org.apache.clerezza.rdf.core.access
Class LockableMGraphWrapper

java.lang.Object
  extended by org.apache.clerezza.rdf.core.access.LockableMGraphWrapper
All Implemented Interfaces:
Iterable<Triple>, Collection<Triple>, LockableMGraph, MGraph, TripleCollection

public class LockableMGraphWrapper
extends Object
implements LockableMGraph

Wrappes an MGraph as a LockableMGraph, this class is used by TcManager to support TcProviders that do not privide LockableMGraph.

Author:
rbn

Constructor Summary
LockableMGraphWrapper(MGraph providedMGraph)
          Constructs a LocalbleMGraph for an MGraph.
 
Method Summary
 boolean add(Triple e)
           
 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)
           
 Iterator<Triple> filter(NonLiteral subject, UriRef predicate, Resource object)
          Filters triples given a pattern.
 Graph getGraph()
          Returns the graph
 ReadWriteLock getLock()
          The lock provided by this methods allows to create read- and write-locks that span individual method calls.
 boolean isEmpty()
           
 Iterator<Triple> iterator()
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.clerezza.rdf.core.MGraph
equals
 
Methods inherited from interface java.util.Collection
hashCode
 

Constructor Detail

LockableMGraphWrapper

public LockableMGraphWrapper(MGraph providedMGraph)
Constructs a LocalbleMGraph for an MGraph.

Parameters:
providedMGraph - a non-lockable mgraph
Method Detail

getLock

public ReadWriteLock getLock()
Description copied from interface: LockableMGraph
The lock provided by this methods allows to create read- and write-locks that span individual method calls. Having a read locks prevents other threads from writing to this MGraph, having a write-lock prevents other threads from reading and writing.

Specified by:
getLock in interface LockableMGraph
Returns:
the lock of this MGraph

getGraph

public Graph getGraph()
Description copied from interface: MGraph
Returns the graph

Specified by:
getGraph in interface MGraph
Returns:
graph

filter

public Iterator<Triple> filter(NonLiteral subject,
                               UriRef predicate,
                               Resource object)
Description copied from interface: TripleCollection
Filters triples given a pattern. filter(null, null, null) returns the same as iterator()

Specified by:
filter in interface TripleCollection
Returns:
Iterator

size

public int size()
Specified by:
size in interface Collection<Triple>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<Triple>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<Triple>

iterator

public Iterator<Triple> iterator()
Specified by:
iterator in interface Iterable<Triple>
Specified by:
iterator in interface Collection<Triple>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<Triple>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<Triple>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<Triple>

add

public boolean add(Triple e)
Specified by:
add in interface Collection<Triple>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<Triple>

addAll

public boolean addAll(Collection<? extends Triple> c)
Specified by:
addAll in interface Collection<Triple>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<Triple>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<Triple>

clear

public void clear()
Specified by:
clear in interface Collection<Triple>

addGraphListener

public void addGraphListener(GraphListener listener,
                             FilterTriple filter,
                             long delay)
Description copied from interface: TripleCollection
Adds the specified 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.

Specified by:
addGraphListener in interface TripleCollection
Parameters:
listener - The listener that will be notified
filter - 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.

addGraphListener

public void addGraphListener(GraphListener listener,
                             FilterTriple filter)
Description copied from interface: TripleCollection
Adds the specified 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).

Specified by:
addGraphListener in interface TripleCollection
Parameters:
listener - The listener that will be notified
filter - The triple filter with which triples are tested, that were part of the modification.

removeGraphListener

public void removeGraphListener(GraphListener listener)
Description copied from interface: TripleCollection
Removes the specified GraphListener from the graph. This listener will no longer be notified, when the graph is modified.

Specified by:
removeGraphListener in interface TripleCollection
Parameters:
listener - The listener to be removed.


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.