com.waveset.util
Class TreeNode

java.lang.Object
  extended bycom.waveset.util.TreeNode

public class TreeNode
extends java.lang.Object

A simple collection that stores the nodes in a tree and provides for depth-first and breadth first iteration. This is an unsynchronized class. If you use this class from multiple threads, you must do it in a synchronized context.


Nested Class Summary
static class TreeNode.WouldCreateCycleException
           
 
Field Summary
static java.lang.String code_id
           
 
Constructor Summary
TreeNode(java.lang.Object key, java.lang.Object o, TreeNode parent)
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key, boolean searchAllChildren)
           
 boolean containsValue(java.lang.Object value, boolean searchAllChildren)
           
 boolean equals(java.lang.Object o)
           
 TreeNode get(java.lang.Object key, boolean searchAllChildren)
          Get the requested object
 java.util.List getChildren()
           
 java.lang.Object getKey()
           
 TreeNode getParent()
           
 TreeNode getTopNode()
          Walk to the top of the tree and return that node.
 boolean getTouched()
           
 java.lang.Object getValue()
           
 boolean isEmpty()
           
static void main(java.lang.String[] args)
           
 TreeNode put(java.lang.Object key, java.lang.Object value)
           
 void put(TreeNode child)
           
 TreeNode remove(java.lang.Object key)
           
 void setParent(TreeNode parent)
           
 void setTouched(boolean touched)
           
 void setValue(java.lang.Object value)
           
 java.util.List toList(boolean breadthFirst)
          Return a List of all keys in the tree which can be used for iterating over the tree.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

TreeNode

public TreeNode(java.lang.Object key,
                java.lang.Object o,
                TreeNode parent)
Method Detail

isEmpty

public boolean isEmpty()

containsKey

public boolean containsKey(java.lang.Object key,
                           boolean searchAllChildren)

containsValue

public boolean containsValue(java.lang.Object value,
                             boolean searchAllChildren)

get

public TreeNode get(java.lang.Object key,
                    boolean searchAllChildren)
Get the requested object


getChildren

public java.util.List getChildren()

getKey

public java.lang.Object getKey()

getValue

public java.lang.Object getValue()

setValue

public void setValue(java.lang.Object value)

getParent

public TreeNode getParent()

setParent

public void setParent(TreeNode parent)

getTouched

public boolean getTouched()

setTouched

public void setTouched(boolean touched)

getTopNode

public TreeNode getTopNode()
Walk to the top of the tree and return that node.


put

public TreeNode put(java.lang.Object key,
                    java.lang.Object value)
             throws TreeNode.WouldCreateCycleException
Throws:
TreeNode.WouldCreateCycleException

put

public void put(TreeNode child)
         throws TreeNode.WouldCreateCycleException
Throws:
TreeNode.WouldCreateCycleException

remove

public TreeNode remove(java.lang.Object key)

clear

public void clear()

toList

public java.util.List toList(boolean breadthFirst)
Return a List of all keys in the tree which can be used for iterating over the tree.

Parameters:
breadthFirst - - returns the keys in breadth order - the children of this node will be first, then their children, etc. If false, the keys are in depth order which will have the first child, then its first child, etc.

toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object o)

main

public static void main(java.lang.String[] args)