net.sf.infrared.agent.util
Class TreeNode

java.lang.Object
  extended bynet.sf.infrared.agent.util.TreeNode
All Implemented Interfaces:
Serializable

public class TreeNode
extends Object
implements Serializable

Implementation of a TreeNode that represents a single node in a Tree

See Also:
Serialized Form

Constructor Summary
TreeNode()
          Default constructor - required for handling mapping to XML
 
Method Summary
 void addChild(TreeNode child)
          Add a new child node to the end of the list
 void addChildren(List children)
           
static TreeNode createTreeNode(Object value)
          Factory method to create tree nodes
 TreeNode find(Object value)
           
 List getChildren()
          Return the list of child nodes
 int getDepth()
          Returns the depth at which this node appears in a tree.
 TreeNode getParent()
          Returns the parent node
 int getPosition()
          Returns the position the node occupies among the children of the parent node.
 Object getValue()
          Get the value associated with this TreeNode
 boolean removeChild(TreeNode child)
           
 void setParent(TreeNode parentNode)
          Set the parent for this node
 String toString()
           
 void traverseBreadthFirst(NodeVisitor visitor)
          traverse the tree (starting at this node) breadth first
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode()
Default constructor - required for handling mapping to XML

Method Detail

createTreeNode

public static TreeNode createTreeNode(Object value)
Factory method to create tree nodes

Parameters:
value -
Returns:
a new tree node object

getValue

public Object getValue()
Get the value associated with this TreeNode

Returns:
associated value

getChildren

public List getChildren()
Return the list of child nodes

Returns:
returns list of TreeNodes

addChild

public void addChild(TreeNode child)
Add a new child node to the end of the list

Parameters:
child - - child node shouldn't be null

removeChild

public boolean removeChild(TreeNode child)

setParent

public void setParent(TreeNode parentNode)
Set the parent for this node

Parameters:
parentNode -

getParent

public TreeNode getParent()
Returns the parent node

Returns:
parent node

traverseBreadthFirst

public void traverseBreadthFirst(NodeVisitor visitor)
traverse the tree (starting at this node) breadth first

Parameters:
visitor -

find

public TreeNode find(Object value)

getDepth

public int getDepth()
Returns the depth at which this node appears in a tree. Will return -1 if the tree is not part of a tree

Returns:

getPosition

public int getPosition()
Returns the position the node occupies among the children of the parent node. Will return -1 if the tree is not part of a tree

Returns:

addChildren

public void addChildren(List children)

toString

public String toString()