edu.stanford.smi.protegex.owl.model.triplestore.impl
Class AbstractTripleStore

java.lang.Object
  extended byedu.stanford.smi.protegex.owl.model.triplestore.impl.AbstractTripleStore
All Implemented Interfaces:
NamespaceMap, ProtegeTripleAdder, TripleStore
Direct Known Subclasses:
DatabaseTripleStore, JenaTripleStore

public abstract class AbstractTripleStore
extends Object
implements ProtegeTripleAdder, TripleStore

A TripleStore that acts as a view on an existing NarrowFrameStore.

Author:
Holger Knublauch

Field Summary
private  Map addPropertyValueHandlers
           
private  edu.stanford.smi.protege.model.Slot directInstancesSlot
           
private  edu.stanford.smi.protege.model.Slot directTypesSlot
           
protected  edu.stanford.smi.protege.model.framestore.NarrowFrameStore frameStore
           
protected  edu.stanford.smi.protege.model.Slot nameSlot
           
protected  OWLModel owlModel
           
protected  TripleStoreModel tripleStoreModel
           
 
Constructor Summary
AbstractTripleStore(OWLModel owlModel, TripleStoreModel tripleStoreModel, edu.stanford.smi.protege.model.framestore.NarrowFrameStore frameStore)
           
 
Method Summary
 void add(RDFResource subject, RDFProperty predicate, Object object)
           
 void add(Triple triple)
           
 boolean addValue(edu.stanford.smi.protege.model.Instance subject, edu.stanford.smi.protege.model.Slot slot, Object object)
           
 void addValueFast(edu.stanford.smi.protege.model.Instance subject, edu.stanford.smi.protege.model.Slot slot, Object object)
           
 boolean contains(RDFResource subject, RDFProperty predicate, Object object)
           
 boolean contains(Triple triple)
           
 void dump()
          Debugging only.
 String getDefaultNamespace()
           
 RDFResource getHomeResource(String name)
           
 String getName()
           
 String getNamespaceForPrefix(String prefix)
           
 edu.stanford.smi.protege.model.framestore.NarrowFrameStore getNarrowFrameStore()
          Provides access to the internal Protege storage for low-level access.
 String getPrefix(String namespace)
           
 Collection getPrefixes()
           
protected  Collection getReferences(Object search)
           
 Collection getSlotValues(edu.stanford.smi.protege.model.Instance instance, edu.stanford.smi.protege.model.Slot slot)
           
protected  Collection getValues(edu.stanford.smi.protege.model.Instance instance, edu.stanford.smi.protege.model.Slot slot)
           
private  void initAACHandler(String propertyName, String clsName, Class clazz)
           
private  void initHandler(String propertyName, AddPropertyValueHandler handler)
           
 Iterator listHomeResources()
          Gets all resources that have their "home" in this triple store.
 Iterator listObjects(RDFResource subject, RDFProperty property)
          Gets the values of a given subject/property combination.
 Iterator listSubjects(RDFProperty property)
          The the subjects of all triples where a given property has any value.
 Iterator listSubjects(RDFProperty predicate, Object object)
          Gets the subjects of all triples with a given predicate and object.
 Iterator listTriplesWithObject(RDFObject object)
          Lists all Triples that have a given object.
 Iterator listTriplesWithSubject(RDFResource subject)
          Lists all Triples that have a given subject.
 void remove(RDFResource subject, RDFProperty predicate, Object object)
           
 void remove(Triple triple)
           
private  void removeDirectType(RDFResource subject, Object object)
           
 void removePrefix(String prefix)
           
protected  void removeValue(edu.stanford.smi.protege.model.Instance subject, edu.stanford.smi.protege.model.Slot slot, Object value)
           
 void setDefaultNamespace(String value)
           
 void setDefaultNamespace(URI uri)
           
 void setName(String value)
           
 void setPrefix(String namespace, String prefix)
           
 void setPrefix(URI namespace, String prefix)
           
 void setRDFResourceName(RDFResource resource, String name)
           
 void sortPropertyValues(RDFResource resource, RDFProperty property, Comparator comparator)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.stanford.smi.protegex.owl.model.triplestore.TripleStore
listTriples
 

Field Detail

addPropertyValueHandlers

private Map addPropertyValueHandlers

directInstancesSlot

private edu.stanford.smi.protege.model.Slot directInstancesSlot

directTypesSlot

private edu.stanford.smi.protege.model.Slot directTypesSlot

frameStore

protected edu.stanford.smi.protege.model.framestore.NarrowFrameStore frameStore

nameSlot

protected edu.stanford.smi.protege.model.Slot nameSlot

owlModel

protected OWLModel owlModel

tripleStoreModel

protected TripleStoreModel tripleStoreModel
Constructor Detail

AbstractTripleStore

public AbstractTripleStore(OWLModel owlModel,
                           TripleStoreModel tripleStoreModel,
                           edu.stanford.smi.protege.model.framestore.NarrowFrameStore frameStore)
Method Detail

add

public void add(Triple triple)
Specified by:
add in interface TripleStore

add

public void add(RDFResource subject,
                RDFProperty predicate,
                Object object)
Specified by:
add in interface TripleStore

addValue

public boolean addValue(edu.stanford.smi.protege.model.Instance subject,
                        edu.stanford.smi.protege.model.Slot slot,
                        Object object)
Specified by:
addValue in interface ProtegeTripleAdder

addValueFast

public void addValueFast(edu.stanford.smi.protege.model.Instance subject,
                         edu.stanford.smi.protege.model.Slot slot,
                         Object object)
