org.writersforge.catalan.transform.text
Class ToAsciiConverter

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

public class ToAsciiConverter
extends BaseNodeProcessor

A packed ASCII field processor which explodes a packed ASCII data node into a collection of Java objects, or vice versa.

Author:
jsheets
See Also:
AsciiFieldManager

Constructor Summary
ToAsciiConverter(org.writersforge.bellows.Datum xml)
          Creates a new instance of ToAsciiConverter from the XML spec.
ToAsciiConverter(java.lang.String fieldSpec)
          Creates a new instance of AsciiConverter.
 
Method Summary
 void end(java.util.List nodes)
          Ends the current traversal.
 java.util.List processNode(java.lang.Object node)
          Process a single node.
 void setPadding(java.lang.String padding)
          Assigns a custom padding string to use as a cycling overlay to all padded ('x') spans.
 java.lang.String toString()
          Convert this object to a String value.
 
Methods inherited from class org.writersforge.catalan.transform.BaseNodeProcessor
addLeftover, getLeftovers, getNodes, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToAsciiConverter

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

Parameters:
xml - XML initializing spec

ToAsciiConverter

public ToAsciiConverter(java.lang.String fieldSpec)
Creates a new instance of AsciiConverter.

Parameters:
fieldSpec - ASCII field formatting spec
Method Detail

setPadding

public void setPadding(java.lang.String padding)
Assigns a custom padding string to use as a cycling overlay to all padded ('x') spans. If the padding string is exactly one character long, it will be used for all padding throughout the ASCII data. If it is more than one character long, the padding will be split across all padding spans and repeated if necessary. For example, given the field spec of "2x2s4x", and the padding string "ABCD", the padded data would look like: "AB  CDAB".

Parameters:
padding - the custom padding string

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
Overrides:
end in class BaseNodeProcessor
Parameters:
nodes - the list of nodes that has just been 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)

toString

public java.lang.String toString()
Convert this object to a String value.

Returns:
stringified object