org.progeeks.graph
Class StandardOrientedForestView

java.lang.Object
  extended by com.phoenixst.plexus.AbstractOrientedForest
      extended by org.progeeks.graph.StandardOrientedForestView
All Implemented Interfaces:
com.phoenixst.plexus.GraphView, com.phoenixst.plexus.OrientedForest, java.io.Serializable

public class StandardOrientedForestView
extends com.phoenixst.plexus.AbstractOrientedForest
implements com.phoenixst.plexus.GraphView, java.io.Serializable

A default implementation of the OrientedForestView interface that supports some different operations than the standard Plexus DefaultOrientedForestView at the expense of a little correctness. First, we allow a filter to be specified for finding the root nodes which potentially eliminates having to do a whole graph search if the graph implementation is optimized for the filter. This may lead to inconsistent results since traversing up to a random node's root may return a root that is not in the returned root collection. This class will primarily be used for top down graph exploration though so this is likely never to happen and could be checked for in any case. Also, this version allows the filters to be changed at runtime.

Version:
$Revision: 1.3 $
Author:
Paul Speed
See Also:
Serialized Form

Constructor Summary
StandardOrientedForestView()
          Creates an empty oriented forest view.
StandardOrientedForestView(com.phoenixst.plexus.Graph view)
          Creates a flat oriented forest view of the specified graph.
StandardOrientedForestView(com.phoenixst.plexus.Graph view, org.apache.commons.collections.Predicate rootPredicate, org.apache.commons.collections.Predicate parentPredicate, org.apache.commons.collections.Predicate childPredicate)
          Creates an oriented forest view with the specified properties.
 
Method Summary
 com.phoenixst.plexus.Traverser childTraverser(java.lang.Object node)
           
 org.apache.commons.collections.Predicate getChildPredicate()
           
 com.phoenixst.plexus.Graph getGraph()
           
 java.lang.Object getParent(java.lang.Object node)
           
 com.phoenixst.plexus.Graph.Edge getParentEdge(java.lang.Object node)
           
 org.apache.commons.collections.Predicate getParentPredicate()
           
 org.apache.commons.collections.Predicate getRootPredicate()
           
 boolean isLeaf(java.lang.Object node)
           
 java.util.Collection rootNodes()
           
 void setChildPredicate(org.apache.commons.collections.Predicate childPredicate)
          Sets the predicate used to find the children of nodes.
 void setGraph(com.phoenixst.plexus.Graph graph)
          Sets the graph for which this view is a view.
 void setParentPredicate(org.apache.commons.collections.Predicate parentPredicate)
          Sets the predicate used to find the parents of nodes.
 void setRootPredicate(org.apache.commons.collections.Predicate rootPredicate)
          Sets the predicate used to locate the initial root set.
 
Methods inherited from class com.phoenixst.plexus.AbstractOrientedForest
getDepth, getHeight, getLeastCommonAncestor, getParentEndpoint, getRoot, isAncestor, isForestEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardOrientedForestView

public StandardOrientedForestView()
Creates an empty oriented forest view.


StandardOrientedForestView

public StandardOrientedForestView(com.phoenixst.plexus.Graph view)
Creates a flat oriented forest view of the specified graph. In other words, all nodes are roots.


StandardOrientedForestView

public StandardOrientedForestView(com.phoenixst.plexus.Graph view,
                                  org.apache.commons.collections.Predicate rootPredicate,
                                  org.apache.commons.collections.Predicate parentPredicate,
                                  org.apache.commons.collections.Predicate childPredicate)
Creates an oriented forest view with the specified properties.

Method Detail

setGraph

public void setGraph(com.phoenixst.plexus.Graph graph)
Sets the graph for which this view is a view.


getGraph

public com.phoenixst.plexus.Graph getGraph()
Specified by:
getGraph in interface com.phoenixst.plexus.GraphView

setRootPredicate

public void setRootPredicate(org.apache.commons.collections.Predicate rootPredicate)
Sets the predicate used to locate the initial root set.


getRootPredicate

public org.apache.commons.collections.Predicate getRootPredicate()

setParentPredicate

public void setParentPredicate(org.apache.commons.collections.Predicate parentPredicate)
Sets the predicate used to find the parents of nodes.


getParentPredicate

public org.apache.commons.collections.Predicate getParentPredicate()

setChildPredicate

public void setChildPredicate(org.apache.commons.collections.Predicate childPredicate)
Sets the predicate used to find the children of nodes.


getChildPredicate

public org.apache.commons.collections.Predicate getChildPredicate()

getParent

public java.lang.Object getParent(java.lang.Object node)
Specified by:
getParent in interface com.phoenixst.plexus.OrientedForest
Overrides:
getParent in class com.phoenixst.plexus.AbstractOrientedForest

getParentEdge

public com.phoenixst.plexus.Graph.Edge getParentEdge(java.lang.Object node)
Specified by:
getParentEdge in interface com.phoenixst.plexus.OrientedForest

childTraverser

public com.phoenixst.plexus.Traverser childTraverser(java.lang.Object node)
Specified by:
childTraverser in interface com.phoenixst.plexus.OrientedForest

rootNodes

public java.util.Collection rootNodes()
Specified by:
rootNodes in interface com.phoenixst.plexus.OrientedForest

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface com.phoenixst.plexus.OrientedForest
Overrides:
isLeaf in class com.phoenixst.plexus.AbstractOrientedForest


Copyright © 2002-2003 Paul Speed. All Rights Reserved.