|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.vizzini.util.tree.AbstractTreeNode
public abstract class AbstractTreeNode
Provides base functionality for a tree node.
| Constructor Summary | |
|---|---|
AbstractTreeNode()
Construct this object. |
|
AbstractTreeNode(Object userObject)
Construct this object with the given parameter. |
|
AbstractTreeNode(Object userObject,
boolean isChildAllowed)
Construct this object with the given parameter. |
|
| Method Summary | |
|---|---|
void |
acceptBreadthFirst(IVisitor visitor)
Accept the given visitor in a breadth first manner. |
void |
acceptDepthFirst(IVisitor visitor)
Accept the given visitor in a depth first manner. |
void |
add(ITreeNode treeNode)
Removes newChild from its parent and makes it a child of this node by adding it to the end of this node's child array. |
Iterator |
breadthFirstIterator()
Creates and returns an enumeration that traverses the subtree rooted at this node in breadth-first order. |
Iterator |
children()
Creates and returns a forward-order iterator of this node's children. |
Object |
clone()
Return a clone of this instance. |
protected ITreeNodeCollection |
createTreeNodeCollection()
Create a new tree node collection of the appropriate type. |
Iterator |
depthFirstIterator()
Creates and returns an enumeration that traverses the subtree rooted at this node in depth-first order. |
protected String |
dotDesc()
Return a dot description of this node. |
protected String |
dotLabel()
Return a dot label of this node. |
protected String |
dotLinkDesc()
Return a dot description of this node. |
boolean |
equals(Object object)
Return true if the given object is equal to this. |
protected ITreeNodeCollection |
fillCollectionBreadthFirst(ITreeNodeCollection list)
Fill the given collection with nodes in a breadth first manner. |
protected ITreeNodeCollection |
fillCollectionChildren(ITreeNodeCollection list)
Fill the given collection with the children of this. |
protected ITreeNodeCollection |
fillCollectionDepthFirst(ITreeNodeCollection list)
Fill the given collection with nodes in a depth first manner. |
ITreeNodeCollection |
getBreadthFirstList()
Creates and returns a list containing the subtree rooted at this node in breadth-first order. |
ITreeNode |
getChildAt(int index)
Returns the child at the specified index in this node's child array. |
int |
getChildCount()
Returns the number of children of this node. |
ITreeNodeCollection |
getChildren()
Return the tree node collection of children. |
int |
getDepth()
Returns the depth of the tree rooted at this node -- the longest distance from this node to a leaf. |
ITreeNodeCollection |
getDepthFirstList()
Creates and returns a list containing the subtree rooted at this node in depth-first order. |
ITreeNode |
getFirstChild()
Returns this node's first child. |
ITreeNode |
getFirstLeaf()
Finds and returns the first leaf that is a descendant of this node -- either this node or its first child's first leaf. |
int |
getIndex(ITreeNode treeNode)
Returns the index of the specified child in this node's child array. |
ITreeNode |
getLastChild()
Returns this node's last child. |
ITreeNode |
getLastLeaf()
Finds and returns the last leaf that is a descendant of this node -- either this node or its last child's last leaf. |
int |
getLevel()
Returns the number of levels above this node -- the distance from the root to this node. |
ITreeNode |
getNextSibling()
Return the sibling after this. |
int |
getNodeCount()
Return the count of all nodes in the subtree rooted at this node. |
ITreeNode |
getParent()
Returns this node's parent or null if this node has no parent. |
ITreeNode[] |
getPath()
Returns the path from the root, to get to this node. |
ITreeNode |
getRoot()
Returns the root of the tree that contains this node. |
static Class |
getTreeNodeCollectionClass()
|
Object |
getUserObject()
Returns this node's user object. |
int |
hashCode()
Returns a hash code value for the object. |
void |
insert(ITreeNode treeNode,
int index)
Removes treeNode from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index childIndex. |
boolean |
isChildAllowed()
Returns true if this node is allowed to have children. |
boolean |
isLeaf()
Returns true if this node has no children. |
boolean |
isRoot()
Returns true if this node is the root of the tree. |
void |
remove(int index)
Removes the child at the specified index from this node's children and sets that node's parent to null. |
void |
remove(ITreeNode treeNode)
Removes treeNode from this node's child array, giving it a null parent. |
void |
removeAllChildren()
Removes all of this node's children, setting their parents to null. |
void |
removeFromParent()
Removes the subtree rooted at this node from the tree, giving this node a null parent. |
void |
setChildAllowed(boolean isChildAllowed)
Determines whether or not this node is allowed to have children. |
void |
setChildren(ITreeNodeCollection children)
|
void |
setParent(ITreeNode parent)
Sets this node's parent to parent but does not change the
parent's child array. |
static void |
setTreeNodeCollectionClass(Class treeNodeCollectionClass)
|
void |
setUserObject(Object userObject)
Sets the user object for this node to userObject. |
String |
toString()
Return a string representation of this object. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractTreeNode()
public AbstractTreeNode(Object userObject)
userObject - User object.
public AbstractTreeNode(Object userObject,
boolean isChildAllowed)
userObject - User object.isChildAllowed - Flag indicating whether children are allowed.| Method Detail |
|---|
public static Class getTreeNodeCollectionClass()
public static void setTreeNodeCollectionClass(Class treeNodeCollectionClass)
treeNodeCollectionClass - the treeNodeCollectionClass to setpublic void acceptBreadthFirst(IVisitor visitor)
acceptBreadthFirst in interface IVisitablevisitor - Visitor.public void acceptDepthFirst(IVisitor visitor)
acceptDepthFirst in interface IVisitablevisitor - Visitor.public void add(ITreeNode treeNode)
add in interface ITreeNodepublic Iterator breadthFirstIterator()
breadthFirstIterator in interface ITreeNodepublic Iterator children()
children in interface ITreeNodepublic Object clone()
clone in interface ITreeNodeclone in class Objectpublic Iterator depthFirstIterator()
depthFirstIterator in interface ITreeNodepublic boolean equals(Object object)
equals in class Objectobject - The object to compare.public ITreeNodeCollection getBreadthFirstList()
getBreadthFirstList in interface ITreeNodepublic ITreeNode getChildAt(int index)
getChildAt in interface ITreeNodepublic int getChildCount()
getChildCount in interface ITreeNodepublic ITreeNodeCollection getChildren()
public int getDepth()
getDepth in interface ITreeNodepublic ITreeNodeCollection getDepthFirstList()
getDepthFirstList in interface ITreeNodepublic ITreeNode getFirstChild()
getFirstChild in interface ITreeNodepublic ITreeNode getFirstLeaf()
getFirstLeaf in interface ITreeNodepublic int getIndex(ITreeNode treeNode)
getIndex in interface ITreeNodepublic ITreeNode getLastChild()
getLastChild in interface ITreeNodepublic ITreeNode getLastLeaf()
getLastLeaf in interface ITreeNodepublic int getLevel()
getLevel in interface ITreeNodepublic ITreeNode getNextSibling()
getNextSibling in interface ITreeNodepublic int getNodeCount()
getNodeCount in interface ITreeNodepublic ITreeNode getParent()
getParent in interface ITreeNodepublic ITreeNode[] getPath()
getPath in interface ITreeNodepublic ITreeNode getRoot()
getRoot in interface ITreeNodepublic Object getUserObject()
ITreeNode
getUserObject in interface ITreeNodepublic int hashCode()
hashCode in class Object
public void insert(ITreeNode treeNode,
int index)
insert in interface ITreeNodepublic boolean isChildAllowed()
isChildAllowed in interface ITreeNodepublic boolean isLeaf()
isLeaf in interface ITreeNodepublic boolean isRoot()
isRoot in interface ITreeNodepublic void remove(int index)
remove in interface ITreeNodepublic void remove(ITreeNode treeNode)
remove in interface ITreeNodepublic void removeAllChildren()
removeAllChildren in interface ITreeNodepublic void removeFromParent()
removeFromParent in interface ITreeNodepublic void setChildAllowed(boolean isChildAllowed)
setChildAllowed in interface ITreeNodepublic void setChildren(ITreeNodeCollection children)
children - the children to setpublic void setParent(ITreeNode parent)
parent but does not change the
parent's child array.
setParent in interface ITreeNodepublic void setUserObject(Object userObject)
ITreeNode
setUserObject in interface ITreeNodeuserObject - the userObject to setpublic String toString()
toString in interface ITreeNodetoString in class Objectprotected ITreeNodeCollection createTreeNodeCollection()
protected String dotDesc()
protected String dotLabel()
protected String dotLinkDesc()
protected ITreeNodeCollection fillCollectionBreadthFirst(ITreeNodeCollection list)
list - Collection to fill.protected ITreeNodeCollection fillCollectionChildren(ITreeNodeCollection list)
list - Collection to fill.protected ITreeNodeCollection fillCollectionDepthFirst(ITreeNodeCollection list)
list - Collection to fill.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
| Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |