Access keys

CompositeTextFileFactory

Kind of class: class
Inherits from: BasicClass
Implements:
Version: 1.1
Author: Martin Heidegger
Classpath: org.as2lib.io.file.CompositeTextFileFactory
File last modified: Thursday, 13 October 2005, 18:03:26
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.

Constructor

CompositeTextFileFactory

function CompositeTextFileFactory (
Void)
Constructs a new CompositeTextFileFactory.

Instance methods

createTextFile

function createTextFile (
source:String, size:Byte, uri:String) : TextFile
Creates a TextFile implementation depending to the set TextFileFactorys.
Parameters:
source:
content of the TextFile to create
size :
size in org.as2lib.data.type.Byte of the loaded resource
uri :
location of the loaded resource
Returns:
TextFile that represents the resource

putTextFileFactoryByExtension

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:
extension :
extension of the file that should be recognized by the
passed-in textFileFactory
textFileFactory:
TextFileFactory that creates the files

putTextFileFactoryByExtensions

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:
extensions :
list of extensions of files that should be recognized
by the passed-in textFileFactory
fileFactory:
TextFileFactory that creates the files

setDefaultTextFileFactory

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