classpathhelper.util
Class AbstractTree

java.lang.Object
  extended byclasspathhelper.util.AbstractTree
All Implemented Interfaces:
ITree
Direct Known Subclasses:
AbstractTreeRoot, ClassElement, ClassElement, ClassElement, ClassPathElement, ClassPathElement, ClassPathElement, ContentElement, ContentElement, ContentElement, PackageElement, PackageElement, PackageElement, SimpleTreeNode

public abstract class AbstractTree
extends java.lang.Object
implements ITree

Abstract base class for a tree node. This class provides basic tree structure related methods for maintaining children and parents.

Usage

This class is intended to be subclassed to provide a specific functionality. The helper methods for children automatically handle dispatching notifications.

Since:
1.0
Author:
bharris

Constructor Summary
AbstractTree()
           
 
Method Summary
 void addChild(ITree node)
          Adds a new node as a child to this tree node.
 void addChildren(ITree[] nodes)
          Adds a new array of children to this tree node.
 ITree[] getChildren()
          Getter for this nodes children.
 ITree getParent()
          Getter for the parent of this node.
protected  ITreeRoot getRoot()
          Returns the root of this tree.
 boolean hasChildren()
          Does this node have children.
 void removeAllChildren()
          Method to remove all children from this node.
 void removeChild(ITree node)
          Method for removing a child node.
 void setParent(ITree theParent)
          Method for setting the parent of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface classpathhelper.util.ITree
getIconName
 

Constructor Detail

AbstractTree

public AbstractTree()
Since:
1.0
Method Detail

addChild

public void addChild(ITree node)
Adds a new node as a child to this tree node. This method will dispatch a Tree Structure change event.

Parameters:
node - The child node to add.
Since:
1.0

addChildren

public void addChildren(ITree[] nodes)
Adds a new array of children to this tree node. This method will dispatch a Tree Structure change event.

Parameters:
nodes - The children nodes to add.
Since:
1.0

removeChild

public void removeChild(ITree node)
Method for removing a child node. This mehtod will dispatch a tree structure change event.

Parameters:
node - The node to remove.
Since:
1.0

removeAllChildren

public void removeAllChildren()
Method to remove all children from this node. This method will fire a tree structure changed event.

Since:
1.0

setParent

public void setParent(ITree theParent)
Method for setting the parent of this node. This method is typically called by the parents addChild(ITree) method and doesn't need to be called directly.

Parameters:
theParent - The parent node.
Since:
1.0

getRoot

protected ITreeRoot getRoot()
Returns the root of this tree. If no root can be found then this node has not yet been added to a tree. sub trees can be constructed prior to adding to a tree.

Returns:
The root of the tree.
Since:
1.0

hasChildren

public boolean hasChildren()
Description copied from interface: ITree
Does this node have children.

Specified by:
hasChildren in interface ITree
Returns:
true if this node has children otherwise false

getChildren

public ITree[] getChildren()
Description copied from interface: ITree
Getter for this nodes children.

Specified by:
getChildren in interface ITree
Returns:
An array containing this nodes children.

getParent

public ITree getParent()
Description copied from interface: ITree
Getter for the parent of this node.

Specified by:
getParent in interface ITree
Returns:
The parent node or null if this nood is the root or if this node has not yet been added to a tree.