org.writersforge.catalan.transform
Class Transformer

java.lang.Object
  extended byorg.writersforge.catalan.transform.Transformer

public class Transformer
extends java.lang.Object

A XML driven data transformer for converting data from one format to another. Performs a series of operations against a List of input data objects. The input data will change content and size as it goes through the chain of transforms. For complete documentation on the Transform XML language used by the Transformer, see the Catalan User Guide.

Author:
jsheets

Constructor Summary
Transformer(org.writersforge.bellows.Datum transform)
          Deprecated. Creates a new instance of Transformer.
Transformer(org.writersforge.bellows.Datum transform, ProcessorRegistry registry)
          Deprecated. Creates a new instance of Transformer with a custom mapping registry.
 
Method Summary
 java.lang.String[] getProcessorIds()
          Deprecated. Retrieves an array of unique identifiers for all NodeProcessors in this Transformer.
static void main(java.lang.String[] args)
          Deprecated. Processes the Transform XML, loading data from one or more parameters.
 java.util.List process(java.lang.String[] ids, java.util.List nodes)
          Deprecated. Runs the List of input nodes through a set of processors, by id.
 java.util.List processAll(java.util.List nodes)
          Deprecated. Runs the List of input nodes through every processor in the Transformer's XML specification, in order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transformer

public Transformer(org.writersforge.bellows.Datum transform)
Deprecated. 
Creates a new instance of Transformer. Loads a collection of NodeProcessor implementations based on the specification in the supplied Datum transform tree.

Parameters:
transform - the XML specification

Transformer

public Transformer(org.writersforge.bellows.Datum transform,
                   ProcessorRegistry registry)
Deprecated. 
Creates a new instance of Transformer with a custom mapping registry. Loads a collection of NodeProcessor implementations based on the specification in the supplied Datum transform tree. Only scans the registry during initialization, so any changes to the registry after the Transformer instance exists will not affect that Transformer.

Parameters:
transform - the XML specification
registry - XML-to-processor mapping registry
Method Detail

processAll

public java.util.List processAll(java.util.List nodes)
Deprecated. 
Runs the List of input nodes through every processor in the Transformer's XML specification, in order.

Parameters:
nodes - input data nodes
Returns:
the processed output data nodes

getProcessorIds

public java.lang.String[] getProcessorIds()
Deprecated. 
Retrieves an array of unique identifiers for all NodeProcessors in this Transformer. A processor's id can be explicitly specified in the XML specification with the 'id' attribute. If the 'id' attribute does not exist for a processor, the id becomes the fully qualified class of the NodeProcessor followed by a space and the zero-based index of the processor in the XML specification. For example, given this XML specification:
 <transform>
   <replace old='oldtext1' new='newtext1'/>
   <replace id='textreplace' old='oldtext2' new='newtext2'/>
   <replace old='oldtext3' new='newtext3'/>
 <transform>

The returned ids would be:

If any processors share the same explicit id, the second and later duplicates will all be treated as if they had no explicit id. Thus, this XML specification:

 <transform>
   <replace id='textreplace' old='oldtext1' new='newtext1'/>
   <replace id='textreplace' old='oldtext2' new='newtext2'/>
   <replace id='textreplace' old='oldtext3' new='newtext3'/>
 <transform>

would result in the following ids:

Returns:
an array of processor identifiers

process

public java.util.List process(java.lang.String[] ids,
                              java.util.List nodes)
Deprecated. 
Runs the List of input nodes through a set of processors, by id. The input data will be sent through the processors in the order they appear in the ids array, even if that means the same id is run more than once.

Parameters:
ids - the ids of the transforms to run
nodes - input data nodes
Returns:
the processed output data nodes
Throws:
java.lang.IllegalArgumentException - if an id in ids does not exist in the XML specification

main

public static void main(java.lang.String[] args)
Deprecated. 
Processes the Transform XML, loading data from one or more parameters. The first parameter is always a file path or URL to the Transform XML document. The Transformer loads any further parameters into the input data queue. If they are file paths or URLs, they can be loaded with the <import> operation.

Parameters:
args - the Transform XML file and any input data parameters