de.unihalle.informatik.MiToBo.core.datatypes
Class MTBTreeNode

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBTreeNode

public class MTBTreeNode
extends java.lang.Object

This class implements the nodes of class 'Tree'. The recursive structure of a tree is implicitly given by the list of children of each node that again are TreeNodes on their own.

Author:
Birgit Möller
See Also:
MTBTree, MTBTreeNodeData

Field Summary
protected  java.util.Vector<MTBTreeNode> childs
          List of nodes that are childs of the given node.
protected  MTBTreeNodeData dataObject
          Data object associated with the given node.
protected  MTBTreeNode parent
          Parent node
 
Constructor Summary
MTBTreeNode(MTBTreeNodeData object)
          Constructor for a TreeNode.
 
Method Summary
 void addChild(MTBTreeNode t)
          Add a new child to the node.
 java.util.Vector<MTBTreeNode> getChilds()
          Returns Vector with child nodes.
 MTBTreeNodeData getData()
          Returns a reference to the data associated with the node.
 MTBTreeNode getParent()
          Get the parent of this node.
 void printData()
          Recursively prints the data contained in the nodes of the tree.
 void removeChild(MTBTreeNode t)
          Remove child node.
 void setParent(MTBTreeNode t)
          Set the parent of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

childs

protected java.util.Vector<MTBTreeNode> childs
List of nodes that are childs of the given node.


dataObject

protected MTBTreeNodeData dataObject
Data object associated with the given node.


parent

protected MTBTreeNode parent
Parent node

Constructor Detail

MTBTreeNode

public MTBTreeNode(MTBTreeNodeData object)
Constructor for a TreeNode.

Parameters:
object - Data object associated with the node.
Method Detail

addChild

public void addChild(MTBTreeNode t)
Add a new child to the node.

Sets the parent reference of the child to this node.

Parameters:
t - Node to be added as child to this node.

getChilds

public java.util.Vector<MTBTreeNode> getChilds()
Returns Vector with child nodes.

Returns:
Vector of child nodes.

getData

public MTBTreeNodeData getData()
Returns a reference to the data associated with the node.

Returns:
Reference to the node's data object.

getParent

public MTBTreeNode getParent()
Get the parent of this node.

Returns:
Parent node.

printData

public void printData()
Recursively prints the data contained in the nodes of the tree.

The method requires all data objects to be derived from TreeNodeData and implement the function printData().


removeChild

public void removeChild(MTBTreeNode t)
Remove child node.

Parameters:
t - Node to be removed.

setParent

public void setParent(MTBTreeNode t)
Set the parent of this node.

Also adds this node to the children of the parent.

Parameters:
t - Parent node.