public class TreeNode extends Object
Constructor and Description |
---|
TreeNode()
Create a new node.
|
TreeNode(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.
|
List |
getChildren()
Return the children of node.
|
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(List children)
Sets the children of a Node object.
|
void |
setData(Object data)
Set the node data.
|
String |
toString()
Get the string representation.
|
public List children
public TreeNode()
public TreeNode(Object data)
public List getChildren()
public void setChildren(List children)
children
- The list to set.public int getNumberOfChildren()
public void addChild(TreeNode child)
child
- a Nodepublic void insertChildAt(int index, TreeNode child) throws IndexOutOfBoundsException
index
- the position to insert at.child
- the NodeIndexOutOfBoundsException
- if thrown.public void removeChildAt(int index) throws IndexOutOfBoundsException
index
- the index of the element to delete.IndexOutOfBoundsException
- if thrown.public Object getData()
public void setData(Object data)
data
- The node data.Copyright © 2013. All Rights Reserved.