org.kuali.student.common.ui.client.widgets.table
Class Node<T>

java.lang.Object
  extended by org.kuali.student.common.ui.client.widgets.table.Node<T>
All Implemented Interfaces:
Cloneable

public class Node<T>
extends Object
implements Cloneable

A generic tree node.


Field Summary
(package private)  List<Node> childrenList
          Children are stored in a list
(package private)  String id
           
(package private)  Node parent
          Parent Node.
(package private)  T userObject
          User Object
 
Constructor Summary
Node()
          Empty, default constructor
Node(T obj)
          Constructor of Node which accepts the user object
 
Method Summary
 void addNode(Node node)
          Add one child and set child's parent to current node
 List<Node> children()
           
 Node<T> clone()
           
 List<Node> deepTrans(Node root)
           
 List<Node<T>> getAllChildren()
          Return all children and grand children
 int getAllLeafCount()
          Returns the total number of leaves that are descendants of this node.
 Node getChildAt(int index)
          Get the child at index
 int getChildCount()
          Return the child count
 int getDistance(Node node)
           
 Node<T> getFirstLeafDescendant()
          Get the first leaf among all its children
 int getIndex(Node aChild)
           
 List<Node> getLeafChildren()
           
 List<Node> getLeafSiblings()
           
 int getMaxLevelDistance()
           
 List<Node> getNonLeafChildren()
          Return all non-leaf children
 Node getParent()
          Get the parent of current node
 List<Node> getSiblings()
           
 T getUserObject()
          Get the user object from node
 boolean isLeaf()
          If it has no children, it is a leaf
 boolean isNodeChild(Node aNode)
          Is passed node a child of current node
 boolean isNodeSibling(Node anotherNode)
          Is parsed in node a sibling
static void main(String[] argv)
           
 void remove(int childIndex)
          Remove child at childIndex
 void remove(Node child)
          Remove child from children list
 void removeAllChildren()
           
 void removeFromParent()
          Remove child from parent
 void setParent(Node parent)
          Set the Parent node for current node
 void setUserObject(T obj)
          Set the user object to this node
 List<List<Node>> toLevel()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

childrenList

List<Node> childrenList
Children are stored in a list


parent

Node parent
Parent Node. null if node has no parent


userObject

T userObject
User Object


id

String id
Constructor Detail

Node

public Node()
Empty, default constructor


Node

public Node(T obj)
Constructor of Node which accepts the user object

Parameters:
obj - user object
Method Detail

getUserObject

public T getUserObject()
Get the user object from node

Returns:
T returns the user object. User object must by type T

setUserObject

public void setUserObject(T obj)
Set the user object to this node

Parameters:
obj - obj must be an instanceo of type T

setParent

public void setParent(Node parent)
Set the Parent node for current node

Parameters:
parent - new parent

getParent

public Node getParent()
Get the parent of current node

Returns:
the parent

addNode

public void addNode(Node node)
Add one child and set child's parent to current node

Parameters:
node - new child

isLeaf

public boolean isLeaf()
If it has no children, it is a leaf

Returns:
boolean is it a leaf

getChildCount

public int getChildCount()
Return the child count


getChildAt

public Node getChildAt(int index)
Get the child at index

Parameters:
index - the index of the child
Returns:
the child

removeFromParent

public void removeFromParent()
Remove child from parent


remove

public void remove(int childIndex)
Remove child at childIndex

Parameters:
childIndex - child indexs

remove

public void remove(Node child)
Remove child from children list

Parameters:
child -

removeAllChildren

public void removeAllChildren()

isNodeChild

public boolean isNodeChild(Node aNode)
Is passed node a child of current node

Parameters:
aNode -

getIndex

public int getIndex(Node aChild)

isNodeSibling

public boolean isNodeSibling(Node anotherNode)
Is parsed in node a sibling


getAllLeafCount

public int getAllLeafCount()
Returns the total number of leaves that are descendants of this node.

Returns:
the number of leaves beneath this node

getAllChildren

public List<Node<T>> getAllChildren()
Return all children and grand children


getFirstLeafDescendant

public Node<T> getFirstLeafDescendant()
Get the first leaf among all its children


getNonLeafChildren

public List<Node> getNonLeafChildren()
Return all non-leaf children

Returns:
List list of non-leaf children

getLeafChildren

public List<Node> getLeafChildren()

getSiblings

public List<Node> getSiblings()

getLeafSiblings

public List<Node> getLeafSiblings()

children

public List<Node> children()

toLevel

public List<List<Node>> toLevel()

deepTrans

public List<Node> deepTrans(Node root)

getMaxLevelDistance

public int getMaxLevelDistance()

getDistance

public int getDistance(Node node)

toString

public String toString()
Overrides:
toString in class Object

clone

public Node<T> clone()
Overrides:
clone in class Object

main

public static void main(String[] argv)


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.