Plexus v0.13.1

com.phoenixst.plexus.examples
Class FileSystemForest

java.lang.Object
  extended by com.phoenixst.plexus.AbstractGraph
      extended by com.phoenixst.plexus.examples.FileSystemForest
All Implemented Interfaces:
Graph, OrientedForest

public class FileSystemForest
extends AbstractGraph
implements OrientedForest

A lazy forest graph of the local file system. The single instance of this class should be retrieved through the getInstance() method.

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.phoenixst.plexus.Graph
Graph.Edge
 
Method Summary
 Traverser childTraverser(Object node)
          Traverses over the children of the specified node.
 boolean containsEdge(Graph.Edge edge)
          This implementation traverses over the edges in this graph incident on the tail of the specified edge, looking for it and returning true if found.
 boolean containsNode(Object node)
          This implementation iterates over the nodes in this graph looking for the specified element.
 int degree(Object node)
          This implementation counts the number of elements accessed by this graph's traverser( node, null ) method, counting self-loops twice.
protected  Collection edges()
          Returns a Collection view of all the Graph.Edges in this Graph.
 int getDepth(Object node)
          Gets the depth of the specified node.
 int getHeight(Object node)
          Gets the height of the specified node.
static FileSystemForest getInstance()
           
 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(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.
protected  Collection nodes()
          Returns a Collection view of all the nodes in this Graph.
 boolean removeNode(Object node)
          This implementation iterates over the nodes in this graph looking for the specified element.
 Collection rootNodes()
          Returns the root nodes of this forest.
protected  Traverser traverser(Object node)
          Returns an unfiltered Traverser over those Graph.Edges incident to the specified node.
 
Methods inherited from class com.phoenixst.plexus.AbstractGraph
addEdge, addNode, adjacentNodes, degree, edges, getAdjacentNode, getEdge, getIncidentEdge, getNode, incidentEdges, nodes, removeEdge, traverser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final FileSystemForest getInstance()

nodes

protected Collection nodes()
Description copied from class: AbstractGraph
Returns a Collection view of all the nodes in this Graph. This method is only called by nodes( Predicate ).

Specified by:
nodes in class AbstractGraph

edges

protected Collection edges()
Description copied from class: AbstractGraph
Returns a Collection view of all the Graph.Edges in this Graph. This method is only called by edges( Predicate ).

Specified by:
edges in class AbstractGraph

traverser

protected Traverser traverser(Object node)
Description copied from class: AbstractGraph
Returns an unfiltered Traverser over those Graph.Edges incident to the specified node. This method is only called by traverser( node, Predicate ).

Specified by:
traverser in class AbstractGraph

degree

public int degree(Object node)
Description copied from class: AbstractGraph
This implementation counts the number of elements accessed by this graph's traverser( node, null ) method, counting self-loops twice.

Specified by:
degree in interface Graph
Overrides:
degree in class AbstractGraph
Parameters:
node - return the degree of this node.
Returns:
the degree of node.

containsNode

public boolean containsNode(Object node)
Description copied from class: AbstractGraph
This implementation iterates over the nodes in this graph looking for the specified element.

Specified by:
containsNode in interface Graph
Overrides:
containsNode in class AbstractGraph
Parameters:
node - the node whose presence in this Graph is to be tested.
Returns:
true if this Graph contains the specified node.

removeNode

public boolean removeNode(Object node)
Description copied from class: AbstractGraph
This implementation iterates over the nodes in this graph looking for the specified element. If it finds the element, it removes the element using using the Iterator.remove() operation.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this graph's nodes( null ).iterator() method does not implement the remove method and this graph contains the specified node.

Specified by:
removeNode in interface Graph
Overrides:
removeNode in class AbstractGraph
Parameters:
node - the node to be removed from this Graph.
Returns:
true if this Graph contained node.

containsEdge

public boolean containsEdge(Graph.Edge edge)
Description copied from class: AbstractGraph
This implementation traverses over the edges in this graph incident on the tail of the specified edge, looking for it and returning true if found.

Specified by:
containsEdge in interface Graph
Overrides:
containsEdge in class AbstractGraph
Parameters:
edge - the Graph.Edge whose presence in this Graph is to be tested.
Returns:
true if this Graph contains the specified Graph.Edge.

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

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.