Plexus v0.13.1

com.phoenixst.plexus
Class ForestTreeAdapter

java.lang.Object
  extended by com.phoenixst.plexus.ForestTreeAdapter
All Implemented Interfaces:
OrientedForest, Rooted, RootedTree

public class ForestTreeAdapter
extends Object
implements RootedTree

An adapter which presents the subgraph of an OrientedForest rooted at a specified node as a RootedTree.

Since:
1.0
Version:
$Revision: 1.9 $
Author:
Ray A. Conner

Constructor Summary
ForestTreeAdapter(Object root, OrientedForest forest, boolean isStrict)
          Creates a new ForestTreeAdapter.
 
Method Summary
 Traverser childTraverser(Object node)
          Traverses over the children of the specified node.
 int getDepth(Object node)
          Gets the depth of the specified node.
 int getHeight(Object node)
          Gets the height of the specified node.
 Object getLeastCommonAncestor(Object aNode, Object bNode)
          Returns the least common ancestor of the specified nodes, or null if none exists.
 Object getParent(Object node)
          Gets the parent of the specified node, or null if it doesn't have one.
 Graph.Edge getParentEdge(Object node)
          Gets the parent Edge of the specified node, or null if it doesn't have one.
 Object getParentEndpoint(Graph.Edge edge)
          Returns the parent endpoint of the specified forest Edge.
 Object getRoot()
          Gets the root node.
 Object getRoot(Object node)
          Gets the root of the subgraph containing the specified node.
 boolean isAncestor(Object ancestor, Object descendant)
          Returns true if ancestor is actually an ancestor of descendant.
 boolean isForestEdge(Graph.Edge edge)
          Gets whether or not the specified Edge is a forest edge.
 boolean isLeaf(Object node)
          Returns true if the specified node has no children.
 boolean isTreeNode(Object node)
          Returns true if the specified node is a descendant of the root node.
 Collection rootNodes()
          Returns the root nodes of this forest.
 void setRoot(Object root)
          Sets the root node, which must already be present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForestTreeAdapter

public ForestTreeAdapter(Object root,
                         OrientedForest forest,
                         boolean isStrict)
Creates a new ForestTreeAdapter.

Parameters:
root - create a tree of the subgraph rooted at this node.
forest - the forest of which this tree is a subview.
isStrict - if true, all appropriate methods accepting nodes will throw a NoSuchNodeException if the argument node is not a descendant of the root node of this tree. If false, only getRoot( node ) and getDepth( node ) will throw an exception in this case.
Method Detail

getRoot

public Object getRoot()
Description copied from interface: Rooted
Gets the root node.

Specified by:
getRoot in interface Rooted

setRoot

public void setRoot(Object root)
Description copied from interface: Rooted
Sets the root node, which must already be present.

Specified by:
setRoot in interface Rooted

getParent

public Object getParent(Object node)
Description copied from interface: OrientedForest
Gets the parent of the specified node, or null if it doesn't have one. If null is a valid node, then OrientedForest.getParentEdge(java.lang.Object) must be used to distinguish the two cases.

Specified by:
getParent in interface OrientedForest

childTraverser

public Traverser childTraverser(Object node)
Description copied from interface: OrientedForest
Traverses over the children of the specified node.

Specified by:
childTraverser in interface OrientedForest

getParentEdge

public Graph.Edge getParentEdge(Object node)
Description copied from interface: OrientedForest
Gets the parent Edge of the specified node, or null if it doesn't have one.

Specified by:
getParentEdge in interface OrientedForest

isForestEdge

public boolean isForestEdge(Graph.Edge edge)
Description copied from interface: OrientedForest
Gets whether or not the specified Edge is a forest edge.

Specified by:
isForestEdge in interface OrientedForest

getParentEndpoint

public Object getParentEndpoint(Graph.Edge edge)
Description copied from interface: OrientedForest
Returns the parent endpoint of the specified forest Edge. If the specified Edge is not a forest edge, throws an IllegalArgumentException.

Specified by:
getParentEndpoint in interface OrientedForest

rootNodes

public Collection rootNodes()
Description copied from interface: OrientedForest
Returns the root nodes of this forest.

Specified by:
rootNodes in interface OrientedForest

getRoot

public Object getRoot(Object node)
Description copied from interface: OrientedForest
Gets the root of the subgraph containing the specified node.

Specified by:
getRoot in interface OrientedForest

isLeaf

public boolean isLeaf(Object node)
Description copied from interface: OrientedForest
Returns true if the specified node has no children.

Specified by:
isLeaf in interface OrientedForest

isAncestor

public boolean isAncestor(Object ancestor,
                          Object descendant)
Description copied from interface: OrientedForest
Returns true if ancestor is actually an ancestor of descendant.

Specified by:
isAncestor in interface OrientedForest

getLeastCommonAncestor

public Object getLeastCommonAncestor(Object aNode,
                                     Object bNode)
Description copied from interface: OrientedForest
Returns the least common ancestor of the specified nodes, or null if none exists. If null is a valid node, then some other method must be used to distinguish the two cases.

Specified by:
getLeastCommonAncestor in interface OrientedForest

getDepth

public int getDepth(Object node)
Description copied from interface: OrientedForest
Gets the depth of the specified node.

Specified by:
getDepth in interface OrientedForest

getHeight

public int getHeight(Object node)
Description copied from interface: OrientedForest
Gets the height of the specified node.

Specified by:
getHeight in interface OrientedForest

isTreeNode

public boolean isTreeNode(Object node)
Description copied from interface: RootedTree
Returns true if the specified node is a descendant of the root node.

Specified by:
isTreeNode in interface RootedTree

Plexus v0.13.1

See the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.