com.tonbeller.jpivot.util
Class TreeNode

java.lang.Object
  extended by com.tonbeller.jpivot.util.TreeNode

public class TreeNode
extends java.lang.Object

Tree Node for the for a general tree of Objects


Constructor Summary
TreeNode(java.lang.Object obj)
          cTtor
 
Method Summary
 void addChildNode(TreeNode child)
          add child node
 TreeNode deepCopy()
          deep copy (clone)
 TreeNode deepCopyPrune(int depth)
          deep copy (clone) and prune
 java.util.List getChildren()
           
 int getLevel()
           
 TreeNode getParent()
           
 java.lang.Object getReference()
           
 void remove()
          remove node from tree
 void setReference(java.lang.Object object)
          set reference object
 int walkChildren(TreeNodeCallback callbackHandler)
          walk through children subtrees of this node
 int walkTree(TreeNodeCallback callbackHandler)
          walk through subtree of this node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode(java.lang.Object obj)
cTtor

Parameters:
obj - referenced object
Method Detail

remove

public void remove()
remove node from tree


addChildNode

public void addChildNode(TreeNode child)
add child node

Parameters:
child - node to be added

deepCopy

public TreeNode deepCopy()
deep copy (clone)

Returns:
copy of TreeNode

deepCopyPrune

public TreeNode deepCopyPrune(int depth)
deep copy (clone) and prune

Parameters:
depth - - number of child levels to be copied
Returns:
copy of TreeNode

getLevel

public int getLevel()
Returns:
level = distance from root

walkTree

public int walkTree(TreeNodeCallback callbackHandler)
walk through subtree of this node

Parameters:
callbackHandler - function called on iteration

walkChildren

public int walkChildren(TreeNodeCallback callbackHandler)
walk through children subtrees of this node

Parameters:
callbackHandler - function called on iteration

getChildren

public java.util.List getChildren()
Returns:
List of children

getParent

public TreeNode getParent()
Returns:
parent node

getReference

public java.lang.Object getReference()
Returns:
reference object

setReference

public void setReference(java.lang.Object object)
set reference object

Parameters:
object - reference