public class TreeNode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.util.List<TreeNode> |
children
The children.
|
protected java.lang.Object |
data
The user node data.
|
Constructor and Description |
---|
TreeNode()
Create a new node.
|
TreeNode(java.lang.Object data)
Create a new node.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(TreeNode child)
Adds a child to the list of children for this node.
|
java.util.List<TreeNode> |
getChildren()
Return the children of node.
|
java.lang.Object |
getData()
Get the node data.
|
int |
getNumberOfChildren()
Returns the number of immediate children of this node.
|
void |
insertChildAt(int index,
TreeNode child)
Inserts a node at the specified position in the child list.
|
void |
removeChildAt(int index)
Remove the Node |
void |
setChildren(java.util.List<TreeNode> children)
Sets the children of a Node object.
|
void |
setData(java.lang.Object data)
Set the node data.
|
java.lang.String |
toString()
Get the string representation.
|
protected java.lang.Object data
public java.util.List<TreeNode> children
public TreeNode()
public TreeNode(java.lang.Object data)
public java.util.List<TreeNode> getChildren()
public void setChildren(java.util.List<TreeNode> children)
children
- The list to set.public int getNumberOfChildren()
public void addChild(TreeNode child)
child
- a Nodepublic void insertChildAt(int index, TreeNode child) throws java.lang.IndexOutOfBoundsException
index
- the position to insert at.child
- the Nodejava.lang.IndexOutOfBoundsException
- if thrown.public void removeChildAt(int index) throws java.lang.IndexOutOfBoundsException
index
- the index of the element to delete.java.lang.IndexOutOfBoundsException
- if thrown.public java.lang.Object getData()
public void setData(java.lang.Object data)
data
- The node data.public java.lang.String toString()
toString
in class java.lang.Object