org.expasy.jpl.commons.collection.tree
Class TreeNodeImpl<T>

java.lang.Object
  extended by org.expasy.jpl.commons.collection.tree.TreeNodeImpl<T>
Type Parameters:
T - data type.
All Implemented Interfaces:
Serializable, TreeNode<T>, TreeView<T>

public final class TreeNodeImpl<T>
extends Object
implements TreeNode<T>

Naive tree node.

Version:
1.0
Author:
nikitin.
See Also:
Serialized Form

Method Summary
 void addChild(TreeNode<T> child)
          Add the given child to the node.
 boolean equals(Object o)
           
 TreeNode<T> getChildAt(int index)
           
 List<TreeNode<T>> getChildren()
           
 T getData()
           
 Set<TreeNode<T>> getLeaves()
           
 Set<TreeNode<T>> getNodes()
           
 int getNumberOfChildren()
           
 TreeNode<T> getParent()
           
 int hashCode()
           
 boolean isLeave()
           
 boolean isRoot()
           
static
<T> TreeNodeImpl<T>
newNode(T data, TreeNode<T> parent)
           
static
<T> TreeNodeImpl<T>
newRoot(T data)
           
 void setData(T data)
          Set the data to this node.
 void setParent(TreeNode<T> parent)
          Set the parent node.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

newRoot

public static <T> TreeNodeImpl<T> newRoot(T data)

newNode

public static <T> TreeNodeImpl<T> newNode(T data,
                                          TreeNode<T> parent)

getParent

public final TreeNode<T> getParent()
Specified by:
getParent in interface TreeView<T>
Returns:
the parent node.

setParent

public void setParent(TreeNode<T> parent)
Description copied from interface: TreeNode
Set the parent node.

Specified by:
setParent in interface TreeNode<T>

getChildren

public final List<TreeNode<T>> getChildren()
Specified by:
getChildren in interface TreeView<T>
Returns:
the direct children of the node.

getLeaves

public final Set<TreeNode<T>> getLeaves()
Specified by:
getLeaves in interface TreeView<T>
Returns:
the tree leaves.

getNodes

public final Set<TreeNode<T>> getNodes()
Specified by:
getNodes in interface TreeView<T>
Returns:
the tree nodes.

getNumberOfChildren

public final int getNumberOfChildren()
Specified by:
getNumberOfChildren in interface TreeView<T>
Returns:
the number of children of this node.

isRoot

public final boolean isRoot()
Specified by:
isRoot in interface TreeView<T>
Returns:
true if root node.

isLeave

public final boolean isLeave()
Specified by:
isLeave in interface TreeView<T>
Returns:
the parent node.

addChild

public void addChild(TreeNode<T> child)
Description copied from interface: TreeNode
Add the given child to the node.

Specified by:
addChild in interface TreeNode<T>

getChildAt

public final TreeNode<T> getChildAt(int index)
                             throws IndexOutOfBoundsException
Specified by:
getChildAt in interface TreeView<T>
Returns:
the child node at index.
Throws:
IndexOutOfBoundsException

getData

public final T getData()
Specified by:
getData in interface TreeView<T>
Returns:
the node data.

setData

public void setData(T data)
Description copied from interface: TreeNode
Set the data to this node.

Specified by:
setData in interface TreeNode<T>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.