public class WatchableGraphWrapper extends Object implements WatchableGraph
Constructor and Description |
---|
WatchableGraphWrapper(Graph wrapped) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Triple triple) |
boolean |
addAll(Collection<? extends Triple> c) |
void |
addGraphListener(GraphListener listener,
FilterTriple filter)
Adds the specified
GraphListener to the graph. |
void |
addGraphListener(GraphListener listener,
FilterTriple filter,
long delay)
Adds the specified
GraphListener to the graph. |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
protected void |
dispatchEvent(GraphEvent event)
Dispatches a
GraphEvent to all registered listeners for which
the specified Triple matches the FilterTriple s
of the listeners. |
Iterator<Triple> |
filter(BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object)
Filters triples given a pattern.
|
ImmutableGraph |
getImmutableGraph()
Returns an ImutableGraph describing the graph at the current point in
time.
|
ReadWriteLock |
getLock()
The lock provided by this methods allows to create read- and write-locks
that span multiple method calls.
|
boolean |
isEmpty() |
Iterator<Triple> |
iterator() |
protected boolean |
performAdd(Triple e)
A subclass of
AbstractGraph should override
this method instead of add for Graph event support to be
added. |
protected boolean |
performRemove(Triple triple)
A subclass of
AbstractGraph should override
this method instead of remove for ImmutableGraph event support to be
added. |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
void |
removeGraphListener(GraphListener listener)
Removes the specified
GraphListener from the graph. |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hashCode, parallelStream, removeIf, spliterator, stream
public WatchableGraphWrapper(Graph wrapped)
public boolean contains(Object o)
contains
in interface Collection<Triple>
public Iterator<Triple> filter(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Graph
public boolean add(Triple triple)
add
in interface Collection<Triple>
protected boolean performAdd(Triple e)
AbstractGraph
should override
this method instead of add
for Graph event support to be
added.e
- The triple to be added to the triple collectionpublic boolean remove(Object o)
remove
in interface Collection<Triple>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Triple>
protected boolean performRemove(Triple triple)
AbstractGraph
should override
this method instead of remove
for ImmutableGraph event support to be
added.o
- The triple to be removed from the triple collectionprotected void dispatchEvent(GraphEvent event)
GraphEvent
to all registered listeners for which
the specified Triple
matches the FilterTriple
s
of the listeners.triple
- The Triple that was modifiedtype
- The type of modificationpublic void addGraphListener(GraphListener listener, FilterTriple filter)
WatchableGraph
GraphListener
to the graph. This listener
will be notified, when the graph is modified and the Triple
that was part of the modifiaction matched the specified
FilterTriple
. The notification will be passed without delay.
Same as addGraphListener(listener, filter, 0).
addGraphListener
in interface WatchableGraph
listener
- The listener that will be notifiedfilter
- The triple filter with which triples are tested,
that were part of the modification.public void addGraphListener(GraphListener listener, FilterTriple filter, long delay)
WatchableGraph
GraphListener
to the graph. This listener
will be notified, when the graph is modified and the Triple
that was part of the modifiaction matched the specified
FilterTriple
. The notification will be passed to the
listener after the specified delay time (in milli-seconds) has passed.
If more matching events occur during the delay period, then they are
passed all together at the end of the delay period. If the the listener
unregisters or the platform is stopped within the period then the already
occurred events may not be delivered.
All implementations support this method, immutable implementations will typically provide an empty implementation, they shall not throw an exception.
Implementation of which the triples change over time without add- and remove-methods being called (e.g. implementation dynamically generating their triples on invocation of the filer-method) may choose not to, or only partially propagate their changes to the listener. They should describe the behavior in the documentation of the class.
Implementations should keep weak references the listeners, so that the listener can be garbage collected if its no longer referenced by another object.
If delay is 0 notification will happen synchroneously.
addGraphListener
in interface WatchableGraph
listener
- The listener that will be notifiedfilter
- The triple filter with which triples are tested,
that were part of the modification.delay
- The time period afer which the listener will be notified in milliseconds.public void removeGraphListener(GraphListener listener)
WatchableGraph
GraphListener
from the graph. This
listener will no longer be notified, when the graph is modified.removeGraphListener
in interface WatchableGraph
listener
- The listener to be removed.public ImmutableGraph getImmutableGraph()
Graph
this
is an instance of ImmutableGraph this can
safely return this
.getImmutableGraph
in interface Graph
public ReadWriteLock getLock()
Graph
java.util.concurrent.locks.ReentrantReadWriteLock
.
Immutable instances (such as instances of ImmutableGraph
)
or instances used in transaction where concurrent acces of the same
instance is not an issue may return a no-op ReadWriteLock (i.e. one
which returned ReadLock and WriteLock instances of which the methods do
not do anything)public int size()
size
in interface Collection<Triple>
public boolean isEmpty()
isEmpty
in interface Collection<Triple>
public Object[] toArray()
toArray
in interface Collection<Triple>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Triple>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Triple>
public boolean addAll(Collection<? extends Triple> c)
addAll
in interface Collection<Triple>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<Triple>
public void clear()
clear
in interface Collection<Triple>
Copyright © 2015–2022 The Apache Software Foundation. All rights reserved.