org.umber.catalan.transform.xform
Class XFormProcessor

java.lang.Object
  extended byorg.umber.catalan.transform.BaseNodeProcessor
      extended byorg.umber.catalan.transform.xform.XFormProcessor
All Implemented Interfaces:
INodeProcessor
Direct Known Subclasses:
CopyProcessor, DeleteProcessor, InlineProcessor, InsertProcessor, MoveProcessor, RenameProcessor, StyleProcessor, TagProcessor, ToAttributeProcessor, ToElementProcessor, WrapProcessor

public abstract class XFormProcessor
extends BaseNodeProcessor

Common base class for all XForm operations.

Author:
jsheets

Constructor Summary
XFormProcessor(java.lang.String query)
          Creates a new instance of XFormProcessor.
 
Method Summary
 java.lang.String getQuery()
          Retrieves the Bellows query path to select nodes to process.
protected  Datum[] getQueryNodes(Datum datum)
          Finds the Datum nodes to perform the transformation on.
 java.util.List processNode(java.lang.Object node)
          Process a single node.
protected abstract  Datum transformNode(Datum node, Datum root)
          Performs an in-place transformation on the supplied Datum tree.
 
Methods inherited from class org.umber.catalan.transform.BaseNodeProcessor
addLeftover, end, getLeftovers, getNodes, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XFormProcessor

public XFormProcessor(java.lang.String query)
Creates a new instance of XFormProcessor.

Parameters:
query - a Bellows query path to select nodes to process
Method Detail

getQueryNodes

protected Datum[] getQueryNodes(Datum datum)
Finds the Datum nodes to perform the transformation on.

Parameters:
datum - the input datum tree to select nodes from
Returns:
the nodes to operate on

getQuery

public java.lang.String getQuery()
Retrieves the Bellows query path to select nodes to process.

Returns:
Bellows query path for target nodes

processNode

public java.util.List processNode(java.lang.Object node)
Process a single node. The processing action can be any arbitrary task, such as text replacement, data restructuring, or even statistical gathering. The processor should return a processed version of the node; this can be the same object untouched, or the same object modified, or a new set of objects.

Parameters:
node - the node to process
Returns:
a List of processing results (can be empty)

transformNode

protected abstract Datum transformNode(Datum node,
                                       Datum root)
Performs an in-place transformation on the supplied Datum tree.

Parameters:
node - the current node to operate upon
root - the root of the entire XML tree
Returns:
the new root Datum object (usually the same one)