org.graffiti.event
Class ListenerManager

java.lang.Object
  extended by org.graffiti.event.ListenerManager

public class ListenerManager
extends Object

Class that is responsible to keep track of all the Listeners that are registered. It therefore provides methods to add and remove certain types of Listeners. It also contains methods representing all available events. When one of these methods is called, the ListenerManager delegates the call to all Listeners registered in the appropriate listener set. When a listener is registered as strict, it does not get any messages during the time a transaction is active (i.e. between transactionStarted and transactionFinished). Non strict listeners receive events independent of transactions. It is not possible to add a Listener both as strict and non strict. At the end of a transaction, a set is passed within a TransactionEvent that contains all objects that (might) have been changed. This set is passed to both, strict and non strict listeners.

Version:
$Revision: 5767 $

Constructor Summary
ListenerManager()
          Default constructor.
 
Method Summary
 void addNonstrictAttributeListener(AttributeListener l)
          Registers AttributeListener l by adding it to the list of non-strict and strict transaction AttributeListeners.
 void addNonstrictEdgeListener(EdgeListener l)
          Registers EdgeListener l by adding it to the list of non-strict transaction EdgeListeners.
 void addNonstrictGraphListener(GraphListener l)
          Registers GraphListener l by adding it to the list of GraphListeners.
 void addNonstrictNodeListener(NodeListener l)
          Registers NodeListener l by adding it to the list of non-strict transaction NodeListeners.
 void addStrictAttributeListener(AttributeListener l)
          Registers AttributeListener l by adding it to the list of strict transaction AttributeListeners.
 void addStrictEdgeListener(EdgeListener l)
          Registers EdgeListener l by adding it to the list of strict transaction EdgeListeners.
 void addStrictGraphListener(GraphListener l)
          Registers GraphListener l by adding it to the list of strict transaction GraphListeners.
 void addStrictNodeListener(NodeListener l)
          Registers NodeListener l by adding it to the list of strict transaction NodeListeners.
 void postAttributeAdded(AttributeEvent event)
          Called after an attribute has been added.
 void postAttributeChanged(AttributeEvent event)
          Called after an attribute has been changed.
 void postAttributeRemoved(AttributeEvent event)
          Called after an attribute has been removed.
 void postDirectedChanged(EdgeEvent event)
          Called after the edge was set directed or undirected.
 void postEdgeAdded(GraphEvent event)
          Called after an edge has been added to the graph.
 void postEdgeRemoved(GraphEvent event)
          Called after an edge has been removed from the graph.
 void postEdgeReversed(EdgeEvent event)
          Called after the edge has been reversed.
 void postGraphCleared(GraphEvent event)
          Called after method clear() has been called on a graph.
 void postInEdgeAdded(NodeEvent event)
          Called just after an incoming edge has been added to the node.
 void postInEdgeRemoved(NodeEvent event)
          Called after an incoming edge has been removed from the node.
 void postNodeAdded(GraphEvent event)
          Called after an edge has been added to the graph.
 void postNodeRemoved(GraphEvent event)
          Called after a node has been removed from the graph.
 void postOutEdgeAdded(NodeEvent event)
          Called after an outgoing edge has been added to the node.
 void postOutEdgeRemoved(NodeEvent event)
          Called after an outgoing edge has been removed from the node.
 void postSourceNodeChanged(EdgeEvent event)
          Called after the source node of an edge has changed.
 void postTargetNodeChanged(EdgeEvent event)
          Called after the target node of an edge has changed.
 void postUndirectedEdgeAdded(NodeEvent event)
          Called after an (undirected) edge has been added to the node.
 void postUndirectedEdgeRemoved(NodeEvent event)
          Called after an (undirected) edge has been removed from the node.
 void preAttributeAdded(AttributeEvent event)
          Called just before an attribute is added.
 void preAttributeChanged(AttributeEvent event)
          Called before a change of an attribute takes place.
 void preAttributeRemoved(AttributeEvent event)
          Called just before an attribute is removed.
 void preDirectedChanged(EdgeEvent event)
          Called before the edge is set directed or undirected.
 void preEdgeAdded(GraphEvent event)
          Called just before an edge is added to the graph.
 void preEdgeRemoved(GraphEvent event)
          Called just before an edge is removed from the graph.
 void preEdgeReversed(EdgeEvent event)
          Called before the edge is going to be reversed.
 void preGraphCleared(GraphEvent event)
          Called before method clear() is called on a graph.
 void preInEdgeAdded(NodeEvent event)
          Called just before an incoming edge is added to the node.
 void preInEdgeRemoved(NodeEvent event)
          Called just before an incoming edge is removed from the node.
 void preNodeAdded(GraphEvent event)
          Called just before a node is added to the graph.
 void preNodeRemoved(GraphEvent event)
          Called just before a node is removed from the graph.
 void preOutEdgeAdded(NodeEvent event)
          Called just before an outgoing edge is added to the node.
 void preOutEdgeRemoved(NodeEvent event)
          Called just before an outgoing edge is removed from the node.
 void preSourceNodeChanged(EdgeEvent event)
          Called before a change of the source node of an edge takes place.
 void preTargetNodeChanged(EdgeEvent event)
          Called before a change of the target node of an edge takes place.
 void preUndirectedEdgeAdded(NodeEvent event)
          Called just before an (undirected) edge is added to the node.
 void preUndirectedEdgeRemoved(NodeEvent event)
          Called just before an (undirected) edge is removed from the node.
 void removeAttributeListener(AttributeListener l)
          Unregisters AttributeListener l by removing it from the list of AttributeListeners.
 void removeEdgeListener(EdgeListener l)
          Unregisters EdgeListener l by removing it from the list of EdgeListeners.
 void removeGraphListener(GraphListener l)
          Unregisters GraphListener l by removing it from the list of nonstrict and strict transaction GraphListeners.
 void removeNodeListener(NodeListener l)
          Unregisters NodeListener l by removing it from the list of NodeListeners
 void transactionFinished(Object source)
          Called when a transaction has finished.
 void transactionStarted(Object source)
          Called when a transaction has started.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenerManager

