Plexus v0.13.1

com.phoenixst.plexus
Class FilteredGraph

java.lang.Object
  extended by com.phoenixst.plexus.AbstractGraph
      extended by com.phoenixst.plexus.FilteredGraph
All Implemented Interfaces:
Graph, ObservableGraph

public class FilteredGraph
extends AbstractGraph
implements ObservableGraph

A filtered Graph implementation. Unlike other Graph wrappers and implementations, and in violation of the contract for Graph.Edge.equals(), the Edges produced by this Graph are not wrapped.

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.phoenixst.plexus.Graph
Graph.Edge
 
Constructor Summary
protected FilteredGraph()
          This constructor, together with initialize(Graph, Predicate, Predicate), allows a subclass to initialize the internal state during deserialization.
  FilteredGraph(Graph delegate, org.apache.commons.collections.Predicate nodePredicate, org.apache.commons.collections.Predicate edgePredicate)
          Creates a new FilteredGraph.
 
Method Summary
 Graph.Edge addEdge(Object object, Object tail, Object head, boolean isDirected)
          This implementation throws an UnsupportedOperationException.
 void addGraphListener(GraphListener listener)
          Adds the specified GraphListener which will be notified whenever this ObservableGraph's structure changes.
 boolean addNode(Object node)
          This implementation throws an UnsupportedOperationException.
 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.
protected  Collection edges()
          Returns a Collection view of all the Graph.Edges in this Graph.
protected  Graph getDelegate()
          Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.
protected  org.apache.commons.collections.Predicate getEdgePredicate()
          Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.
protected  org.apache.commons.collections.Predicate getNodePredicate()
          Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.
protected  void initialize(Graph delegateGraph, org.apache.commons.collections.Predicate nodePred, org.apache.commons.collections.Predicate edgePred)
          This method should only be called by subclasses during deserialization.
protected  Collection nodes()
          Returns a Collection view of all the nodes in this Graph.
 boolean removeEdge(Graph.Edge edge)
          This implementation traverses over the edges in this graph incident on the tail of the specified edge.
 void removeGraphListener(GraphListener listener)
          Removes a previously added GraphListener.
 boolean removeNode(Object node)
          This implementation iterates over the nodes in this graph looking for the specified element.
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
adjacentNodes, degree, degree, edges, getAdjacentNode, getEdge, getIncidentEdge, getNode, incidentEdges, nodes, traverser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.phoenixst.plexus.Graph
adjacentNodes, degree, degree, edges, getAdjacentNode, getEdge, getIncidentEdge, getNode, incidentEdges, nodes, traverser
 

Constructor Detail

FilteredGraph

public FilteredGraph(Graph delegate,
                     org.apache.commons.collections.Predicate nodePredicate,
                     org.apache.commons.collections.Predicate edgePredicate)
Creates a new FilteredGraph.


FilteredGraph

protected FilteredGraph()
This constructor, together with initialize(Graph, Predicate, Predicate), allows a subclass to initialize the internal state during deserialization.

Method Detail

initialize

protected final void initialize(Graph delegateGraph,
                                org.apache.commons.collections.Predicate nodePred,
                                org.apache.commons.collections.Predicate edgePred)
This method should only be called by subclasses during deserialization.


getDelegate

protected final Graph getDelegate()
Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.


getEdgePredicate

protected final org.apache.commons.collections.Predicate getEdgePredicate()
Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.


getNodePredicate

protected final org.apache.commons.collections.Predicate getNodePredicate()
Provides accesss to the internal state so it can be manually serialized by a subclass's writeObject() method.


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

addNode

public boolean addNode(Object node)
Description copied from class: AbstractGraph
This implementation throws an UnsupportedOperationException.

Specified by:
addNode in interface Graph
Overrides:
addNode in class AbstractGraph
Parameters:
node - the node to be added to this Graph.
Returns:
true if this Graph changed as a result of the call, false if this Graph already 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.

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.

addEdge

public Graph.Edge addEdge(Object object,
                          Object tail,
                          Object head,
                          boolean isDirected)
Description copied from class: AbstractGraph
This implementation throws an UnsupportedOperationException.

Specified by:
addEdge in interface Graph
Overrides:
addEdge in class AbstractGraph
Parameters:
object - the user-defined object to be contained in the new edge.
tail - the first endpoint of the new edge.
head - the second endpoint of the new edge.
isDirected - whether the new edge is directed.
Returns:
the newly created Graph.Edge if this Graph changed as a result of the call, null if this Graph does not allow duplicate edges and already contains the specified edge.

removeEdge

public boolean removeEdge(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. 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 traverser returned by this graph's traverser( node, predicate ) method does not implement the removeEdge method and this graph contains the specified edge.

Specified by:
removeEdge in interface Graph
Overrides:
removeEdge in class AbstractGraph
Parameters:
edge - the Graph.Edge to be removed from this Graph.
Returns:
true if this Graph contained the specified Graph.Edge.

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.

addGraphListener

public void addGraphListener(GraphListener listener)
Adds the specified GraphListener which will be notified whenever this ObservableGraph's structure changes. If the wrapped graph does not implement ObservableGraph, then this method with throw an UnsupportedOperationException.

Specified by:
addGraphListener in interface ObservableGraph

removeGraphListener

public void removeGraphListener(GraphListener listener)
Removes a previously added GraphListener. If the wrapped graph does not implement ObservableGraph, then this method with throw an UnsupportedOperationException.

Specified by:
removeGraphListener in interface ObservableGraph

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.