Package org.apache.jena.graph.impl
Class SimpleEventManager
java.lang.Object
org.apache.jena.graph.impl.SimpleEventManager
- All Implemented Interfaces:
GraphEventManager
,GraphListener
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Answer true iff there is at least one attached listener.void
notifyAddArray
(Graph g, Triple[] ts) Method called when an array of triples has been added to the graph.void
notifyAddGraph
(Graph g, Graph added) Method called when another graphg
has been used to specify the triples added to our attached graph.void
notifyAddIterator
(Graph g, Iterator<Triple> it) Method called when an iterator [of triples] has been added to the graphvoid
notifyAddIterator
(Graph g, List<Triple> it) Notify all attached listeners that an iterator [of triples] has been added to the graph; its content has been captured in the listtriples
.void
notifyAddList
(Graph g, List<Triple> L) Method called when a list [of triples] has been added to the graph.void
notifyAddTriple
(Graph g, Triple t) Method called when a single triple has been added to the graph.void
notifyDeleteArray
(Graph g, Triple[] ts) Method called when an array of triples has been deleted from the graph.void
notifyDeleteGraph
(Graph g, Graph removed) Method to call when another graph has been used to specify the triples deleted from our attached graph.void
notifyDeleteIterator
(Graph g, Iterator<Triple> it) Method called when an iterator [of triples] has been deleted from the graph.void
notifyDeleteIterator
(Graph g, List<Triple> L) Notify all attached listeners that an iterator [of triples] has been removed from the graph; its content has been captured in the listtriples
.void
notifyDeleteList
(Graph g, List<Triple> L) Method called when a list [of triples] has been deleted from the graph.void
notifyDeleteTriple
(Graph g, Triple t) Method called when a single triple has been deleted from the graph.void
notifyEvent
(Graph source, Object event) method to call for a general event.static ExtendedIterator<Triple>
notifyingRemove
(Graph g, Iterator<Triple> i) Answer an iterator which wrapsi
to ensure that if a .remove() is executed on it, the graphg
will be notified.register
(GraphListener listener) Attachedlistener
to this manager; notification events sent to the manager are sent to all registered listeners.unregister
(GraphListener listener) Iflistener
is attached to this manager, detach it, otherwise do nothing.
-
Constructor Details
-
SimpleEventManager
public SimpleEventManager()
-
-
Method Details
-
register
Description copied from interface:GraphEventManager
Attachedlistener
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 interfaceGraphEventManager
- Parameters:
listener
- a listener to be fed events- Returns:
- this manager, for cascading
-
unregister
Description copied from interface:GraphEventManager
Iflistener
is attached to this manager, detach it, otherwise do nothing. Only a single registration is removed.- Specified by:
unregister
in interfaceGraphEventManager
- 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 interfaceGraphEventManager
- Returns:
- true iff there is at least one attached listener
-
notifyAddTriple
Description copied from interface:GraphListener
Method called when a single triple has been added to the graph.- Specified by:
notifyAddTriple
in interfaceGraphListener
-
notifyAddArray
Description copied from interface:GraphListener
Method called when an array of triples has been added to the graph.- Specified by:
notifyAddArray
in interfaceGraphListener
-
notifyAddList
Description copied from interface:GraphListener
Method called when a list [of triples] has been added to the graph.- Specified by:
notifyAddList
in interfaceGraphListener
-
notifyAddIterator
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 listtriples
.- Specified by:
notifyAddIterator
in interfaceGraphEventManager
-
notifyAddIterator
Description copied from interface:GraphListener
Method called when an iterator [of triples] has been added to the graph- Specified by:
notifyAddIterator
in interfaceGraphListener
-
notifyAddGraph
Description copied from interface:GraphListener
Method called when another graphg
has been used to specify the triples added to our attached graph.- Specified by:
notifyAddGraph
in interfaceGraphListener
- Parameters:
g
- the graph of triples added
-
notifyDeleteTriple
Description copied from interface:GraphListener
Method called when a single triple has been deleted from the graph.- Specified by:
notifyDeleteTriple
in interfaceGraphListener
-
notifyDeleteArray
Description copied from interface:GraphListener
Method called when an array of triples has been deleted from the graph.- Specified by:
notifyDeleteArray
in interfaceGraphListener
-
notifyDeleteList
Description copied from interface:GraphListener
Method called when a list [of triples] has been deleted from the graph.- Specified by:
notifyDeleteList
in interfaceGraphListener
-
notifyDeleteIterator
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 listtriples
.- Specified by:
notifyDeleteIterator
in interfaceGraphEventManager
-
notifyDeleteIterator
Description copied from interface:GraphListener
Method called when an iterator [of triples] has been deleted from the graph.- Specified by:
notifyDeleteIterator
in interfaceGraphListener
-
notifyDeleteGraph
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 interfaceGraphListener
- Parameters:
g
- the graph of triples added
-
notifyEvent
Description copied from interface:GraphListener
method to call for a general event.value
is usually aGraphEvents
. Special attention is drawn toGraphEvents.removeAll
and events whoseGraphEvents.getTitle()
is"remove"
(seeGraphEvents.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 interfaceGraphListener
-
notifyingRemove
Answer an iterator which wrapsi
to ensure that if a .remove() is executed on it, the graphg
will be notified.
-