Joda System API

org.joda.util
Class ArrayTreeNode

java.lang.Object
  |
  +--org.joda.util.ArrayTreeNode
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, TreeNode, TreeNode.Internal

public class ArrayTreeNode
extends java.lang.Object
implements TreeNode, TreeNode.Internal, java.io.Serializable, java.lang.Cloneable

ArrayTreeNode implements the TreeNode interface. An ArrayList is used to store the children behind the scenes.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
static class ArrayTreeNode.DepthFirstTreeIterator
          Implementation of TreeIterator that navigates through the nodes in a depth first order.
static class ArrayTreeNode.TreeArrayList
          List of TreeNodes that manages the parent behaviour
 
Nested classes inherited from class org.joda.util.TreeNode
TreeNode.Internal
 
Constructor Summary
ArrayTreeNode()
          Constructor
ArrayTreeNode(java.lang.Object value)
          Constructor
 
Method Summary
 TreeNode getChild(int index)
          Get the child of this node at a particular index
 java.util.List getChildren()
          Get the children of this node.
 TreeNode getParent()
          Get the parent of this node
 java.lang.Object getValue()
          Get the user object of this node
 boolean isLeaf()
          Is this a leaf node (has no children)
 boolean isRoot()
          Is this a root node (has no parent)
 void removeFromParent()
          Detach this node from its parent
 void setParent(TreeNode node)
          Set the parent of this node
 void setValue(java.lang.Object object)
          Set the user object of this node
 java.lang.String toString()
          Get a debugging string
 TreeIterator treeIterator()
          Get a tree iterator from this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayTreeNode

public ArrayTreeNode()
Constructor


ArrayTreeNode

public ArrayTreeNode(java.lang.Object value)
Constructor

Method Detail

isRoot

public boolean isRoot()
Is this a root node (has no parent)

Specified by:
isRoot in interface TreeNode
Returns:
true if no parent

getParent

public TreeNode getParent()
Get the parent of this node

Specified by:
getParent in interface TreeNode
Returns:
the object that is the parent of this node

setParent

public void setParent(TreeNode node)
Set the parent of this node

Specified by:
setParent in interface TreeNode.Internal
Parameters:
node - the new parent node
Returns:
the object that is the parent of this node

isLeaf

public boolean isLeaf()
Is this a leaf node (has no children)

Specified by:
isLeaf in interface TreeNode
Returns:
true if no children

getChild

public TreeNode getChild(int index)
Get the child of this node at a particular index

Specified by:
getChild in interface TreeNode
Parameters:
index - the index to obtain
Returns:
the object that is the parent of this node

getChildren

public java.util.List getChildren()
Get the children of this node. This is a live list and can be updated with TreeNodes.

Specified by:
getChildren in interface TreeNode
Returns:
the list of children

removeFromParent

public void removeFromParent()
Detach this node from its parent

Specified by:
removeFromParent in interface TreeNode

treeIterator

public TreeIterator treeIterator()
Get a tree iterator from this node. Traversal is depth first. The tree is traversed when the iterator is constructed, so concurrent modification is possible.

Specified by:
treeIterator in interface TreeNode
Returns:
the tree iterator

getValue

public java.lang.Object getValue()
Get the user object of this node

Specified by:
getValue in interface TreeNode
Returns:
the user object value

setValue

public void setValue(java.lang.Object object)
Set the user object of this node

Specified by:
setValue in interface TreeNode
Parameters:
object - the new user object value

toString

public java.lang.String toString()
Get a debugging string

Overrides:
toString in class java.lang.Object

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.