Class SimpleEventManager

  • All Implemented Interfaces:
    GraphEventManager, GraphListener

    public class SimpleEventManager
    extends java.lang.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 Detail

      • SimpleEventManager

        public SimpleEventManager()
    • Method Detail

      • 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
      • notifyAddList

        public void notifyAddList​(Graph g,
                                  java.util.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,
                                      java.util.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,
                                      java.util.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
      • notifyDeleteList

        public void notifyDeleteList​(Graph g,
                                     java.util.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,
                                         java.util.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,
                                         java.util.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
      • notifyingRemove

        public static ExtendedIterator<Triple> notifyingRemove​(Graph g,
                                                               java.util.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.