public final class AOTreeNode
extends java.lang.Object
Constructor and Description |
---|
AOTreeNode(java.lang.Object userObject)
Creates a tree node with no parent, no children, but which allows
children, and initializes it with the specified user object.
|
Modifier and Type | Method and Description |
---|---|
void |
add(AOTreeNode newChild)
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. |
AOTreeNode |
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.
|
AOTreeNode |
getParent()
Returns this node's parent or null if this node has no parent.
|
java.lang.Object |
getUserObject()
Returns this node's user object.
|
boolean |
isLeaf()
Returns true if this node has no children.
|
void |
setParent(AOTreeNode newParent)
Sets this node's parent to
newParent but does not change the
parent's child array. |
java.lang.String |
toString()
Returns the result of sending
toString() to this node's user
object, or null if this node has no user object. |
public AOTreeNode(java.lang.Object userObject)
userObject
- an Object provided by the user that constitutes the node's
datapublic void setParent(AOTreeNode newParent)
newParent
but does not change the
parent's child array. This method is called from insert()
and remove()
to reassign a child's parent, it should not be
messaged from anywhere else.newParent
- this node's new parentpublic AOTreeNode getParent()
public AOTreeNode getChildAt(int index)
index
- an index into this node's child arrayjava.lang.ArrayIndexOutOfBoundsException
- if index
is out of boundspublic int getChildCount()
public java.lang.Object getUserObject()
public void add(AOTreeNode newChild)
newChild
from its parent and makes it a child of
this node by adding it to the end of this node's child array.newChild
- node to add as a child of this nodejava.lang.IllegalArgumentException
- if newChild
is nulljava.lang.IllegalStateException
- if this node does not allow childreninsert(es.gob.afirma.core.util.tree.AOTreeNode, int)
public boolean isLeaf()
getAllowsChildren
public java.lang.String toString()
toString()
to this node's user
object, or null if this node has no user object.toString
in class java.lang.Object
getUserObject()