Specified by:
addValueFast in interface ProtegeTripleAdder

contains

public boolean contains(Triple triple)
Specified by:
contains in interface TripleStore

contains

public boolean contains(RDFResource subject,
                        RDFProperty predicate,
                        Object object)
Specified by:
contains in interface TripleStore

getDefaultNamespace

public String getDefaultNamespace()
Specified by:
getDefaultNamespace in interface NamespaceMap

getName

public String getName()
Specified by:
getName in interface TripleStore

getHomeResource

public RDFResource getHomeResource(String name)
Specified by:
getHomeResource in interface TripleStore

getNamespaceForPrefix

public String getNamespaceForPrefix(String prefix)
Specified by:
getNamespaceForPrefix in interface NamespaceMap

getNarrowFrameStore

public edu.stanford.smi.protege.model.framestore.NarrowFrameStore getNarrowFrameStore()
Description copied from interface: TripleStore
Provides access to the internal Protege storage for low-level access. This method should only be used by experienced users.

Specified by:
getNarrowFrameStore in interface TripleStore
Returns:
the NarrowFrameStore

getSlotValues

public Collection getSlotValues(edu.stanford.smi.protege.model.Instance instance,
                                edu.stanford.smi.protege.model.Slot slot)
Specified by:
getSlotValues in interface ProtegeTripleAdder

getValues

protected Collection getValues(edu.stanford.smi.protege.model.Instance instance,
                               edu.stanford.smi.protege.model.Slot slot)

getPrefix

public String getPrefix(String namespace)
Specified by:
getPrefix in interface NamespaceMap

getPrefixes

public Collection getPrefixes()
Specified by:
getPrefixes in interface NamespaceMap

getReferences

protected Collection getReferences(Object search)

initAACHandler

private void initAACHandler(String propertyName,
                            String clsName,
                            Class clazz)

initHandler

private void initHandler(String propertyName,
                         AddPropertyValueHandler handler)

listHomeResources

public Iterator listHomeResources()
Description copied from interface: TripleStore
Gets all resources that have their "home" in this triple store. The home is defined to be the TripleStore with the :NAME value of the resource.

Specified by:
listHomeResources in interface TripleStore
Returns:
an Iterator of RDFResources

listObjects

public Iterator listObjects(RDFResource subject,
                            RDFProperty property)
Description copied from interface: TripleStore
Gets the values of a given subject/property combination.

Specified by:
listObjects in interface TripleStore
Parameters:
subject -
property -
Returns:
a Collection of Objects (e.g. RDFResources)

listSubjects

public Iterator listSubjects(RDFProperty property)
Description copied from interface: TripleStore
The the subjects of all triples where a given property has any value. The Iterator does not contain duplicates.

Specified by:
listSubjects in interface TripleStore
Parameters:
property - the property to look for
Returns:
an Iterator of RDFResources

listSubjects

public Iterator listSubjects(RDFProperty predicate,
                             Object object)
Description copied from interface: TripleStore
Gets the subjects of all triples with a given predicate and object.

Specified by:
listSubjects in interface TripleStore
Parameters:
predicate - the predicate to match
object - the object to match
Returns:
an Iterator of RDFResources

listTriplesWithObject

public Iterator listTriplesWithObject(RDFObject object)
Description copied from interface: TripleStore
Lists all Triples that have a given object.

Specified by:
listTriplesWithObject in interface TripleStore
Parameters:
object - the object to get the triples of
Returns:
an Iterator of Triples

listTriplesWithSubject

public Iterator listTriplesWithSubject(RDFResource subject)
Description copied from interface: TripleStore
Lists all Triples that have a given subject. In other words, this returns all property-value pairs of a given resource. Note that this operation is currently not efficiently implemented.

Specified by:
listTriplesWithSubject in interface TripleStore
Parameters:
subject - the subject in the triples
Returns:
an Iterator of Triples

remove

public void remove(Triple triple)
Specified by:
remove in interface TripleStore

remove

public void remove(RDFResource subject,
                   RDFProperty predicate,
                   Object object)
Specified by:
remove in interface TripleStore

setName

public void setName(String value)
Specified by:
setName in interface TripleStore

removeDirectType

private void removeDirectType(RDFResource subject,
                              Object object)

removePrefix

public void removePrefix(String prefix)
Specified by:
removePrefix in interface NamespaceMap

removeValue

protected void removeValue(edu.stanford.smi.protege.model.Instance subject,
                           edu.stanford.smi.protege.model.Slot slot,
                           Object value)

setDefaultNamespace

public void setDefaultNamespace(String value)
Specified by:
setDefaultNamespace in interface NamespaceMap

setDefaultNamespace

public void setDefaultNamespace(URI uri)
Specified by:
setDefaultNamespace in interface NamespaceMap

setPrefix

public void setPrefix(String namespace,
                      String prefix)
Specified by:
setPrefix in interface NamespaceMap

setPrefix

public void setPrefix(URI namespace,
                      String prefix)
Specified by:
setPrefix in interface NamespaceMap

setRDFResourceName

public void setRDFResourceName(RDFResource resource,
                               String name)
Specified by:
setRDFResourceName in interface TripleStore

sortPropertyValues

public void sortPropertyValues(RDFResource resource,
                               RDFProperty property,
                               Comparator comparator)
Specified by:
sortPropertyValues in interface TripleStore

toString

public String toString()

dump

public void dump()
Description copied from interface: TripleStore
Debugging only.

Specified by:
dump in interface TripleStore