qflib 0.98.1

de.qfs.lib.tree
Class TreeBuilder

java.lang.Object
  |
  +--de.qfs.lib.tree.TreeBuilder

public class TreeBuilder
extends java.lang.Object

Helper class that simplifies building a tree from some kind of data, e.g. a file.

Since:
0.98.1
Version:
$Revision: 1.1 $
Author:
Gregor Schmid

Field Summary
protected  MutableTreeAdapter adapter
          The adapter used for tree manipulation.
protected  java.lang.Object currentNode
          The current node during the build process-
protected static java.lang.Object dummy
          Dummy object to represent null nodes internally.
protected  NodeFactory factory
          The node factory used to create the nodes.
protected  boolean first
          Flag to check for the root node.
protected  java.util.Vector path
          The path to the current node.
protected  java.lang.Object root
          The root object of the new tree.
 
Constructor Summary
TreeBuilder(MutableTreeAdapter adapter, NodeFactory factory)
          Create a new TreeBuilder.
 
Method Summary
 java.lang.Object closeNode()
          Close the current node.
 java.lang.Object getRoot()
          Get the root node of the new tree.
 java.lang.Object openNode(java.lang.Object data)
          Open a new node.
 void reset()
          Reset the TreeBuilder to build a new tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dummy

protected static final java.lang.Object dummy
Dummy object to represent null nodes internally.

first

protected boolean first
Flag to check for the root node.

adapter

protected MutableTreeAdapter adapter
The adapter used for tree manipulation.

factory

protected NodeFactory factory
The node factory used to create the nodes.

root

protected java.lang.Object root
The root object of the new tree.

currentNode

protected java.lang.Object currentNode
The current node during the build process-

path

protected java.util.Vector path
The path to the current node.
Constructor Detail

TreeBuilder

public TreeBuilder(MutableTreeAdapter adapter,
                   NodeFactory factory)
Create a new TreeBuilder.
Parameters:
adapter - The adapter to use for tree manipulation.
factory - The node factory to use to create the nodes.
Method Detail

openNode

public java.lang.Object openNode(java.lang.Object data)
Open a new node.
Parameters:
data - The data for the new node.
Returns:
The new node.

closeNode

public java.lang.Object closeNode()
Close the current node.
Returns:
The new current node, i.e. the parent of the closed node.

getRoot

public java.lang.Object getRoot()
Get the root node of the new tree.
Returns:
The root of the tree.

reset

public void reset()
Reset the TreeBuilder to build a new tree.

qflib 0.98.1