public ListenerManager()
Default constructor. Initializes all listener sets as empty hash sets.

Method Detail

addNonstrictAttributeListener

public void addNonstrictAttributeListener(AttributeListener l)
                                   throws ListenerRegistrationException
Registers AttributeListener l by adding it to the list of non-strict and strict transaction AttributeListeners.

Parameters:
l - the AttributeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addNonstrictEdgeListener

public void addNonstrictEdgeListener(EdgeListener l)
                              throws ListenerRegistrationException
Registers EdgeListener l by adding it to the list of non-strict transaction EdgeListeners.

Parameters:
l - the EdgeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addNonstrictGraphListener

public void addNonstrictGraphListener(GraphListener l)
                               throws ListenerRegistrationException
Registers GraphListener l by adding it to the list of GraphListeners.

Parameters:
l - the GraphListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addNonstrictNodeListener

public void addNonstrictNodeListener(NodeListener l)
                              throws ListenerRegistrationException
Registers NodeListener l by adding it to the list of non-strict transaction NodeListeners.

Parameters:
l - the NodeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addStrictAttributeListener

public void addStrictAttributeListener(AttributeListener l)
                                throws ListenerRegistrationException
Registers AttributeListener l by adding it to the list of strict transaction AttributeListeners.

Parameters:
l - the AttributeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addStrictEdgeListener

public void addStrictEdgeListener(EdgeListener l)
                           throws ListenerRegistrationException
Registers EdgeListener l by adding it to the list of strict transaction EdgeListeners.

Parameters:
l - the EdgeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addStrictGraphListener

public void addStrictGraphListener(GraphListener l)
                            throws ListenerRegistrationException
Registers GraphListener l by adding it to the list of strict transaction GraphListeners.

Parameters:
l - the GraphListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

addStrictNodeListener

public void addStrictNodeListener(NodeListener l)
                           throws ListenerRegistrationException
Registers NodeListener l by adding it to the list of strict transaction NodeListeners.

Parameters:
l - the NodeListener that is registered.
Throws:
ListenerRegistrationException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!

postAttributeAdded

public void postAttributeAdded(AttributeEvent event)
Called after an attribute has been added. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postAttributeChanged

public void postAttributeChanged(AttributeEvent event)
Called after an attribute has been changed. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postAttributeRemoved

public void postAttributeRemoved(AttributeEvent event)
Called after an attribute has been removed. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postDirectedChanged

public void postDirectedChanged(EdgeEvent event)
Called after the edge was set directed or undirected. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postEdgeAdded

public void postEdgeAdded(GraphEvent event)
Called after an edge has been added to the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postEdgeRemoved

public void postEdgeRemoved(GraphEvent event)
Called after an edge has been removed from the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postEdgeReversed

public void postEdgeReversed(EdgeEvent event)
Called after the edge has been reversed. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postGraphCleared

public void postGraphCleared(GraphEvent event)
Called after method clear() has been called on a graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postInEdgeAdded

