org.writersforge.catalan.transform.io
Class DebugProcessor

java.lang.Object
  extended byorg.writersforge.catalan.transform.BaseNodeProcessor
      extended byorg.writersforge.catalan.transform.io.DebugProcessor
All Implemented Interfaces:
org.writersforge.bellows.traverse.NodeProcessor

public class DebugProcessor
extends BaseNodeProcessor

Debug logging processor which sends each node to the debug output, but does not alter anything.

Author:
jsheets

Constructor Summary
DebugProcessor(org.writersforge.bellows.Datum xml)
          Creates a new instance of DebugProcessor from the XML spec.
DebugProcessor(java.lang.String logLevel, java.lang.String message)
          Creates a new instance of DebugProcessor that logs the message to the requested logging channel.
DebugProcessor(java.lang.String logLevel, java.lang.String preText, java.lang.String postText)
          Creates a new instance of DebugProcessor that logs all nodes to the requested logging channel.
 
Method Summary
static void main(java.lang.String[] args)
          Tests debugging output, since it's not so easy in a JUnit test.
 java.util.List processNode(java.lang.Object node)
          Process a single node.
 void start(java.util.List nodes)
          Starts a new traversal.
 
Methods inherited from class org.writersforge.catalan.transform.BaseNodeProcessor
addLeftover, end, getLeftovers, getNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugProcessor

public DebugProcessor(org.writersforge.bellows.Datum xml)
Creates a new instance of DebugProcessor from the XML spec.

Parameters:
xml - XML initializing spec

DebugProcessor

public DebugProcessor(java.lang.String logLevel,
                      java.lang.String preText,
                      java.lang.String postText)
Creates a new instance of DebugProcessor that logs all nodes to the requested logging channel. Valid log levels are "trace", "debug", "info", "warn", "error", and "fatal".

Parameters:
logLevel - the name of the logging channel
preText - optional leading log text for each node
postText - optional trailing log text for each node

DebugProcessor

public DebugProcessor(java.lang.String logLevel,
                      java.lang.String message)
Creates a new instance of DebugProcessor that logs the message to the requested logging channel. Valid log levels are "trace", "debug", "info", "warn", "error", and "fatal".

Parameters:
logLevel - the name of the logging channel
message - static log text
Method Detail

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
Overrides:
start in class BaseNodeProcessor
Parameters:
nodes - the list of nodes that will later be traversed

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)

main

public static void main(java.lang.String[] args)
Tests debugging output, since it's not so easy in a JUnit test.

Parameters:
args - unused