org.openanzo.services.trackers
Class SelectorTracker

java.lang.Object
  extended by org.openanzo.services.trackers.SelectorTracker
All Implemented Interfaces:
INotificationSelector, ISerializableTracker, ITracker
Direct Known Subclasses:
JenaSelectorTracker

public class SelectorTracker
extends java.lang.Object
implements ISerializableTracker

Used to track statements which match a specified selector pattern.

Author:
Christopher R. Vincent, Jordi A. Albornoz Mulligan, Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
SelectorTracker(org.openrdf.model.Resource namedGraph)
          Create a SelectorTracker for a namedGraph
SelectorTracker(org.openrdf.model.Resource trackerURI, org.openrdf.model.Resource context, org.openrdf.model.Resource subject, org.openrdf.model.URI predicate, org.openrdf.model.Value object, boolean replicated, boolean deleted, java.util.Collection<org.openrdf.model.URI> trackerSetUris)
          Create a new SelectorTracker
SelectorTracker(org.openrdf.model.Resource context, org.openrdf.model.Resource subject, org.openrdf.model.URI predicate, org.openrdf.model.Value object)
          Create a new SelectorTracker to track statements using provided values as filter
SelectorTracker(SelectorTracker tracker)
          Create a new SelectorTracker based on data stored within Jastor tracker object
 
Method Summary
 void addListener(org.openrdf.model.URI trackerSetURI, TrackerListener listener)
          Add a new TrackerListener for this tracker
 void addTrackerSet(org.openrdf.model.URI trackerSetURI)
          Add a new TrackerSet to this tracker
 boolean equals(java.lang.Object o)
          This is here simply to remind you to implement equals and hashCode when implementing this interface.
static java.util.List<org.openrdf.model.Resource> findSerializedTrackers(INamedGraph graph)
          Finds the Resource objects representing all of the serialized SelectorTracker objects found in the given graph.
 org.openrdf.model.URI getContext()
          Get the Context resource for tracker
 java.util.Set<TrackerListener> getListeners()
          Get the TrackerListeners for this tracker
 java.lang.String getMessageSelector()
          Get the JMS message selector corresponding to this INotificationSelector's definition
 org.openrdf.model.Value getObject()
          The tracker's object value
 org.openrdf.model.URI getPredicate()
          The tracker's predicate value
 java.lang.String getQueryString()
          Get the Sparql query used in order to retrieve this queries matching statements from the dataset
 org.openrdf.model.Resource getSubject()
          The tracker's subject value
 java.util.Set<org.openrdf.model.URI> getTrackerSets()
          Get the TrackerSets for this tracker
 org.openrdf.model.Resource getURI()
          The tracker's URI
 int hashCode()
          This is here simply to remind you to implement equals and hashCode when implementing this interface.
 boolean isDeleted()
          Determine if the tracker is deleted
 boolean isReplicated()
          Determine if the tracker is replicated
static java.util.Set<ISerializableTracker> loadAllSerializedTrackers(INamedGraph graph)
          Loads all of the trackers found serialized in the given model.
static SelectorTracker loadSerializedTracker(org.openrdf.model.Resource trackerResource, INamedGraph graph)
          Creates a SelectorTracker object from its serialization in the given graph.
 boolean matchNamedGraphUri(org.openrdf.model.URI namedGraphUri)
          Determine if a change to the given NamedGraph matches this tracker.
 boolean matchStatement(org.openrdf.model.Statement statement)
          Determine if the given statement matches this tracker.
 void removeListener(org.openrdf.model.URI trackerSetURI, TrackerListener listener)
          Remove a TrackerListener from this tracker
 void removeSerialization(INamedGraph graph)
          Removes the RDF statements that make up any and all serializations of this tracker from the given RDF graph.
 void removeTrackerSet(org.openrdf.model.URI trackerSetURI)
          Remove a TrackerSet from this tracker
 org.openrdf.model.Resource serialize(INamedGraph graph)
          Serializes this tracker into the given RDF graph.
 void setDeleted(boolean deleted)
          Set if the tracker is deleted
 void setReplicated(boolean replicated)
          Set if the tracker is replicated
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectorTracker

public SelectorTracker(org.openrdf.model.Resource namedGraph)
Create a SelectorTracker for a namedGraph

Parameters:
namedGraph - to track

SelectorTracker

public SelectorTracker(SelectorTracker tracker)
Create a new SelectorTracker based on data stored within Jastor tracker object

