Class SimpleEventManager

java.lang.Object
org.apache.jena.graph.impl.SimpleEventManager
All Implemented Interfaces:
GraphEventManager, GraphListener

public class SimpleEventManager extends Object implements GraphEventManager
Simple implementation of GraphEventManager for GraphBase to use. The listeners are held as an [Array]List.

This class also holds the utility method notifyingRemove, which wraps iterators so that their .remove() operation notifies the specified graph of the removal.

  • Constructor Details

    • SimpleEventManager

      public SimpleEventManager()
  • Method Details

    • register

      public GraphEventManager register(GraphListener listener)
      Description copied from interface: GraphEventManager
      Attached listener to this manager; notification events sent to the manager are sent to all registered listeners. A listener may be registered multiple times, in which case it's called multiple times per event. A listener will be notified of an event if it is registered before the Graph method call that initiated the event, and was not unregistered before that method call returned. In addition, a listener may (or may not) be notified of an event if it is registered before such a method returns or is unregistered after such a method is called. For example, it may unregister itself in response to the event. If the registration and/or unregistration occur on different threads the usual thread uncertainties in such statements apply.
      Specified by:
      register in interface GraphEventManager
      Parameters:
      listener - a listener to be fed events
      Returns:
      this manager, for cascading
    • unregister

      public GraphEventManager unregister(GraphListener listener)
      Description copied from interface: GraphEventManager
      If listener is attached to this manager, detach it, otherwise do nothing. Only a single registration is removed.
      Specified by:
      unregister in interface GraphEventManager
      Parameters:
      listener - the listener to be detached from the graph
      Returns:
      this manager, for cascading
    • listening

      public boolean listening()
      Description copied from interface: GraphEventManager
      Answer true iff there is at least one attached listener.
      Specified by:
      listening in interface GraphEventManager
      Returns:
      true iff there is at least one attached listener
    • notifyAddTriple

      public void notifyAddTriple(Graph g, Triple t)
      Description copied from interface: GraphListener
      Method called when a single triple has been added to the graph.
      Specified by:
      notifyAddTriple in interface GraphListener
    • notifyAddArray

      public void notifyAddArray(Graph g, Triple[] ts)
      Description copied from interface: GraphListener
      Method called when an array of triples has been added to the graph.
      Specified by:
      notifyAddArray in interface GraphListener
    • notifyAddList

      public void notifyAddList(Graph g, List<Triple> L)
      Description copied from interface: GraphListener
      Method called when a list [of triples] has been added to the graph.
      Specified by:
      notifyAddList in interface GraphListener
    • notifyAddIterator

      public void notifyAddIterator(Graph g, List<Triple> it)
      Description copied from interface: GraphEventManager
      Notify all attached listeners that an iterator [of triples] has been added to the graph; its content has been captured in the list triples.
      Specified by:
      notifyAddIterator in interface GraphEventManager
    • notifyAddIterator

      public void notifyAddIterator(Graph g, Iterator<Triple> it)
      Description copied from interface: GraphListener
      Method called when an iterator [of triples] has been added to the graph
      Specified by:
      notifyAddIterator in interface GraphListener
    • notifyAddGraph

      public void notifyAddGraph(Graph g, Graph added)
      Description copied from interface: GraphListener
      Method called when another graph g has been used to specify the triples added to our attached graph.
      Specified by:
      notifyAddGraph in interface GraphListener
      Parameters:
      g - the graph of triples added
    • notifyDeleteTriple

      public void notifyDeleteTriple(Graph g, Triple t)
      Description copied from interface: GraphListener
      Method called when a single triple has been deleted from the graph.
      Specified by:
      notifyDeleteTriple in interface GraphListener
    • notifyDeleteArray

      public void notifyDeleteArray(Graph g, Triple[] ts)
      Description copied from interface: GraphListener
      Method called when an array of triples has been deleted from the graph.
      Specified by:
      notifyDeleteArray in interface GraphListener
    • notifyDeleteList

      public void notifyDeleteList(Graph g, List<Triple> L)
      Description copied from interface: GraphListener
      Method called when a list [of triples] has been deleted from the graph.
      Specified by:
      notifyDeleteList in interface GraphListener
    • notifyDeleteIterator

      public void notifyDeleteIterator(Graph g, List<Triple> L)
      Description copied from interface: GraphEventManager
      Notify all attached listeners that an iterator [of triples] has been removed from the graph; its content has been captured in the list triples.
      Specified by:
      notifyDeleteIterator in interface GraphEventManager
    • notifyDeleteIterator

      public void notifyDeleteIterator(Graph g, Iterator<Triple> it)
      Description copied from interface: GraphListener
      Method called when an iterator [of triples] has been deleted from the graph.
      Specified by:
      notifyDeleteIterator in interface GraphListener
    • notifyDeleteGraph

      public void notifyDeleteGraph(Graph g, Graph removed)
      Description copied from interface: GraphListener
      Method to call when another graph has been used to specify the triples deleted from our attached graph.
      Specified by:
      notifyDeleteGraph in interface GraphListener
      Parameters:
      g - the graph of triples added
    • notifyEvent

      public void notifyEvent(Graph source, Object event)
      Description copied from interface: GraphListener
      method to call for a general event. value is usually a GraphEvents. Special attention is drawn to GraphEvents.removeAll and events whose GraphEvents.getTitle() is "remove" (see GraphEvents.remove(Node, Node, Node). Unlike other notifications, the listener cannot tell which triples have been modified, since they have already been deleted by the time this event is sent, and the event does not include a record of them.
      Specified by:
      notifyEvent in interface GraphListener
    • notifyingRemove

      public static ExtendedIterator<Triple> notifyingRemove(Graph g, Iterator<Triple> i)
      Answer an iterator which wraps i to ensure that if a .remove() is executed on it, the graph g will be notified.