Package jadex.commons.collection
Class TreeNode
- java.lang.Object
-
- jadex.commons.collection.TreeNode
-
public class TreeNode extends java.lang.Object
Represents a node of a tree.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 element at index index of the List.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.
-
-
-
Field Detail
-
data
protected java.lang.Object data
The user node data.
-
children
public java.util.List<TreeNode> children
The children.
-
-
Method Detail
-
getChildren
public java.util.List<TreeNode> getChildren()
Return the children of node.- Returns:
- The children of node.
-
setChildren
public void setChildren(java.util.List<TreeNode> children)
Sets the children of a Node object.- Parameters:
children
- The list to set.
-
getNumberOfChildren
public int getNumberOfChildren()
Returns the number of immediate children of this node.- Returns:
- the number of immediate children.
-
addChild
public void addChild(TreeNode child)
Adds a child to the list of children for this node.- Parameters:
child
- a Node
-
insertChildAt
public void insertChildAt(int index, TreeNode child) throws java.lang.IndexOutOfBoundsException
Inserts a node at the specified position in the child list. Will throw an ArrayIndexOutOfBoundsException if the index does not exist.- Parameters:
index
- the position to insert at.child
- the Node object to insert.- Throws:
java.lang.IndexOutOfBoundsException
- if thrown.
-
removeChildAt
public void removeChildAt(int index) throws java.lang.IndexOutOfBoundsException
Remove the Node element at index index of the List.- Parameters:
index
- the index of the element to delete.- Throws:
java.lang.IndexOutOfBoundsException
- if thrown.
-
getData
public java.lang.Object getData()
Get the node data.- Returns:
- The node data.
-
setData
public void setData(java.lang.Object data)
Set the node data.- Parameters:
data
- The node data.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation.
-
-