org.wegra.util.collection
Class TreeNode

java.lang.Object
  extended byorg.wegra.util.collection.TreeNode

public class TreeNode
extends java.lang.Object


Constructor Summary
TreeNode()
           
TreeNode(java.lang.Object value)
           
 
Method Summary
 void add(TreeNode child)
          Adds new child to current tree.
 TreeNode getChildAt(int index)
          Returns the child WTreeNode at index.
 int getChildCount()
          Returns the count of children.
 java.util.Iterator getChildren()
          Returns all child nodes.
 int getIndex(TreeNode child)
          Returns index of specified child.
 TreeNode getParent()
          Returns parent node.
 java.lang.Object getValue()
          Returns current node's value.
 boolean isLeaf()
          Tests if it's leaf node.
 boolean isRoot()
          Tests if it's root node.
 void removeAllChildren()
          Removes all children.
 TreeNode removeChild(TreeNode child)
          Removes child from current tree.
 void removeFromParent()
          Removes itself from parent.
 void setParent(TreeNode parent)
          Resets parent node.
 void setValue(java.lang.Object value)
          Resets current node's value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode()

TreeNode

public TreeNode(java.lang.Object value)
Method Detail

getValue

public final java.lang.Object getValue()
Returns current node's value.

Returns:
value

setValue

public final void setValue(java.lang.Object value)
Resets current node's value.

Parameters:
value - new value

isRoot

public final boolean isRoot()
Tests if it's root node.

Returns:
true if it's root, otherwise false

isLeaf

public boolean isLeaf()
Tests if it's leaf node.

Returns:
true if it's leaf, otherwise false

getParent

public final TreeNode getParent()
Returns parent node.

Returns:
parent node, or null if it's parent node.

setParent

public final void setParent(TreeNode parent)
Resets parent node.

Parameters:
parent - node.

getChildAt

public TreeNode getChildAt(int index)
Returns the child WTreeNode at index.

Parameters:
index - index.
Returns:
child node at index.

getChildCount

public int getChildCount()
Returns the count of children.

Returns:
count of children.

getChildren

public java.util.Iterator getChildren()
Returns all child nodes.

Returns:
all child nodes, or null if it's leaf node.

add

public void add(TreeNode child)
Adds new child to current tree.

Parameters:
child - new child.

removeChild

public TreeNode removeChild(TreeNode child)
Removes child from current tree.

Returns:
removed node.

removeAllChildren

public void removeAllChildren()
Removes all children.


getIndex

public int getIndex(TreeNode child)
Returns index of specified child.

Parameters:
child - child.
Returns:
index of specified child.

removeFromParent

public void removeFromParent()
Removes itself from parent.


toString

public java.lang.String toString()