flattree
Class TreeReader

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

public class TreeReader
extends Object
implements TreeProcessor

A reader of a tree's Nodes.

See Also:
read()

Field Summary
static int END
           
static int START
           
 
Constructor Summary
TreeReader(Node root, FlatReader reader)
          Read nodes from the given reader.
 
Method Summary
 Node getCurrentNode()
          Get the currently read node.
 String getName()
          Get the name of the recently started Node.
 Position getPosition()
           
 Range getRange()
          Get the range for current Node.
 Range getRange(Leaf leaf)
          Get a leaf's range for the current Node.
 Map<String,String> getValues()
          Get the leaves' values for the recently started Node.
protected  State newState()
          Factory method to create a new state.
 int read()
          Read the next START or END.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START

public static final int START
See Also:
Constant Field Values

END

public static final int END
See Also:
Constant Field Values
Constructor Detail

TreeReader

public TreeReader(Node root,
                  FlatReader reader)
Read nodes from the given reader.

Parameters:
root - root node
reader - reader to read from
Method Detail

getCurrentNode

public Node getCurrentNode()
Get the currently read node.

Throws:
IllegalStateException - if no node is currently read

read

public int read()
Read the next START or END.

Returns:
START or END
Throws:
TreeException - if no Node was able to read the current line
TreeException - if Node.read(ReadLine, State) failed to read the current line
See Also:
getName(), getValues()

getPosition

public Position getPosition()

getName

public String getName()
Get the name of the recently started Node.

Returns:
name
See Also:
START

getValues

public Map<String,String> getValues()
Get the leaves' values for the recently started Node.

Returns:
values
See Also:
read(), START

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

newState

protected State newState()
Factory method to create a new state. Invoked for every read Node .

Returns:
state


Copyright © 2011. All Rights Reserved.