Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.phoenixst.plexus
Class ObservableGraphWrapper  view ObservableGraphWrapper download ObservableGraphWrapper.java

java.lang.Object
  extended bycom.phoenixst.plexus.GraphWrapper
      extended bycom.phoenixst.plexus.ObservableGraphWrapper
All Implemented Interfaces:
Graph, ObservableGraph, java.io.Serializable

public class ObservableGraphWrapper
extends GraphWrapper
implements ObservableGraph

A wrapper around a Graph so that it can be watched for structural changes. Note: the Iterator.remove()>Iterator.remove() 55 method on Traversers created by this class will only work if the Traversers created by the wrapped Graph can tolerate having edges removed while the traversal is in progress.

Since:
1.0
Version:
$Revision: 1.18 $

Nested Class Summary
private  class ObservableGraphWrapper.ObservableEdgeIteratorWrapper
           
private  class ObservableGraphWrapper.ObservableNodeIteratorWrapper
           
private  class ObservableGraphWrapper.ObservableTraverserWrapper
           
 
Nested classes inherited from class com.phoenixst.plexus.GraphWrapper
GraphWrapper.EdgeIteratorWrapper, GraphWrapper.EdgeWrapper, GraphWrapper.NodeIteratorWrapper, GraphWrapper.TraverserWrapper
 
Nested classes inherited from class com.phoenixst.plexus.Graph
Graph.Edge
 
Field Summary
private  GraphListener[] listenerArray
           
private  java.util.List listeners
           
 
Fields inherited from class com.phoenixst.plexus.GraphWrapper
g
 
Constructor Summary
ObservableGraphWrapper(Graph g)
          Creates a new ObservableGraphWrapper.
 
Method Summary
 Graph.Edge addEdge(java.lang.Object object, java.lang.Object tail, java.lang.Object head)
          Adds the specified edge to the Graph (optional operation).
 void addGraphListener(GraphListener listener)
          Adds the specified GraphListener which will be notified whenever this ObservableGraph's structure changes.
 boolean addNode(java.lang.Object node)
          Adds node to this Graph (optional operation).
 void clear()
          Removes all nodes and edges from this Graph (optional operation).
protected  GraphListener[] createListenerArray()
           
protected  void fireEdgeAdded(Graph.Edge edge)
           
protected  void fireEdgeRemoved(Graph.Edge edge)
           
protected  void fireNodeAdded(java.lang.Object node)
           
protected  void fireNodeRemoved(java.lang.Object node)
           
 boolean removeEdge(Graph.Edge edge)
          Removes the specified Edge from this Graph (optional operation).
 void removeGraphListener(GraphListener listener)
          Removes a previously added GraphListener.
protected  void removeIncidentEdges(java.lang.Object node)
           
 boolean removeNode(java.lang.Object node)
          Removes node from this Graph (optional operation).
protected  java.util.Iterator wrapEdgeIterator(java.util.Iterator edgeIter)
          Returns a wrapped edge iterator.
protected  java.util.Iterator wrapNodeIterator(java.util.Iterator nodeIter)
          Returns a wrapped node iterator.
protected  Traverser wrapTraverser(Traverser traverser)
          Returns a wrapped traverser.
 
Methods inherited from class com.phoenixst.plexus.GraphWrapper
containsEdge, containsNode, degree, edgeIterator, edgeIterator, edgeSize, getEdge, inDegree, inTraverser, isDirected, isEmpty, isSimple, nodeIterator, nodeSize, outDegree, outTraverser, traverser, unwrapEdge, unwrapEdgeObject, unwrapNode, wrapEdge, wrapEdgeObject, wrapNode
 
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
containsEdge, containsNode, degree, edgeIterator, edgeIterator, edgeSize, getEdge, inDegree, inTraverser, isDirected, isEmpty, isSimple, nodeIterator, nodeSize, outDegree, outTraverser, traverser
 

