jasi.sim.user.tree
Class Tree<T>

java.lang.Object
  extended by jasi.sim.user.tree.Tree<T>
Type Parameters:
T - The type.
Direct Known Subclasses:
AbstractLispTree, OmtTree

public abstract class Tree<T>
extends java.lang.Object

Create a node tree from a Lisp string.


Field Summary
protected static int CHILD
          Indicates a child node.
protected static int ROOT
          Indicates a root node.
protected static int SIBLING
          Indicates a sibling node.
 
Constructor Summary
Tree()
           
 
Method Summary
 AbstractNode<T> current()
          Get this tree's current node.
static
<S> java.util.Collection<AbstractNode<S>>
get(java.util.Collection<AbstractNode<S>> nodeList, S content)
          Get all children of a given content for a list of nodes.
protected  void node(int type, T content)
          Create a node of a given type for the current node.
static java.lang.String read(java.io.Reader reader)
          Create a string for tree from a given reader.
protected  void reduceLevel()
          Reduce the tree level.
 AbstractNode<T> root()
          Get this tree's root node.
 java.lang.String toString()
          Get string representation of this node.
static
<S> java.lang.String
toString(java.util.Collection<AbstractNode<S>> nodeList)
          Get string representation of a list of nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT

protected static final int ROOT
Indicates a root node.

See Also:
Constant Field Values

CHILD

protected static final int CHILD
Indicates a child node.

See Also:
Constant Field Values

SIBLING

protected static final int SIBLING
Indicates a sibling node.

See Also:
Constant Field Values
Constructor Detail

Tree

public Tree()
Method Detail

read

public static java.lang.String read(java.io.Reader reader)
                             throws java.io.IOException
Create a string for tree from a given reader.

Parameters:
reader - The reader for the input.
Returns:
The input string for tree.
Throws:
java.io.IOException - If an I/O error occurs.

get

public static <S> java.util.Collection<AbstractNode<S>> get(java.util.Collection<AbstractNode<S>> nodeList,
                                                            S content)
Get all children of a given content for a list of nodes.

Type Parameters:
S - The type of node content.
Parameters:
nodeList - The list of nodes.
content - The content of the children.
Returns:
The children.

toString

public static <S> java.lang.String toString(java.util.Collection<AbstractNode<S>> nodeList)
Get string representation of a list of nodes.

Type Parameters:
S - The content type of node.
Parameters:
nodeList - The list of nodes.
Returns:
The string.

reduceLevel

protected final void reduceLevel()
Reduce the tree level.


node

protected final void node(int type,
                          T content)
                   throws TreeException
Create a node of a given type for the current node.

Parameters:
type - The node type.
content - The node's content.
Throws:
TreeException - Used invalid type.

root

public final AbstractNode<T> root()
Get this tree's root node.

Returns:
The root node or empty node.

current

public final AbstractNode<T> current()
Get this tree's current node.

Returns:
The root node.

toString

public java.lang.String toString()
Get string representation of this node.

Overrides:
toString in class java.lang.Object
Returns:
The string.