Class org.as2lib.io.file.CompositeTextFileFactory

Implemented Interfaces

TextFileFactory

Description

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.

Method Index

new CompositeTextFileFactory()
createTextFile(), putTextFileFactory(), putTextFileFactoryByExtension(), putTextFileFactoryByExtensions(), setDefaultTextFileFactory()

Inherited from BasicClass

Constructor Detail

CompositeTextFileFactory

public function CompositeTextFileFactory(Void)

Constructs a new CompositeTextFileFactory.

Method Detail

createTextFile

public function createTextFile(source:String, size:Byte, uri:String):TextFile

Creates a TextFile implementation depending to the set TextFileFactorys.

Parameters

sourcecontent of the TextFile to create
sizesize in Byte of the loaded resource
urilocation of the loaded resource

Return

TextFile that represents the resource

Specified By

createTextFile() in org.as2lib.io.file.TextFileFactory

setDefaultTextFileFactory

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.

Parameters

textFileFactory TextFileFactory to be used in default case

putTextFileFactory

public function putTextFileFactory()

putTextFileFactoryByExtension

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());

Parameters

extensionextension of the file that should be recognized by the passed-in textFileFactory

putTextFileFactoryByExtensions

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());

Parameters

extensionslist of extensions of files that should be recognized by the passed-in textFileFactory
fileFactory TextFileFactory that creates the files