org.openrdf.sesame.sailimpl.memory
Class RdfSchemaRepository

java.lang.Object
  extended byorg.openrdf.sesame.sailimpl.memory.RdfSource
      extended byorg.openrdf.sesame.sailimpl.memory.RdfRepository
          extended byorg.openrdf.sesame.sailimpl.memory.RdfSchemaRepository
All Implemented Interfaces:
RdfRepository, RdfSchemaRepository, RdfSchemaSource, RdfSource, Sail, ValueFactory

public class RdfSchemaRepository
extends RdfRepository
implements RdfSchemaRepository

An implementation of the RdfSchemaRepository interface extending the memory repository with Schema inferencing capabilities.

Version:
$Revision: 1.19.2.4 $
Author:
Jeen Broekstra, Arjohn Kampman

Field Summary
 
Fields inherited from class org.openrdf.sesame.sailimpl.memory.RdfRepository
SYNC_DELAY_KEY
 
Fields inherited from class org.openrdf.sesame.sailimpl.memory.RdfSource
COMPRESS_FILE_KEY, DATA_FORMAT_KEY, FILE_KEY
 
Constructor Summary
RdfSchemaRepository()
           
 
Method Summary
 void addStatement(Resource subj, URI pred, Value obj)
          Adds a statament to the repository.
 void clearRepository()
          Clears the repository.
 void commitTransaction()
          Commits a started transaction.
 StatementIterator getClasses()
          Gets all defined classes.
 StatementIterator getDirectSubClassOf(Resource subClass, Resource superClass)
          Gets all direct subClassOf relations with a specific sub- and/or superclass.
 StatementIterator getDirectSubPropertyOf(Resource subProp, Resource superProp)
          Gets all direct subPropertyOf relations with a specific sub- and/or superproperty.
 StatementIterator getDirectType(Resource anInstance, Resource aClass)
          Gets all direct type relations with a specific instance and/or class.
 StatementIterator getDomain(Resource prop, Resource domain)
          Gets all domain relations with a specific property and/or domain class.
 StatementIterator getExplicitStatements(Resource subj, URI pred, Value obj)
          Gets all explicitly added statements with a specific subject, predicate and/or object.
 LiteralIterator getLiterals(String label, String language, URI datatype)
          Gets all literals with a specific label, language and/or datatype.
 StatementIterator getProperties()
          Gets all defined properties.
 StatementIterator getRange(Resource prop, Resource range)
          Gets all range relations with a specific property and/or range class.
 StatementIterator getStatements(Resource subj, URI pred, Value obj)
          Gets all statements with a specific subject, predicate and/or object.
 StatementIterator getStatements(Resource subj, URI pred, Value obj, boolean explicitOnly)
           
 StatementIterator getSubClassOf(Resource subClass, Resource superClass)
          Gets all subClassOf relations with a specific sub- and/or superclass.
 StatementIterator getSubPropertyOf(Resource subProperty, Resource superProperty)
          Gets all subPropertyOf relations with a specific sub- and/or superproperty.
 StatementIterator getType(Resource anInstance, Resource aClass)
          Gets all type relations with a specific instance and/or class.
 boolean hasExplicitStatement(Resource subj, URI pred, Value obj)
          Checks if an explicitly added statement with a specific subject, predicate and/or object is present in the repository.
 boolean hasStatement(Resource subj, URI pred, Value obj)
          Checks whether some statement with a specific subject, predicate and/or object is present in the repository.
 boolean hasStatement(Resource subj, URI pred, Value obj, boolean explicitOnly)
           
 void initialize(File file, RDFFormat dataFormat, boolean compressFile)
          Initializes this repository, using the specified file for persistent storage.
 boolean isClass(Resource resource)
          Checks whether the supplied resource represents a class.
 boolean isDirectSubClassOf(Resource subClass, Resource superClass)
          Checks whether one resource is a direct subclass of another.
 boolean isDirectSubPropertyOf(Resource subProperty, Resource superProperty)
          Checks whether one resource is a direct subproperty of another.
 boolean isDirectType(Resource anInstance, Resource aClass)
          Checks whether one resource is a direct instance of another.
 boolean isProperty(Resource resource)
          Checks whether the supplied resource represents a property.
 boolean isSubClassOf(Resource subClass, Resource superClass)
          Checks whether one resource is a subclass of another.
 boolean isSubPropertyOf(Resource subProperty, Resource superProperty)
          Checks whether one resource is a subproperty of another.
 boolean isType(Resource anInstance, Resource aClass)
          Checks whether one resource is an instance of another.
 int removeStatements(Resource subj, URI pred, Value obj)
          Removes data statements that match the (subject, predicate, object) pattern from the repository.
 
