public class SimpleEventManager extends Object implements GraphEventManager
This class also holds the utility method notifyingRemove, which wraps iterators so that their .remove() operation notifies the specified graph of the removal.
Constructor and Description |
---|
SimpleEventManager() |
SimpleEventManager(Graph graph)
Deprecated.
Use the no argument constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
listening()
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 graph
g 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 graph
|
void |
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 list
triples . |
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 list
triples . |
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 wraps
i to ensure that if a
.remove() is executed on it, the graph g will be notified. |
GraphEventManager |
register(GraphListener listener)
Attached
listener to this manager; notification events
sent to the manager are sent to all registered listeners. |
GraphEventManager |
unregister(GraphListener listener)
If
listener is attached to this manager, detach it, otherwise
do nothing. |
@Deprecated public SimpleEventManager(Graph graph)
public SimpleEventManager()
public GraphEventManager register(GraphListener listener)
GraphEventManager
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.register
in interface GraphEventManager
listener
- a listener to be fed eventspublic GraphEventManager unregister(GraphListener listener)
GraphEventManager
listener
is attached to this manager, detach it, otherwise
do nothing. Only a single registration is removed.unregister
in interface GraphEventManager
listener
- the listener to be detached from the graphpublic boolean listening()
GraphEventManager
listening
in interface GraphEventManager
public void notifyAddTriple(Graph g, Triple t)
GraphListener
notifyAddTriple
in interface GraphListener
public void notifyAddArray(Graph g, Triple[] ts)
GraphListener
notifyAddArray
in interface GraphListener
public void notifyAddList(Graph g, List<Triple> L)
GraphListener
notifyAddList
in interface GraphListener
public void notifyAddIterator(Graph g, List<Triple> it)
GraphEventManager
triples
.notifyAddIterator
in interface GraphEventManager
public void notifyAddIterator(Graph g, Iterator<Triple> it)
GraphListener
notifyAddIterator
in interface GraphListener
public void notifyAddGraph(Graph g, Graph added)
GraphListener
g
has been used to
specify the triples added to our attached graph.notifyAddGraph
in interface GraphListener
g
- the graph of triples addedpublic void notifyDeleteTriple(Graph g, Triple t)
GraphListener
notifyDeleteTriple
in interface GraphListener
public void notifyDeleteArray(Graph g, Triple[] ts)
GraphListener
notifyDeleteArray
in interface GraphListener
public void notifyDeleteList(Graph g, List<Triple> L)
GraphListener
notifyDeleteList
in interface GraphListener
public void notifyDeleteIterator(Graph g, List<Triple> L)
GraphEventManager
triples
.notifyDeleteIterator
in interface GraphEventManager
public void notifyDeleteIterator(Graph g, Iterator<Triple> it)
GraphListener
notifyDeleteIterator
in interface GraphListener
public void notifyDeleteGraph(Graph g, Graph removed)
GraphListener
notifyDeleteGraph
in interface GraphListener
g
- the graph of triples addedpublic void notifyEvent(Graph source, Object event)
GraphListener
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.notifyEvent
in interface GraphListener
public static ExtendedIterator<Triple> notifyingRemove(Graph g, Iterator<Triple> i)
i
to ensure that if a
.remove() is executed on it, the graph g
will be notified.Licenced under the Apache License, Version 2.0