org.progeeks.graph
Class UnexcludedGraphCoordinator

java.lang.Object
  extended by org.progeeks.graph.CompositeGraph.GraphCoordinator
      extended by org.progeeks.graph.UnexcludedGraphCoordinator

public class UnexcludedGraphCoordinator
extends CompositeGraph.GraphCoordinator

CompositeGraph.GraphCoordinator specialization that automatically unwraps AndPredicates that contain an ExcludesFilter... and if an ExludesFilter is passed directly then it is not passed on to the client. Any results returned are wrapped in the appropriate filtering collection or traverser. This provides a standard way for graphs to ignore these predicates and concentrate on optimizing the lower level calls.

Version:
$Revision: 1.3 $
Author:
Paul Speed

Constructor Summary
UnexcludedGraphCoordinator()
           
UnexcludedGraphCoordinator(java.lang.String name)
           
 
Method Summary
 java.util.Collection edges(org.apache.commons.collections.Predicate edgePredicate, com.phoenixst.plexus.Graph graph)
          Returns the set of edges from the subgraph that match the specified filter.
 com.phoenixst.plexus.Graph.Edge getEdge(org.apache.commons.collections.Predicate edgePredicate, com.phoenixst.plexus.Graph graph)
          Returns an edge from the specified graph that matches the specified filter.
 java.lang.Object getNode(org.apache.commons.collections.Predicate nodePredicate, com.phoenixst.plexus.Graph graph)
          Returns a node from the graph that matches the specified filter.
 java.util.Collection nodes(org.apache.commons.collections.Predicate nodePredicate, com.phoenixst.plexus.Graph graph)
          Returns the set of nodes from the subgraph that match the specified filter.
 void setName(java.lang.String name)
          Allows for XML configuration of the name.
 com.phoenixst.plexus.Traverser traverser(java.lang.Object node, org.apache.commons.collections.Predicate traverserPredicate, com.phoenixst.plexus.Graph graph)
          Returns a traverser for the specified node that is filtered by the specified predicate.
protected  org.apache.commons.collections.Predicate[] unwrapPredicate(org.apache.commons.collections.Predicate p)
          Unwraps the predicate if possible and returns the unwrapped version and the separated excludes filter in an array.
 
Methods inherited from class org.progeeks.graph.CompositeGraph.GraphCoordinator
acceptsConnectedNode, acceptsEdge, acceptsNode, containsEdge, containsNode, getIncidentEdge, getName, hasPotentialEdges, hasPotentialNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnexcludedGraphCoordinator

public UnexcludedGraphCoordinator()

UnexcludedGraphCoordinator

public UnexcludedGraphCoordinator(java.lang.String name)
Method Detail

setName

public void setName(java.lang.String name)
Allows for XML configuration of the name.

Overrides:
setName in class CompositeGraph.GraphCoordinator

unwrapPredicate

protected org.apache.commons.collections.Predicate[] unwrapPredicate(org.apache.commons.collections.Predicate p)
Unwraps the predicate if possible and returns the unwrapped version and the separated excludes filter in an array. Index 0 will be the predicate that can be passed down to the lower level calls. Index 1 will be the predicate that can be used when filtering the collection/iterator result. Either of these values can be null depending on the predicate passed. Index 0 will be null if the passed predicate is an exclude predicate. Index 1 will be null if no unwrapping has occured.


nodes

public java.util.Collection nodes(org.apache.commons.collections.Predicate nodePredicate,
                                  com.phoenixst.plexus.Graph graph)
Returns the set of nodes from the subgraph that match the specified filter. The coordinator may transform the filter as appropriate for its contained graph. The default implementation checks hasPotentialNodes() and if it returns true just calls the graph's nodes() method directly. Otherwise it returns null.

Overrides:
nodes in class CompositeGraph.GraphCoordinator

getNode

public java.lang.Object getNode(org.apache.commons.collections.Predicate nodePredicate,
                                com.phoenixst.plexus.Graph graph)
Returns a node from the graph that matches the specified filter. The default implementation checks hasPotentialNodes() and if it returns truee just calls the graph's getNode() method directly. Otherwise it returns null.

Overrides:
getNode in class CompositeGraph.GraphCoordinator

edges

public java.util.Collection edges(org.apache.commons.collections.Predicate edgePredicate,
                                  com.phoenixst.plexus.Graph graph)
Returns the set of edges from the subgraph that match the specified filter. The coordinator may transform the filter as appropriate for its contained graph. The default implementation checks hasPotentialEdges() and if it returns true just calls the graph's edges() method directly. Otherwise it returns null.

Overrides:
edges in class CompositeGraph.GraphCoordinator

getEdge

public com.phoenixst.plexus.Graph.Edge getEdge(org.apache.commons.collections.Predicate edgePredicate,
                                               com.phoenixst.plexus.Graph graph)
Returns an edge from the specified graph that matches the specified filter. The default implementation checks hasPotentialEdges() and if it return true, just calls the graph's getEdge() method directly. Otherwise it returns null.

Overrides:
getEdge in class CompositeGraph.GraphCoordinator

traverser

public com.phoenixst.plexus.Traverser traverser(java.lang.Object node,
                                                org.apache.commons.collections.Predicate traverserPredicate,
                                                com.phoenixst.plexus.Graph graph)
Returns a traverser for the specified node that is filtered by the specified predicate. The default implementation calls containsNode() and returns null if the node isn't in the graph. Otherwise, the subgraph's traverser() method is called directly.

Overrides:
traverser in class CompositeGraph.GraphCoordinator


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