org.melati.util
Class TreeNode
java.lang.Object
org.melati.util.TreeNode
public class TreeNode
- extends Object
A Tree
node.
- Author:
- MylesC At paneris.org
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parent
protected TreeNode parent
TreeNode
public TreeNode(Treeable n,
int d)
- Constructor.
- Parameters:
n
- the Treeable objectd
- the depth of this node
isRoot
public boolean isRoot()
- Returns:
- whether this is a root node
isLeaf
public boolean isLeaf()
- Returns:
- whether this is a terminal node
getDepth
public int getDepth()
- Returns:
- the depth in the tree
getData
public Treeable getData()
- Returns:
- the Treeable data object this wraps
getParent
public TreeNode getParent()
- Returns:
- theis nodes parent, null if this is a root node
getUniqueName
public String getUniqueName()
- Returns:
- the name unique within the Tree
getChildren
public TreeNode[] getChildren()
- Returns:
- the descendants of this node, maybe an empty Array
getNodeToRootPath
public TreeNode[] getNodeToRootPath(boolean includeNode,
boolean reverse)
- Retrieve an Array of TreeNodes which is the shortest path from
this node to its root.
- Parameters:
includeNode
- whether to include this node in the pathreverse
- if true returns a path from root to this
- Returns:
- an Array of TreeNodes
getPathToRoot
public TreeNode[] getPathToRoot()
- Returns:
- the path to this node's root excluding this node
getPathFromRoot
public TreeNode[] getPathFromRoot()
- Returns:
- the path from this node's root excluding this node
augment
public static TreeNode[] augment(Treeable[] nodes,
int depth)
- Create a new Array of TreeNodes specifying a new depth.
- Parameters:
nodes
- the nodes to copydepth
- the new depth
- Returns:
- a new Array of TreeNodes with the new depth
Copyright © 2000-2010 PanEris. All Rights Reserved.