public void postInEdgeAdded(NodeEvent event)
Called just after an incoming edge has been added to the node. (For undirected edges postUndirectedEdgeAdded is called instead.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postInEdgeRemoved

public void postInEdgeRemoved(NodeEvent event)
Called after an incoming edge has been removed from the node. (For undirected edges postUndirectedEdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postNodeAdded

public void postNodeAdded(GraphEvent event)
Called after an edge has been added to the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postNodeRemoved

public void postNodeRemoved(GraphEvent event)
Called after a node has been removed from the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postOutEdgeAdded

public void postOutEdgeAdded(NodeEvent event)
Called after an outgoing edge has been added to the node. (For undirected edges postUndirectedEdgeAdded is called instead.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postOutEdgeRemoved

public void postOutEdgeRemoved(NodeEvent event)
Called after an outgoing edge has been removed from the node. (For undirected edges postUndirectedEdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postSourceNodeChanged

public void postSourceNodeChanged(EdgeEvent event)
Called after the source node of an edge has changed. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postTargetNodeChanged

public void postTargetNodeChanged(EdgeEvent event)
Called after the target node of an edge has changed. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postUndirectedEdgeAdded

public void postUndirectedEdgeAdded(NodeEvent event)
Called after an (undirected) edge has been added to the node. (For directed edges pre- In/Out- EdgeAdded is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

postUndirectedEdgeRemoved

public void postUndirectedEdgeRemoved(NodeEvent event)
Called after an (undirected) edge has been removed from the node. (For directed edges pre- In/Out- EdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preAttributeAdded

public void preAttributeAdded(AttributeEvent event)
Called just before an attribute is added. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preAttributeChanged

public void preAttributeChanged(AttributeEvent event)
Called before a change of an attribute takes place. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preAttributeRemoved

public void preAttributeRemoved(AttributeEvent event)
Called just before an attribute is removed. Calls the same method in all AttributeListeners in the strictAttributeListenerList

Parameters:
event - the AttributeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preDirectedChanged

public void preDirectedChanged(EdgeEvent event)
Called before the edge is set directed or undirected. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preEdgeAdded

public void preEdgeAdded(GraphEvent event)
Called just before an edge is added to the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preEdgeRemoved

public void preEdgeRemoved(GraphEvent event)
Called just before an edge is removed from the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preEdgeReversed

public void preEdgeReversed(EdgeEvent event)
Called before the edge is going to be reversed. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preGraphCleared

public void preGraphCleared(GraphEvent event)
Called before method clear() is called on a graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preInEdgeAdded

public void preInEdgeAdded(NodeEvent event)
Called just before an incoming edge is added to the node. (For undirected edges preUndirectedEdgeAdded is called instead.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preInEdgeRemoved

public void preInEdgeRemoved(NodeEvent event)
Called just before an incoming edge is removed from the node. (For undirected edges preUndirectedEdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preNodeAdded

public void preNodeAdded(GraphEvent event)
Called just before a node is added to the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preNodeRemoved

public void preNodeRemoved(GraphEvent event)
Called just before a node is removed from the graph. Calls the same method in all GraphListeners in the strictGraphListenerList

Parameters:
event - the GraphEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preOutEdgeAdded

public void preOutEdgeAdded(NodeEvent event)
Called just before an outgoing edge is added to the node. (For undirected edges preUndirectedEdgeAdded is called instead.) Calls the same method in all NodeListeners in the nodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preOutEdgeRemoved

public void preOutEdgeRemoved(NodeEvent event)
Called just before an outgoing edge is removed from the node. (For undirected edges preUndirectedEdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preSourceNodeChanged

public void preSourceNodeChanged(EdgeEvent event)
Called before a change of the source node of an edge takes place. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preTargetNodeChanged

public void preTargetNodeChanged(EdgeEvent event)
Called before a change of the target node of an edge takes place. Calls the same method in all EdgeListeners in the strictEdgeListenerList

Parameters:
event - the EdgeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preUndirectedEdgeAdded

public void preUndirectedEdgeAdded(NodeEvent event)
Called just before an (undirected) edge is added to the node. (For directed edges pre- In/Out- EdgeAdded is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

preUndirectedEdgeRemoved

public void preUndirectedEdgeRemoved(NodeEvent event)
Called just before an (undirected) edge is removed from the node. (For directed edges pre- In/Out- EdgeRemoved is called.) Calls the same method in all NodeListeners in the strictNodeListenerList

Parameters:
event - the NodeEvent detailing the changes.
Throws:
IllegalArgumentException - DOCUMENT ME!

removeAttributeListener

public void removeAttributeListener(AttributeListener l)
                             throws ListenerNotFoundException
Unregisters AttributeListener l by removing it from the list of AttributeListeners.

Parameters:
l - the AttributeListener that is unregistered.
Throws:
ListenerNotFoundException - if the listener to delete cannot be found in the listener list.

removeEdgeListener

public void removeEdgeListener(EdgeListener l)
                        throws ListenerNotFoundException
Unregisters EdgeListener l by removing it from the list of EdgeListeners.

Parameters:
l - the EdgeListener that is unregistered.
Throws:
ListenerNotFoundException - if the listener to delete cannot be found in the listener list.

removeGraphListener

public void removeGraphListener(GraphListener l)
                         throws ListenerNotFoundException
Unregisters GraphListener l by removing it from the list of nonstrict and strict transaction GraphListeners.

Parameters:
l - the GraphListener that is unregistered.
Throws:
ListenerNotFoundException - if the listener to delete cannot be found in the listener list.

removeNodeListener

public void removeNodeListener(NodeListener l)
                        throws ListenerNotFoundException
Unregisters NodeListener l by removing it from the list of NodeListeners

Parameters:
l - the NodeListener that is unregistered.
Throws:
ListenerNotFoundException - if the listener to delete cannot be found in the listener list.

transactionFinished

public void transactionFinished(Object source)
Called when a transaction has finished. Changes the event it gets by reusing the source but adding the Set of (probably) changed objects.

Parameters:
source - the object, which initiated the end of the transaction.

transactionStarted

public void transactionStarted(Object source)
Called when a transaction has started.

Parameters:
source - the object, which initiated the transaction.


Generated at 2012-05-30 11:00:14 PM CEST