Methods inherited from class org.openrdf.sesame.sailimpl.memory.RdfRepository
addListener, changeNamespacePrefix, getSyncDelay, initialize, removeListener, setSyncDelay, shutDown, startTransaction, sync, transactionStarted
 
Methods inherited from class org.openrdf.sesame.sailimpl.memory.RdfSource
createBNode, createBNode, createLiteral, createLiteral, createLiteral, createStatement, createURI, createURI, getNamespaces, getValueFactory, initialize, optimizeQuery
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.sesame.sail.RdfSource
getNamespaces, getValueFactory, optimizeQuery
 
Methods inherited from interface org.openrdf.sesame.sail.Sail
initialize, shutDown
 
Methods inherited from interface org.openrdf.sesame.sail.RdfRepository
addListener, changeNamespacePrefix, removeListener, startTransaction, transactionStarted
 

Constructor Detail

RdfSchemaRepository

public RdfSchemaRepository()
Method Detail

initialize

public void initialize(File file,
                       RDFFormat dataFormat,
                       boolean compressFile)
                throws SailInitializationException
Description copied from class: RdfSource
Initializes this repository, using the specified file for persistent storage.

Overrides:
initialize in class RdfRepository
Throws:
SailInitializationException

getStatements

public StatementIterator getStatements(Resource subj,
                                       URI pred,
                                       Value obj)
Description copied from interface: RdfSource
Gets all statements with a specific subject, predicate and/or object. All three parameters may be null to indicate wildcards.

Specified by:
getStatements in interface RdfSource
Overrides:
getStatements in class RdfSource

hasStatement

public boolean hasStatement(Resource subj,
                            URI pred,
                            Value obj)
Description copied from interface: RdfSource
Checks whether some statement with a specific subject, predicate and/or object is present in the repository. All three parameters may be null to indicate wildcards.

Specified by:
hasStatement in interface RdfSource
Overrides:
hasStatement in class RdfSource

getExplicitStatements

public StatementIterator getExplicitStatements(Resource subj,
                                               URI pred,
                                               Value obj)
Description copied from interface: RdfSchemaSource
Gets all explicitly added statements with a specific subject, predicate and/or object. All of these parameters may be null to indicate wildcards.

Specified by:
getExplicitStatements in interface RdfSchemaSource
Parameters:
subj - subject of pattern
pred - predicate of pattern
obj - object of pattern
Returns:
iterator over statements
See Also:
RdfSource.getStatements(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value)

getStatements

public StatementIterator getStatements(Resource subj,
                                       URI pred,
                                       Value obj,
                                       boolean explicitOnly)

hasExplicitStatement

public boolean hasExplicitStatement(Resource subj,
                                    URI pred,
                                    Value obj)
Description copied from interface: RdfSchemaSource
Checks if an explicitly added statement with a specific subject, predicate and/or object is present in the repository. All of these parameters may be null to indicate wildcards.

Specified by:
hasExplicitStatement in interface RdfSchemaSource
Parameters:
subj - subject of statement
pred - predicate of statement
obj - object of statement
Returns:
boolean indicating if the specified statement is present.
See Also:
RdfSource.hasStatement(org.openrdf.model.Resource, org.openrdf.model.URI, org.openrdf.model.Value)

hasStatement

public boolean hasStatement(Resource subj,
                            URI pred,
                            Value obj,
                            boolean explicitOnly)

getClasses

public StatementIterator getClasses()
Description copied from interface: RdfSchemaSource
Gets all defined classes.

Specified by:
getClasses in interface RdfSchemaSource
Returns:
A StatementIterator containing statements of the form (someClass, rdf:type, rdfs:Class).

isClass

public boolean isClass(Resource resource)
Description copied from interface: RdfSchemaSource
Checks whether the supplied resource represents a class.

Specified by:
isClass in interface RdfSchemaSource
Parameters:
resource - A resource
Returns:
true if resource is a class, false otherwise.

getProperties

public StatementIterator getProperties()
Description copied from interface: RdfSchemaSource
Gets all defined properties.

Specified by:
getProperties in interface RdfSchemaSource
Returns:
A StatementIterator containing statements of the form (someProperty, rdf:type, rdf:Property).

isProperty

public boolean isProperty(Resource resource)
Description copied from interface: RdfSchemaSource
Checks whether the supplied resource represents a property.

Specified by:
isProperty in interface RdfSchemaSource
Parameters:
resource - A resource
Returns:
true if resource is a property, false otherwise.

getSubClassOf

