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

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

@ALDMetaInfo(export=ALLOWED)
public class MTBTreeNode
extends 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  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.
 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

dataObject

protected MTBTreeNodeData dataObject
Data object associated with the given node.


childs

protected Vector<MTBTreeNode> childs
List of nodes that are childs of 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

getData

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

Returns:
Reference to the node's data object.

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.

removeChild

public void removeChild(MTBTreeNode t)
Remove child node.

Parameters:
t - Node to be removed.

getChilds

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

Returns:
Vector of child nodes.

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.

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().



Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.