Class ListenerManager

java.lang.Object
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: 1.18 $
  • Constructor Details

    • ListenerManager

      public ListenerManager()
      Default contructor. Initializes all listener sets as empty hash sets.
  • Method Details

    • addAllTimeAttributeListener

      public void addAllTimeAttributeListener​(AttributeListener l) throws ListenerRegistrationException
      Registers AttributeListener l by adding it to the list of nonstrict and strict transaction AttributeListeners.
      Parameters:
      l - the AttributeListener that is registered.
      Throws:
      ListenerRegistrationException - DOCUMENT ME!
      IllegalArgumentException - DOCUMENT ME!
    • addAllTimeEdgeListener

      public void addAllTimeEdgeListener​(EdgeListener l) throws ListenerRegistrationException
      Registers EdgeListener l by adding it to the list of nonstrict transaction EdgeListeners.
      Parameters:
      l - the EdgeListener that is registered.
      Throws:
      ListenerRegistrationException - DOCUMENT ME!
      IllegalArgumentException - DOCUMENT ME!
    • addAllTimeGraphListener

      public void addAllTimeGraphListener​(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!
    • addAllTimeNodeListener

      public void addAllTimeNodeListener​(NodeListener l) throws ListenerRegistrationException
      Registers NodeListener l by adding it to the list of nonstrict transaction NodeListeners.
      Parameters:
      l - the NodeListener that is registered.
      Throws:
      ListenerRegistrationException - DOCUMENT ME!
      IllegalArgumentException - DOCUMENT ME!
    • addDelayedAttributeListener

      public void addDelayedAttributeListener​(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!
    • addDelayedEdgeListener

      public void addDelayedEdgeListener​(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!
    • addDelayedGraphListener

      public void addDelayedGraphListener​(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!
    • addDelayedNodeListener

      public void addDelayedNodeListener​(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!
    • 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!
    • 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!
    • 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!
    • 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 non-strict 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.
    • finishOpenTransactions

      public void finishOpenTransactions()
    • 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.
    • transactionFinished

      public void transactionFinished​(Object source, boolean forgetChanges)
    • transactionFinished

      public void transactionFinished​(Object source, boolean forgetChanges, BackgroundTaskStatusProviderSupportingExternalCall status)
    • transactionStarted

      public void transactionStarted​(Object source)
      Called when a transaction has started.
      Parameters:
      source - the object, which initiated the transaction.
    • getNumTransactionsActive

      public int getNumTransactionsActive()