flattree
Class TreeWriter

java.lang.Object
  extended by flattree.TreeWriter
All Implemented Interfaces:
TreeProcessor

public class TreeWriter
extends Object
implements TreeProcessor

A writer of a tree's Nodes.

See Also:
writeStart(String, Map), writeEnd()

Constructor Summary
TreeWriter(FlatWriter writer)
          Write nodes to the given writer.
TreeWriter(Node root, FlatWriter writer)
          Write nodes to the given writer.
 
Method Summary
protected  Node createNode(Node parent, String name, Map<String,String> values)
          Hook method for subclasses to create a child node with the given name.
 Position getPosition()
           
 Range getRange()
          Get the range for current Node.
 Range getRange(Leaf leaf)
          Get a leaf's range for the current Node.
protected  State newState(Map<String,String> values)
           
 void writeEnd()
          End the current Node.
 void writeStart(String name, Map<String,String> values)
          Start a Node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeWriter

public TreeWriter(FlatWriter writer)
Write nodes to the given writer.

Parameters:
writer - write to write to
See Also:
createNode(Node, String, Map)

TreeWriter

public TreeWriter(Node root,
                  FlatWriter writer)
Write nodes to the given writer.

Parameters:
root - root node
writer - write to write to
Method Detail

writeStart

public void writeStart(String name,
                       Map<String,String> values)
Start a Node.

Parameters:
name - name of node to start
values - values for the node's leaves

getPosition

public Position getPosition()

createNode

protected Node createNode(Node parent,
                          String name,
                          Map<String,String> values)
Hook method for subclasses to create a child node with the given name. This default implementation always throws a TreeException.

Parameters:
parent - parent of node to create, null if root
name - name of node to create
values - values leaves' values
Returns:
created node, must not be null
Throws:
TreeException - always

getRange

public Range getRange()
Description copied from interface: TreeProcessor
Get the range for current Node.

Specified by:
getRange in interface TreeProcessor
Returns:
range

getRange

public Range getRange(Leaf leaf)
Description copied from interface: TreeProcessor
Get a leaf's range for the current Node.

Specified by:
getRange in interface TreeProcessor
Parameters:
leaf - leaf to get range for
Returns:
range

writeEnd

public void writeEnd()
End the current Node.


newState

protected State newState(Map<String,String> values)


Copyright © 2011. All Rights Reserved.