public StatementIterator getSubClassOf(Resource subClass,
                                       Resource superClass)
Description copied from interface: RdfSchemaSource
Gets all subClassOf relations with a specific sub- and/or superclass. Note that the subClassOf relation is reflexive: a class is implicitly always a subclass of itself.

Specified by:
getSubClassOf in interface RdfSchemaSource
Parameters:
subClass - The subclass of the relations that should be returned, or null if relations with any subclass should be returned.
superClass - The superclass of the relations that should be returned, or null if relations with any superclass should be returned.
Returns:
A StatementIterator containing statements of the form (someSubClass, rdfs:subClassOf, someSuperClass).

isSubClassOf

public boolean isSubClassOf(Resource subClass,
                            Resource superClass)
Description copied from interface: RdfSchemaSource
Checks whether one resource is a subclass of another.

Specified by:
isSubClassOf in interface RdfSchemaSource
Parameters:
subClass - A class
superClass - A class
Returns:
true if subClass is a subclass of superClass, false otherwise.

getDirectSubClassOf

public StatementIterator getDirectSubClassOf(Resource subClass,
                                             Resource superClass)
Description copied from interface: RdfSchemaSource
Gets all direct subClassOf relations with a specific sub- and/or superclass. A class A is a direct subclass of class B if there is no class C such that A is a subclass of C and C is a subclass of B.

Specified by:
getDirectSubClassOf in interface RdfSchemaSource
Parameters:
subClass - The subclass of the relations that should be returned, or null if relations with any subclass should be returned.
superClass - The superclass of the relations that should be returned, or null if relations with any superclass should be returned.
Returns:
A StatementIterator containing statements of the form (someSubClass, rdfs:subClassOf, someSuperClass).

isDirectSubClassOf

public boolean isDirectSubClassOf(Resource subClass,
                                  Resource superClass)
Description copied from interface: RdfSchemaSource
Checks whether one resource is a direct subclass of another.

Specified by:
isDirectSubClassOf in interface RdfSchemaSource
Parameters:
subClass - A class
superClass - A class
Returns:
true if subClass is a direct subclass of superClass, false otherwise.

getSubPropertyOf

public StatementIterator getSubPropertyOf(Resource subProperty,
                                          Resource superProperty)
Description copied from interface: RdfSchemaSource
Gets all subPropertyOf relations with a specific sub- and/or superproperty. Note that the subPropertyOf relation is reflexive: a property is implicitly always a subproperty of itself.

Specified by:
getSubPropertyOf in interface RdfSchemaSource
Parameters:
subProperty - The subproperty of the relations that should be returned, or null if relations with any subproperty should be returned.
superProperty - The superproperty of the relations that should be returned, or null if relations with any superproperty should be returned.
Returns:
A StatementIterator containing statements of the form (someSubProperty, rdfs:subPropertyOf, someSuperProperty).

isSubPropertyOf

public boolean isSubPropertyOf(Resource subProperty,
                               Resource superProperty)
Description copied from interface: RdfSchemaSource
Checks whether one resource is a subproperty of another.

Specified by:
isSubPropertyOf in interface RdfSchemaSource
Parameters:
subProperty - A property
superProperty - A property
Returns:
true if subProperty is a subproperty of superProperty, false otherwise.

getDirectSubPropertyOf

public StatementIterator getDirectSubPropertyOf(Resource subProp,
                                                Resource superProp)
Description copied from interface: RdfSchemaSource
Gets all direct subPropertyOf relations with a specific sub- and/or superproperty. A property A is a direct subproperty of property B if there is no property C such that A is a subproperty of C and C is a subproperty of B.

Specified by:
getDirectSubPropertyOf in interface RdfSchemaSource
Parameters:
subProp - The subproperty of the relations that should be returned, or null if relations with any subproperty should be returned.
superProp - The superproperty of the relations that should be returned, or null if relations with any superproperty should be returned.
Returns:
A StatementIterator containing statements of the form (someSubProperty, rdfs:subPropertyOf, someSuperProperty).

isDirectSubPropertyOf

public boolean isDirectSubPropertyOf(Resource subProperty,
                                     Resource superProperty)
Description copied from interface: RdfSchemaSource
Checks whether one resource is a direct subproperty of another.

Specified by:
isDirectSubPropertyOf in interface RdfSchemaSource
Parameters:
subProperty - A property
superProperty - A property
Returns:
true if subProperty is a direct subproperty of superProperty, false otherwise.

getDomain

public StatementIterator getDomain(Resource prop,
                                   Resource domain)