Parameters:
tracker - Jastor tracker object reflecting definition of a tracker

SelectorTracker

public SelectorTracker(org.openrdf.model.Resource trackerURI,
                       org.openrdf.model.Resource context,
                       org.openrdf.model.Resource subject,
                       org.openrdf.model.URI predicate,
                       org.openrdf.model.Value object,
                       boolean replicated,
                       boolean deleted,
                       java.util.Collection<org.openrdf.model.URI> trackerSetUris)
Create a new SelectorTracker

Parameters:
trackerURI - URI for tracker
context - URI of graph of match statement
subject - Subject of match statement
predicate - Predicate of match statement
object - Object of match statement
replicated - true if tracker has been replicated
deleted - true if tracker was deleted since last replication
trackerSetUris - set of TrackerSets which this tracker belongs

SelectorTracker

public SelectorTracker(org.openrdf.model.Resource context,
                       org.openrdf.model.Resource subject,
                       org.openrdf.model.URI predicate,
                       org.openrdf.model.Value object)
Create a new SelectorTracker to track statements using provided values as filter

Parameters:
context - URI of graph of match statement
subject - Subject of match statement
predicate - Predicate of match statement
object - Object of match statement
Method Detail

findSerializedTrackers

public static java.util.List<org.openrdf.model.Resource> findSerializedTrackers(INamedGraph graph)
Finds the Resource objects representing all of the serialized SelectorTracker objects found in the given graph.

Parameters:
graph -
Returns:
a List of Resource objects

loadSerializedTracker

public static SelectorTracker loadSerializedTracker(org.openrdf.model.Resource trackerResource,
                                                    INamedGraph graph)
                                             throws AnzoException
Creates a SelectorTracker object from its serialization in the given graph.

Parameters:
trackerResource - the resource representing the serialized tracker
graph -
Returns:
the loaded SelectorTracker
Throws:
AnzoException

serialize

public org.openrdf.model.Resource serialize(INamedGraph graph)
Description copied from interface: ISerializableTracker
Serializes this tracker into the given RDF graph. If this method is called multiple times on the same graph, then it is possible that multiple serializations of the tracker will exist. In that case, those serializations may each have different RDF data but when loaded, they must all be equal via the equals method. The returned RDF resource node is useful for adding extra properties to the serialized tracker.

Specified by:
serialize in interface ISerializableTracker
Parameters:
graph - in which to serialize definition and state of trackers
Returns:
the RDF resource which represents the tracker in the graph.

removeSerialization

public void removeSerialization(INamedGraph graph)
Description copied from interface: ISerializableTracker
Removes the RDF statements that make up any and all serializations of this tracker from the given RDF graph.

Specified by:
removeSerialization in interface ISerializableTracker
Parameters:
graph - in which to serialize definition and state of trackers

matchStatement

public boolean matchStatement(org.openrdf.model.Statement statement)
Description copied from interface: ITracker
Determine if the given statement matches this tracker.

Specified by:
matchStatement in interface ITracker
Parameters:
statement - statement to compare
Returns:
true if the given statement matches this tracker.

matchNamedGraphUri

public boolean matchNamedGraphUri(org.openrdf.model.URI namedGraphUri)
Description copied from interface: ITracker
Determine if a change to the given NamedGraph matches this tracker.

Specified by:
matchNamedGraphUri in interface ITracker
Parameters:
namedGraphUri - Uri of namedGraph to compare.
Returns:
true if a change to the given NamedGraph matches this tracker.

equals

public boolean equals(java.lang.Object o)
Description copied from interface: ITracker
This is here simply to remind you to implement equals and hashCode when implementing this interface. Two trackers are equal if they yield the same result when calling matchStatement for all possible statements.

Specified by:
equals in interface ITracker
Overrides:
equals in class java.lang.Object
Parameters:
o - object to determine equality
Returns:
true if two trackers yield the same result when calling matchStatement for all possible statements

hashCode

public int hashCode()
Description copied from interface: ITracker
This is here simply to remind you to implement equals and hashCode when implementing this interface. Two trackers are equal if they yield the same result when calling matchStatement for all possible statements.

Specified by:
hashCode in interface ITracker
Overrides:
hashCode in class java.lang.Object
Returns:
hashCode for this tracker

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getContext

public org.openrdf.model.URI getContext()
Description copied from interface: ITracker
Get the Context resource for tracker

Specified by:
getContext in interface ITracker
Returns:
the Context resource for tracker

