TextFileFactory
CompositeTextFileFactory
uses different TextFileFactory
implementations depending to the extension of the passed-in uri
in
FileFactory.createTextFile
.
Its a common case that different file extensions are used for different
kinds of file formats. CompositeTextFileFactory
allows different processing
of resources depending to the extension of the loaded file.
If a certain extension has not been specially set it uses the defaultTextFileFactory
to be set with setDefaultTextFileFactory
.
It uses SimpleTextFileFactory as default if no other has been set.
public function createTextFile(source:String, size:Byte, uri:String):TextFile
Creates a TextFile
implementation depending to the set TextFileFactory
s.
source | content of the TextFile to create
|
size | size in Byte of the loaded resource |
uri | location of the loaded resource |
TextFile
that represents the resource
public function setDefaultTextFileFactory(textFileFactory:TextFileFactory):Void
Sets the default TextFileFactory
to be used in default case.
If no other set TextFileFactory
applies to the requested
uri
the passed-in textFileFactory
will be used.
textFileFactory | TextFileFactory to be used in default case
|
public function putTextFileFactoryByExtension(extension:String, fileFactory:TextFileFactory):Void
Sets a certain TextFileFactory
to be used for files with the
passed-in extension
.
The passed-in extension should not contain a leading ".".
Proper example:
var textFileFactory:CompositeFileFactory = new CompositeTextFileFactory();
textFileFactory.putTextFileFactoryByExtension("txt", new SimpleTextFileFactory());
extension | extension of the file that should be recognized by the
passed-in textFileFactory
|
public function putTextFileFactoryByExtensions(extensions:Array, fileFactory:TextFileFactory):Void
Sets a certain TextFileFactory
to be used for files with one extension
of the passed-in extensions
.
Any of the passed-in extension should not contain a leading ".".
Proper example:
var textFileFactory:CompositeTextFileFactory = new CompositeTextFileFactory();
textFileFactory.putTextFileFactoryByExtensions(["txt", "prop"],
new SimpleTextFileFactory());
extensions | list of extensions of files that should be recognized
by the passed-in textFileFactory
|
fileFactory | TextFileFactory that creates the files
|