org.parboiled.trees
Class MutableTreeNodeImpl<T extends MutableTreeNode<T>>

java.lang.Object
  extended by org.parboiled.trees.MutableTreeNodeImpl<T>
Type Parameters:
T - the actual implementation type of this MutableTreeNodeImpl
All Implemented Interfaces:
GraphNode<T>, MutableTreeNode<T>, TreeNode<T>
Direct Known Subclasses:
MutableBinaryTreeNodeImpl

public class MutableTreeNodeImpl<T extends MutableTreeNode<T>>
extends java.lang.Object
implements MutableTreeNode<T>

A base implementation of the MutableTreeNode.


Constructor Summary
MutableTreeNodeImpl()
           
 
Method Summary
 void addChild(int index, T child)
          Adds the given child to this nodes children list and setting the childs parent field to this node.
 java.util.List<T> getChildren()
          Returns the sub nodes of this node.
 T getParent()
          Returns the parent node or null if this node is the root.
 T removeChild(int index)
          Removes the child with the given index.
 void setChild(int index, T child)
          Sets the child node at the given index to the given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableTreeNodeImpl

public MutableTreeNodeImpl()
Method Detail

getParent

public T getParent()
Description copied from interface: TreeNode
Returns the parent node or null if this node is the root.

Specified by:
getParent in interface TreeNode<T extends MutableTreeNode<T>>
Returns:
the parent node

getChildren

public java.util.List<T> getChildren()
Description copied from interface: GraphNode
Returns the sub nodes of this node.

Specified by:
getChildren in interface GraphNode<T extends MutableTreeNode<T>>
Returns:
the sub nodes

addChild

public void addChild(int index,
                     T child)
Description copied from interface: MutableTreeNode
Adds the given child to this nodes children list and setting the childs parent field to this node. If the child is currently attached to another node it is first removed.

Specified by:
addChild in interface MutableTreeNode<T extends MutableTreeNode<T>>
Parameters:
index - the index under which to insert this child into the children list
child - the child node to add

setChild

public void setChild(int index,
                     T child)
Description copied from interface: MutableTreeNode
Sets the child node at the given index to the given node. The node previously existing at the given child index is first properly removed by setting its parent field to null. If the child is currently attached to another node it is first removed from its old parent.

Specified by:
setChild in interface MutableTreeNode<T extends MutableTreeNode<T>>
Parameters:
index - the index under which to set this child into the children list
child - the child node to set

removeChild

public T removeChild(int index)
Description copied from interface: MutableTreeNode
Removes the child with the given index.

Specified by:
removeChild in interface MutableTreeNode<T extends MutableTreeNode<T>>
Parameters:
index - the index of the child to remove.
Returns:
the removed child