loadAllSerializedTrackers

public static java.util.Set<ISerializableTracker> loadAllSerializedTrackers(INamedGraph graph)
                                                                     throws AnzoException
Loads all of the trackers found serialized in the given model. This is a convenience function that only knows how to load NamedGraphTracker and SelectorTracker objects from the model. For each tracker found in the model, this method returns the loaded StatementTracker object as well as the Resource object from which the StatementTracker was loaded.

Parameters:
graph - where serialization of tracker resides
Returns:
a list of Object arrays where each array has length == 2 and the first item in each array is a StatementTracker object and the second is a Resource object.
Throws:
AnzoException

getMessageSelector

public java.lang.String getMessageSelector()
Description copied from interface: INotificationSelector
Get the JMS message selector corresponding to this INotificationSelector's definition

Specified by:
getMessageSelector in interface INotificationSelector
Returns:
the JMS message selector corresponding to this INotificationSelector's definition

getQueryString

public java.lang.String getQueryString()
Description copied from interface: ITracker
Get the Sparql query used in order to retrieve this queries matching statements from the dataset

Specified by:
getQueryString in interface ITracker
Returns:
the Sparql query used in order to retrieve this queries matching statements from the dataset

getObject

public org.openrdf.model.Value getObject()
The tracker's object value

Specified by:
getObject in interface ITracker
Returns:
the object

getPredicate

public org.openrdf.model.URI getPredicate()
The tracker's predicate value

Specified by:
getPredicate in interface ITracker
Returns:
the predicate

getSubject

public org.openrdf.model.Resource getSubject()
The tracker's subject value

Specified by:
getSubject in interface ITracker
Returns:
the subject

getURI

public org.openrdf.model.Resource getURI()
The tracker's URI

Specified by:
getURI in interface ISerializableTracker
Returns:
the tracker's URI

isDeleted

public boolean isDeleted()
Determine if the tracker is deleted

Specified by:
isDeleted in interface ISerializableTracker
Returns:
true if the tracker is deleted

setDeleted

public void setDeleted(boolean deleted)
Set if the tracker is deleted

Specified by:
setDeleted in interface ISerializableTracker
Parameters:
deleted - is the tracker is deleted

isReplicated

public boolean isReplicated()
Determine if the tracker is replicated

Specified by:
isReplicated in interface ISerializableTracker
Returns:
true if the tracker is replicated

setReplicated

public void setReplicated(boolean replicated)
Set if the tracker is replicated

Specified by:
setReplicated in interface ISerializableTracker
Parameters:
replicated - is the tracker is replicated

addListener

public void addListener(org.openrdf.model.URI trackerSetURI,
                        TrackerListener listener)
Description copied from interface: ISerializableTracker
Add a new TrackerListener for this tracker

Specified by:
addListener in interface ISerializableTracker
Parameters:
trackerSetURI - URI of set to which this listener belongs
listener - TrackerListener to add

removeListener

public void removeListener(org.openrdf.model.URI trackerSetURI,
                           TrackerListener listener)
Description copied from interface: ISerializableTracker
Remove a TrackerListener from this tracker

Specified by:
removeListener in interface ISerializableTracker
Parameters:
trackerSetURI - URI of set to which this listener belongs
listener - TrackerListener to remove

addTrackerSet

public void addTrackerSet(org.openrdf.model.URI trackerSetURI)
Description copied from interface: ISerializableTracker
Add a new TrackerSet to this tracker

Specified by:
addTrackerSet in interface ISerializableTracker
Parameters:
trackerSetURI - to add to this tracker

getListeners

public java.util.Set<TrackerListener> getListeners()
Description copied from interface: ISerializableTracker
Get the TrackerListeners for this tracker

Specified by:
getListeners in interface ISerializableTracker
Returns:
the TrackerListeners for this tracker

getTrackerSets

public java.util.Set<org.openrdf.model.URI> getTrackerSets()
Description copied from interface: ISerializableTracker
Get the TrackerSets for this tracker

Specified by:
getTrackerSets in interface ISerializableTracker
Returns:
the TrackerSets for this tracker

removeTrackerSet

public void removeTrackerSet(org.openrdf.model.URI trackerSetURI)
Description copied from interface: ISerializableTracker
Remove a TrackerSet from this tracker

Specified by:
removeTrackerSet in interface ISerializableTracker
Parameters:
trackerSetURI - to remove from this tracker


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.