Description copied from interface: RdfSchemaSource
Gets all domain relations with a specific property and/or domain class.

Specified by:
getDomain in interface RdfSchemaSource
Parameters:
prop - The property of the relations that should be returned, or null if relations with any property should be returned.
domain - The domain of the relations that should be returned, or null if relations with any domain should be returned.
Returns:
A StatementIterator containing statements of the form (someProperty, rdfs:domain, someClass).

getRange

public StatementIterator getRange(Resource prop,
                                  Resource range)
Description copied from interface: RdfSchemaSource
Gets all range relations with a specific property and/or range class.

Specified by:
getRange in interface RdfSchemaSource
Parameters:
prop - The property of the relations that should be returned, or null if relations with any property should be returned.
range - The range of the relations that should be returned, or null if relations with any range should be returned.
Returns:
A StatementIterator containing statements of the form (someProperty, rdfs:range, someClass).

getType

public StatementIterator getType(Resource anInstance,
                                 Resource aClass)
Description copied from interface: RdfSchemaSource
Gets all type relations with a specific instance and/or class.

Specified by:
getType in interface RdfSchemaSource
Parameters:
anInstance - The instance of the relations that should be returned, or null if relations with any instance should be returned.
aClass - The class of the relations that should be returned, or null if relations with any class should be returned.
Returns:
A StatementIterator containing statements of the form (someInstance, rdf:type, someClass).

isType

public boolean isType(Resource anInstance,
                      Resource aClass)
Description copied from interface: RdfSchemaSource
Checks whether one resource is an instance of another.

Specified by:
isType in interface RdfSchemaSource
Parameters:
anInstance - An instance
aClass - A class
Returns:
true if anInstance is a instance of aClass, false otherwise.

getDirectType

public StatementIterator getDirectType(Resource anInstance,
                                       Resource aClass)
Description copied from interface: RdfSchemaSource
Gets all direct type relations with a specific instance and/or class.

Specified by:
getDirectType in interface RdfSchemaSource
Parameters:
anInstance - The instance of the relations that should be returned, or null if relations with any instance should be returned.
aClass - The class of the relations that should be returned, or null if relations with any class should be returned.
Returns:
A StatementIterator containing statements of the form (someInstance, rdf:type, someClass).

isDirectType

public boolean isDirectType(Resource anInstance,
                            Resource aClass)
Description copied from interface: RdfSchemaSource
Checks whether one resource is a direct instance of another.

Specified by:
isDirectType in interface RdfSchemaSource
Parameters:
anInstance - An instance
aClass - A class
Returns:
true if anInstance is a direct instance of aClass, false otherwise.

getLiterals

public LiteralIterator getLiterals(String label,
                                   String language,
                                   URI datatype)
Description copied from interface: RdfSchemaSource
Gets all literals with a specific label, language and/or datatype.

Specified by:
getLiterals in interface RdfSchemaSource
Parameters:
label - The label of the literals that should be returned, or null if literals with any label should be returned.
language - The language of the literals that should be returned, or null if literals with any language should be returned.
datatype - The datatype of the literals that should be returned, or null if literals with any datatype should be returned.
Returns:
A LiteralIterator containing literals that match the specified pattern.

commitTransaction

public void commitTransaction()
Description copied from interface: RdfRepository
Commits a started transaction. A transaction needs to be commited to be guaranteed that data has been added to, or removed from the repository.

Specified by:
commitTransaction in interface RdfRepository
Overrides:
commitTransaction in class RdfRepository

addStatement

public void addStatement(Resource subj,
                         URI pred,
                         Value obj)
                  throws SailUpdateException
Description copied from interface: RdfRepository
Adds a statament to the repository. You must start a transaction before this method can be used.

Specified by:
addStatement in interface RdfRepository
Overrides:
addStatement in class RdfRepository
Throws:
SailUpdateException

removeStatements

public int removeStatements(Resource subj,
                            URI pred,
                            Value obj)
                     throws SailUpdateException
Description copied from interface: RdfRepository
Removes data statements that match the (subject, predicate, object) pattern from the repository. All three parameters may be null to indicate wildcards. You must start a transaction before this method can be used.

Specified by:
removeStatements in interface RdfRepository
Overrides:
removeStatements in class RdfRepository
Throws:
SailUpdateException

clearRepository

public void clearRepository()
                     throws SailUpdateException
Description copied from interface: RdfRepository
Clears the repository. After the repository was cleared, it will be in the same state as after initialization. You must start a transaction before this method can be used.

Specified by:
clearRepository in interface RdfRepository
Overrides:
clearRepository in class RdfRepository
Throws:
SailUpdateException


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.