|
||||||||||
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 IVisitable
visitor
- Visitor.public void acceptDepthFirst(IVisitor visitor)
acceptDepthFirst
in interface IVisitable
visitor
- Visitor.public void add(ITreeNode treeNode)
add
in interface ITreeNode
public Iterator breadthFirstIterator()
breadthFirstIterator
in interface ITreeNode
public Iterator children()
children
in interface ITreeNode
public Object clone()
clone
in interface ITreeNode
clone
in class Object
public Iterator depthFirstIterator()
depthFirstIterator
in interface ITreeNode
public boolean equals(Object object)
equals
in class Object
object
- The object to compare.public ITreeNodeCollection getBreadthFirstList()
getBreadthFirstList
in interface ITreeNode
public ITreeNode getChildAt(int index)
getChildAt
in interface ITreeNode
public int getChildCount()
getChildCount
in interface ITreeNode
public ITreeNodeCollection getChildren()
public int getDepth()
getDepth
in interface ITreeNode
public ITreeNodeCollection getDepthFirstList()
getDepthFirstList
in interface ITreeNode
public ITreeNode getFirstChild()
getFirstChild
in interface ITreeNode
public ITreeNode getFirstLeaf()
getFirstLeaf
in interface ITreeNode
public int getIndex(ITreeNode treeNode)
getIndex
in interface ITreeNode
public ITreeNode getLastChild()
getLastChild
in interface ITreeNode
public ITreeNode getLastLeaf()
getLastLeaf
in interface ITreeNode
public int getLevel()
getLevel
in interface ITreeNode
public ITreeNode getNextSibling()
getNextSibling
in interface ITreeNode
public int getNodeCount()
getNodeCount
in interface ITreeNode
public ITreeNode getParent()
getParent
in interface ITreeNode
public ITreeNode[] getPath()
getPath
in interface ITreeNode
public ITreeNode getRoot()
getRoot
in interface ITreeNode
public Object getUserObject()
ITreeNode
getUserObject
in interface ITreeNode
public int hashCode()
hashCode
in class Object
public void insert(ITreeNode treeNode, int index)
insert
in interface ITreeNode
public boolean isChildAllowed()
isChildAllowed
in interface ITreeNode
public boolean isLeaf()
isLeaf
in interface ITreeNode
public boolean isRoot()
isRoot
in interface ITreeNode
public void remove(int index)
remove
in interface ITreeNode
public void remove(ITreeNode treeNode)
remove
in interface ITreeNode
public void removeAllChildren()
removeAllChildren
in interface ITreeNode
public void removeFromParent()
removeFromParent
in interface ITreeNode
public void setChildAllowed(boolean isChildAllowed)
setChildAllowed
in interface ITreeNode
public 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 ITreeNode
public void setUserObject(Object userObject)
ITreeNode
setUserObject
in interface ITreeNode
userObject
- the userObject to setpublic String toString()
toString
in interface ITreeNode
toString
in class Object
protected 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 |