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

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

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

Represents a node of the Tree class. The Node is also a container, and can be thought of as instrumentation to determine the location of the type T in the Tree.

See Also:
Serialized Form

Constructor Summary
Node()
          Default constructor.
Node(T data)
          Convenience constructor to create a Node with an instance of T.
Node(T data, K label)
          Convenience constructor to create a Node with an instance of T and K.
 
Method Summary
 void addChild(Node<T,K> child)
          Adds a child to the list of children for this Node.
 List<Node<T,K>> getChildren()
          Return the children of Node.
 T getData()
          Data object contained in the node (a leaf)
 K getNodeLabel()
          Object containing the data for labeling the node (can be simple String)
 String getNodeType()
          Indicates what type of node is being represented, used to give a functional label for the node that can also be used for presentation purposes
 int getNumberOfChildren()
          Returns the number of immediate children of this Node.
 void insertChildAt(int index, Node<T,K> child)
          Inserts a Node at the specified position in the child list.
 void removeChildAt(int index)
          Remove the Node element at index index of the List>.
 void setChildren(List<Node<T,K>> children)
          Sets the children of a Node object.
 void setData(T data)
          Setter for the nodes data
 void setNodeLabel(K nodeLabel)
          Setter for the nodes label data
 void setNodeType(String nodeType)
          Setter for the node type String
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node()
Default constructor.


Node

public Node(T data)
Convenience constructor to create a Node with an instance of T.

Parameters:
data - an instance of T.

Node

public Node(T data,
            K label)
Convenience constructor to create a Node with an instance of T and K.

Parameters:
data - an instance of T.
Method Detail

getChildren

public List<Node<T,K>> getChildren()
Return the children of Node. The Tree is represented by a single root Node whose children are represented by a List>. Each of these Node elements in the List can have children. The getChildren() method will return the children of a Node.

Returns:
the children of Node

setChildren

public void setChildren(List<Node<T,K>> children)
Sets the children of a Node object. See docs for getChildren() for more information.

Parameters:
children - the List> to set.

getNumberOfChildren

public int getNumberOfChildren()
Returns the number of immediate children of this Node.

Returns:
the number of immediate children.

addChild

public void addChild(Node<T,K> child)
Adds a child to the list of children for this Node. The addition of the first child will create a new List>.

Parameters:
child - a Node object to set.

insertChildAt

public void insertChildAt(int index,
                          Node<T,K> child)
                   throws IndexOutOfBoundsException
Inserts a Node at the specified position in the child list. Will throw an ArrayIndexOutOfBoundsException if the index does not exist.

Parameters:
index - the position to insert at.
child - the Node object to insert.
Throws:
IndexOutOfBoundsException - if thrown.

removeChildAt

public void removeChildAt(int index)
                   throws IndexOutOfBoundsException
Remove the Node element at index index of the List>.

Parameters:
index - the index of the element to delete.
Throws:
IndexOutOfBoundsException - if thrown.

getData

public T getData()
Data object contained in the node (a leaf)

Returns:
Object

setData

public void setData(T data)
Setter for the nodes data

Parameters:
data -

getNodeLabel

public K getNodeLabel()
Object containing the data for labeling the node (can be simple String)

Returns:
K

setNodeLabel

public void setNodeLabel(K nodeLabel)
Setter for the nodes label data

Parameters:
nodeLabel -

getNodeType

public String getNodeType()
Indicates what type of node is being represented, used to give a functional label for the node that can also be used for presentation purposes

Returns:
String node type

setNodeType

public void setNodeType(String nodeType)
Setter for the node type String

Parameters:
nodeType -

toString

public String toString()
Overrides:
toString in class Object


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