org.writersforge.catalan.transform
Class BaseNodeProcessor
java.lang.Object
org.writersforge.catalan.transform.BaseNodeProcessor
- All Implemented Interfaces:
- org.writersforge.bellows.traverse.NodeProcessor
- Direct Known Subclasses:
- BeanToXml, Concatenator, DatumToObject, DebugProcessor, ExportJavaProcessor, ExportProcessor, FromAsciiConverter, GroupProcessor, ImportProcessor, ObjectToDatum, PdfgenProcessor, SqlProcessor, TextProcessor, TextToLattice, ToAsciiConverter, VelocityProcessor, XFormProcessor, XmlSelectProcessor, XmlToBean, XmlToHtml
- public abstract class BaseNodeProcessor
- extends java.lang.Object
- implements org.writersforge.bellows.traverse.NodeProcessor
A common base implementation for NodeProcessor.
- Author:
- jsheets
|
Method Summary |
protected void |
addLeftover(java.lang.Object node)
Add a node to the list of unprocessed nodes. |
void |
end(java.util.List nodes)
Ends the current traversal. |
protected java.util.List |
getLeftovers()
Retrieves the current list of unprocessed input nodes. |
protected java.util.List |
getNodes()
Retrieves the current node processing list. |
void |
start(java.util.List nodes)
Starts a new traversal. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.writersforge.bellows.traverse.NodeProcessor |
processNode |
BaseNodeProcessor
public BaseNodeProcessor()
- Creates a new instance of BaseNodeProcessor.
getNodes
protected java.util.List getNodes()
- Retrieves the current node processing list. This should only have
contents during traversals, and should only be modified by start()
and end().
- Returns:
- a read only copy of the current node list
getLeftovers
protected java.util.List getLeftovers()
- Retrieves the current list of unprocessed input nodes. This should
only have contents during traversals, and is only really valid during
the end() method.
- Returns:
- a read only copy of the current node list
addLeftover
protected void addLeftover(java.lang.Object node)
- Add a node to the list of unprocessed nodes. The leftover nodes
will typically be appended to the output in the end() method. Normally,
it is preferrable to pass unprocessed nodes out of the processNode()
method; however, when a processor requires more than one node
for an operation, it must cache the results, and may not return any
nodes until the end() post-processing step. In this case, returning
any unprocessed nodes immediately from processNode() will result in
those nodes appearing out of order in the output node list. To avoid
this, you can cache nodes with addLeftover(), then access the full
collection of leftovers with getLeftovers() in the end() method.
- Parameters:
node - unprocessed input data node
start
public void start(java.util.List nodes)
- Starts a new traversal. This method initializes the processor for a
new traversal over a set of nodes. The nodes are not actually
traversed or processed at this point, but the processor is allowed to
perform any pre-traversal calculations, for example storing the total
number of nodes for index calculations.
- Specified by:
start in interface org.writersforge.bellows.traverse.NodeProcessor
- Parameters:
nodes - the list of nodes that will later be traversed
end
public void end(java.util.List nodes)
- Ends the current traversal. Any post-processing on the post-traversal
nodes should be done here, for example removing duplicate nodes. This
method should also clean up any temporary states created during a
traversal. After
end(), the processor should be ready
for the next new traversal.
- Specified by:
end in interface org.writersforge.bellows.traverse.NodeProcessor
- Parameters:
nodes - the list of nodes that has just been traversed