org.txt2xml.config
Class ProcessorFactory

java.lang.Object
  |
  +--org.txt2xml.config.ProcessorFactory

public class ProcessorFactory
extends java.lang.Object

Create a Processor from a configuration file.

Config file of the form:

     <txt2xml>
 *****
     </txt2xml>
 

Author:
Steve Meyfroidt

Method Summary
 Processor createProcessor(java.io.Reader configReader)
           Read the configuration and return the Processor defined: this will include sub-Processors or following Processors if defined in the config.
 Processor createProcessor(java.net.URL configUrl)
           Read the configuration and return the Processor defined: this will include sub-Processors or following Processors if defined in the config.
static ProcessorFactory getInstance()
           
protected  Processor readProcessor(org.jdom.Element processorElement)
           Read config for a Processor in the passed "Processor" Element and return the Processor defined there, including sub-Processors.
protected  Processor readProcessorSequenceFrom(org.jdom.Element parentElement)
           Read config contained by the passed parent Element and return the sequence of Processors defined there, which might include sub-Processors and following Processors if defined.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ProcessorFactory getInstance()

createProcessor

public Processor createProcessor(java.io.Reader configReader)
                          throws ConfigException

Read the configuration and return the Processor defined: this will include sub-Processors or following Processors if defined in the config.

Parameters:
configReader - Reader for a config definition.
Returns:
Processor the Processor defined by the config file at the passed URL.
ConfigException

createProcessor

public Processor createProcessor(java.net.URL configUrl)
                          throws ConfigException

Read the configuration and return the Processor defined: this will include sub-Processors or following Processors if defined in the config.

Parameters:
configUrl - URL of a config file.
Returns:
Processor the Processor defined by the config file at the passed URL.
ConfigException

readProcessorSequenceFrom

protected Processor readProcessorSequenceFrom(org.jdom.Element parentElement)
                                       throws ConfigException

Read config contained by the passed parent Element and return the sequence of Processors defined there, which might include sub-Processors and following Processors if defined.

Note that non-"Processor" elements are silently ignored.

Parameters:
parentElement - the Element containing a Processor definition. Only child "Processor" elements are handled.
Returns:
Processor the Processor defined within the parent Eement.
ConfigException

readProcessor

protected Processor readProcessor(org.jdom.Element processorElement)
                           throws ConfigException

Read config for a Processor in the passed "Processor" Element and return the Processor defined there, including sub-Processors.

The type of a Processor is read from the processor_types.properties configuration. The following types are pre-defined but can be overriden in a "processor_types.properties" file:

Processors are created using java.beans.Beans.instantiate() so serialised Processors can be loaded with the appropriate config. See JDK javadoc.

Parameters:
processorElement - the top-level Processor Element.
Returns:
Processor matching the config.
ConfigException


Copyright 2002 Steve Meyfroidt. All Rights Reserved.