org.progeeks.graph
Class CompositeGraph.GraphCoordinator

java.lang.Object
  extended by org.progeeks.graph.CompositeGraph.GraphCoordinator
Direct Known Subclasses:
UnexcludedGraphCoordinator
Enclosing class:
CompositeGraph

public static class CompositeGraph.GraphCoordinator
extends java.lang.Object

A coordinator can be associated with a subgraph to provide information about the types of filters that will return results and the types of nodes and edges that the graph accepts.


Constructor Summary
CompositeGraph.GraphCoordinator()
           
CompositeGraph.GraphCoordinator(java.lang.String name)
          Creates a graph coordinator associated with the specified name for debugging/identification purposes.
 
Method Summary
 boolean acceptsConnectedNode(java.lang.Object node, com.phoenixst.plexus.Graph graph)
          Returns true if the specified node can be added to the associated graph as a promotion.
 boolean acceptsEdge(java.lang.Object edge, java.lang.Object tail, java.lang.Object head, boolean directed, com.phoenixst.plexus.Graph graph)
          Returns true if the specified edge belongs to the associated graph.
 boolean acceptsNode(java.lang.Object node, com.phoenixst.plexus.Graph graph)
          Returns true if the specified node belongs to the associated graph.
 boolean containsEdge(com.phoenixst.plexus.Graph.Edge edge, com.phoenixst.plexus.Graph graph)
          Returns true if the associated graph contains the specified edge.
 boolean containsNode(java.lang.Object node, com.phoenixst.plexus.Graph graph)
          Returns true if the associated graph contains the specified node.
 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.
 com.phoenixst.plexus.Graph.Edge getIncidentEdge(java.lang.Object node, org.apache.commons.collections.Predicate traverserPredicate, com.phoenixst.plexus.Graph graph)
          Returns an incident edge for the specified node that matches the specified predicate.
 java.lang.String getName()
          Returns the name associated with this coordinator.
 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.
 boolean hasPotentialEdges(org.apache.commons.collections.Predicate edgePredicate)
          Returns true if the associated graph may return edges for the specified filter.
 boolean hasPotentialNodes(org.apache.commons.collections.Predicate nodePredicate)
          Returns true if the associated graph may return nodes for 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.
protected  void setName(java.lang.String name)
          Sets the name of the coordinator... useable by subclasses.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeGraph.GraphCoordinator

public CompositeGraph.GraphCoordinator()

CompositeGraph.GraphCoordinator

public CompositeGraph.GraphCoordinator(java.lang.String name)
Creates a graph coordinator associated with the specified name for debugging/identification purposes.

Method Detail

setName

protected void setName(java.lang.String name)
Sets the name of the coordinator... useable by subclasses.


getName

public java.lang.String getName()
Returns the name associated with this coordinator.


acceptsNode

public boolean acceptsNode(java.lang.Object node,
                           com.phoenixst.plexus.Graph graph)
Returns true if the specified node belongs to the associated graph. Default returns true.


acceptsConnectedNode

public boolean acceptsConnectedNode(java.lang.Object node,
                                    com.phoenixst.plexus.Graph graph)
Returns true if the specified node can be added to the associated graph as a promotion. This means that the node will be subsequently connected to another node in the associated graph. This policy may be slightly more lenient than the acceptsNode() policy. Since nodes must be added to a graph before the connecting edge can be added, this method allows the node to slip through when it would otherwise be rejected. The default implementation calls acceptsNode().


acceptsEdge

public boolean acceptsEdge(java.lang.Object edge,
                           java.lang.Object tail,
                           java.lang.Object head,
                           boolean directed,
                           com.phoenixst.plexus.Graph graph)
Returns true if the specified edge belongs to the associated graph. Default returns true.


containsNode

public boolean containsNode(java.lang.Object node,
                            com.phoenixst.plexus.Graph graph)
Returns true if the associated graph contains the specified node. Coordinators can override this method to trivially reject certain nodes if they know that the graph will never contain them. Some graph.containsNode() calls can be expensive. Default returns graph.containsNode().


hasPotentialNodes

public boolean hasPotentialNodes(org.apache.commons.collections.Predicate nodePredicate)
Returns true if the associated graph may return nodes for the specified filter. Returns false if the associated graph will never return nodes for the specified filter. Defaults to returning true.


containsEdge

public boolean containsEdge(com.phoenixst.plexus.Graph.Edge edge,
                            com.phoenixst.plexus.Graph graph)
Returns true if the associated graph contains the specified edge. Coordinators can override this method to trivially reject certain edges if they know that the graph will never contain them. Some graph.containsEdge() calls can be expensive. Default returns graph.containsEdge().


hasPotentialEdges

public boolean hasPotentialEdges(org.apache.commons.collections.Predicate edgePredicate)
Returns true if the associated graph may return edges for the specified filter. Returns false if the associated graph will never return edges for the specified filter. Defaults to returning true.


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.


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.


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.


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.


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.


getIncidentEdge

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



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