org.kuali.rice.core.api.util.tree
Class Tree<T,K>

java.lang.Object
  extended by org.kuali.rice.core.api.util.tree.Tree<T,K>
All Implemented Interfaces:
Serializable

public class Tree<T,K>
extends Object
implements Serializable

Represents a Tree of Objects of generic type T. The Tree is represented as a single rootElement which points to a List> of children. There is no restriction on the number of children that a particular node may have. This Tree provides a method to serialize the Tree into a List by doing a pre-order traversal. It has several methods to allow easy updates of Nodes in the Tree.

See Also:
Serialized Form

Constructor Summary
Tree()
          Default constructor.
 
Method Summary
 Node<T,K> getRootElement()
          Return the root Node of the tree.
 void setRootElement(Node<T,K> rootElement)
          Set the root Element for the tree.
 List<Node<T,K>> toList()
          Returns the Tree as a List of Node objects.
 String toString()
          Returns a String representation of the Tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree()
Default constructor.

Method Detail

getRootElement

public Node<T,K> getRootElement()
Return the root Node of the tree.

Returns:
the root element.

setRootElement

public void setRootElement(Node<T,K> rootElement)
Set the root Element for the tree.

Parameters:
rootElement - the root element to set.

toList

public List<Node<T,K>> toList()
Returns the Tree as a List of Node objects. The elements of the List are generated from a pre-order traversal of the tree.

Returns:
a List>.

toString

public String toString()
Returns a String representation of the Tree. The elements are generated from a pre-order traversal of the Tree.

Overrides:
toString in class Object
Returns:
the String representation of the Tree.


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.