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

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBTree
Direct Known Subclasses:
DirectoryTree

public class MTBTree
extends java.lang.Object

This class implements a simple tree data structure.

The main component of a tree is its root node. It can have an unrestricted number of children. The tree structure is implicitly given by the recursive (one-way) linkage of nodes to their children. Each node of the tree is associated with a certain data object. Each data object has to be derived from class 'TreeNodeData' to enable one of the basic features of this tree - the recursive printing of data contained within the tree.

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

Field Summary
protected  MTBTreeNode root
          Root node of the tree.
 
Constructor Summary
MTBTree(MTBTreeNode rootNode)
          Constructor for the tree for a given root node.
MTBTree(MTBTreeNodeData rootObject)
          Constructor for the tree.
 
Method Summary
 MTBTreeNode getRoot()
          Access the root node.
 void printTree()
          Prints tree data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected MTBTreeNode root
Root node of the tree.

Constructor Detail

MTBTree

public MTBTree(MTBTreeNode rootNode)
Constructor for the tree for a given root node.

Parameters:
rootNode - the root node

MTBTree

public MTBTree(MTBTreeNodeData rootObject)
Constructor for the tree.

An associated data object has to be provided in any case.

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

getRoot

public MTBTreeNode getRoot()
Access the root node.

Returns:
Reference to the root node of the tree.

printTree

public void printTree()
Prints tree data.

Special feature of this tree: this function prints recursively the data contained inside the tree. Prerequisite for this is that the data objects of each node provide a method for printing their data in a reasonable way, i.e. implement the method printData() of the abstract class TreeNodeData.