Field Detail

listeners

private transient java.util.List listeners

listenerArray

private transient GraphListener[] listenerArray
Constructor Detail

ObservableGraphWrapper

public ObservableGraphWrapper(Graph g)
Creates a new ObservableGraphWrapper.

Method Detail

wrapNodeIterator

protected java.util.Iterator wrapNodeIterator(java.util.Iterator nodeIter)
Description copied from class: GraphWrapper
Returns a wrapped node iterator.

Overrides:
wrapNodeIterator in class GraphWrapper

wrapEdgeIterator

protected java.util.Iterator wrapEdgeIterator(java.util.Iterator edgeIter)
Description copied from class: GraphWrapper
Returns a wrapped edge iterator.

Overrides:
wrapEdgeIterator in class GraphWrapper

wrapTraverser

protected Traverser wrapTraverser(Traverser traverser)
Description copied from class: GraphWrapper
Returns a wrapped traverser.

Overrides:
wrapTraverser in class GraphWrapper

removeIncidentEdges

protected void removeIncidentEdges(java.lang.Object node)

addNode

public boolean addNode(java.lang.Object node)
Description copied from interface: Graph
Adds node to this Graph (optional operation). Returns true if this Graph changed as a result of the call. Returns false if this Graph already contains node.

If a Graph refuses to add a particular node for any reason other than that it already contains the node, it must throw an exception (rather than returning false). This preserves the invariant that a Graph always contains the specified node after this call returns. Graph classes should clearly specify in their documentation any other restrictions on what nodes may be added.

Specified by:
addNode in interface Graph
Overrides:
addNode in class GraphWrapper

removeNode

public boolean removeNode(java.lang.Object node)
Description copied from interface: Graph
Removes node from this Graph (optional operation). This method will also remove all edges incident upon node.

Specified by:
removeNode in interface Graph
Overrides:
removeNode in class GraphWrapper

addEdge

public Graph.Edge addEdge(java.lang.Object object,
                          java.lang.Object tail,
                          java.lang.Object head)
Description copied from interface: Graph
Adds the specified edge to the Graph (optional operation). Returns the newly created Edge if this Graph changed as a result of the call. Returns null if this Graph does not allow duplicate edges and already contains the specified edge.

If a Graph refuses to add a particular edge for any reason other than that it already contains the edge, it must throw an exception (rather than returning null). This preserves the invariant that a Graph always contains the specified edge after this call returns. Graph classes should clearly specify in their documentation any other restrictions on what edges may be added.

Specified by:
addEdge in interface Graph
Overrides:
addEdge in class GraphWrapper

removeEdge

public boolean removeEdge(Graph.Edge edge)
Description copied from interface: Graph
Removes the specified Edge from this Graph (optional operation).

Specified by:
removeEdge in interface Graph
Overrides:
removeEdge in class GraphWrapper

clear

public void clear()
Description copied from interface: Graph
Removes all nodes and edges from this Graph (optional operation).

Specified by:
clear in interface Graph
Overrides:
clear in class GraphWrapper

addGraphListener

public void addGraphListener(GraphListener listener)
Description copied from interface: ObservableGraph
Adds the specified GraphListener which will be notified whenever this ObservableGraph's structure changes.

Specified by:
addGraphListener in interface ObservableGraph

removeGraphListener

public void removeGraphListener(GraphListener listener)
Description copied from interface: ObservableGraph
Removes a previously added GraphListener.

Specified by:
removeGraphListener in interface ObservableGraph

createListenerArray

protected final GraphListener[] createListenerArray()

fireNodeAdded

protected void fireNodeAdded(java.lang.Object node)

fireNodeRemoved

protected void fireNodeRemoved(java.lang.Object node)

fireEdgeAdded

protected void fireEdgeAdded(Graph.Edge edge)

fireEdgeRemoved

protected void fireEdgeRemoved(Graph.Edge edge)