org.ontoware.rdf2go.model
Interface ModelSet

All Superinterfaces:
ClosableIterable<Statement>, Commitable, FindableModelSet, java.lang.Iterable<Statement>, Lockable, ModelSetAddRemove, ModelSetIO, ModelValueFactory, NamespaceSupport, ReificationSupport, Sparqlable

public interface ModelSet
extends Sparqlable, ModelSetIO, FindableModelSet, ModelSetAddRemove, ModelValueFactory, Commitable, ReificationSupport, NamespaceSupport

A ModelSet is like a Graph Data Set in SPARQL. It contains a number of named graphs (Models), which might be empty. Additionally, one special unnamed model, the 'Default Model' belongs to a ModelSet. ModelSet offers a number of methods that make it behave like a quad store, however, when e.g. removing all statements with a certain context, the model named with that context still remains in the ModelSet.

ModelSet can be read from a named graph aware serialization such as TRIG or TRIX using the read/write methods. If you read a serialization that supports only one graph (like RDF/XML), a default model will be created.

The context URI of the default modell is 'null'.

Author:
max, sauermann

Method Summary
 boolean addModel(Model model)
          Adds a model to this ModelSet.
 void addModel(Model model, URI contextURI)
          Adds a complete Model to the given contextURI.
 void addModelSet(ModelSet modelSet)
          Adds a complete ModelSet to this ModelSet.
 void close()
          Close connection to defined, unterlying implementation
 boolean containsModel(URI contextURI)
           
 Statement createStatement(URI context, Resource subject, URI predicate, Node object)
          Creates a statement with a context URI.
 URI createURI(java.lang.String uriString)
          Creates an RDF2Go URI.
 void dump()
          Print the whole content of this ModelSet to System.out.
 Model getDefaultModel()
          The default model is used when the modelset is loaded from a serialization that has no context.
 Model getModel(URI contextURI)
          Get the Model with the passed URI.
 ClosableIterator<Model> getModels()
           
 ClosableIterator<URI> getModelURIs()
           
 java.lang.Object getUnderlyingModelSetImplementation()
           
 boolean isEmpty()
           
 boolean isOpen()
           
 void open()
          Open connection to defined, unterlying implementation
 void removeAll()
          Removes all models, which is not the same as removing all statements from all models in this ModelSet.
 boolean removeModel(URI contextURI)
          Removes the Model (NamedGraph) denoted by contextURI from this modelset.
 long size()
          The number of explicit statements.
 
Methods inherited from interface org.ontoware.rdf2go.model.Sparqlable
queryConstruct, querySelect, sparqlAsk, sparqlConstruct, sparqlDescribe, sparqlSelect
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelSetIO
readFrom, readFrom, readFrom, readFrom, readFrom, readFrom, serialize, writeTo, writeTo, writeTo, writeTo
 
Methods inherited from interface org.ontoware.rdf2go.model.FindableModelSet
contains, containsStatements, countStatements, createQuadPattern, findStatements, findStatements
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelSetAddRemove
addAll, addStatement, addStatement, removeAll, removeStatement, removeStatement, removeStatements, removeStatements, update
 
Methods inherited from interface org.ontoware.aifbcommons.collection.ClosableIterable
iterator
 
Methods inherited from interface org.ontoware.rdf2go.model.Lockable
isLocked, lock, unlock
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelValueFactory
createBlankNode, createBlankNode, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, isValidURI, newRandomUniqueURI
 
Methods inherited from interface org.ontoware.rdf2go.model.Commitable
commit, setAutocommit
 
Methods inherited from interface org.ontoware.rdf2go.model.ReificationSupport
addReificationOf, addReificationOf, deleteReification, getAllReificationsOf, hasReifications
 
Methods inherited from interface org.ontoware.rdf2go.model.NamespaceSupport
getNamespace, getNamespaces, removeNamespace, setNamespace
 

Method Detail

open

void open()
Open connection to defined, unterlying implementation


isOpen

boolean isOpen()
Returns:
true if ModelSet is open

close

void close()
Close connection to defined, unterlying implementation


size

long size()
          throws ModelRuntimeException
The number of explicit statements. Statements that are inferred e.g. using backward-chaining are per definition not in this number, and also some inferred stateemtns may or may be not part of ths size, depending on the implementation of the model. If a new triple is added to the model, the size must increase.

Returns:
the number of statements in the modelset.
Throws:
ModelRuntimeException

isEmpty

boolean isEmpty()
Returns:
true if all models in this ModelSet contain zero statements. This method might be faster than calling size() == 0 on each model. Note: This method can return isEmpty == true, even if the ModelSet contains a number of models.

createURI

URI createURI(java.lang.String uriString)
              throws ModelRuntimeException
Creates an RDF2Go URI. This allows a user to create a model via 'getModel( URI )'.

Specified by:
createURI in interface ModelValueFactory
Parameters:
uriString -
Returns:
an RDF2Go URI
Throws:
ModelRuntimeException - if URI has not a valid URI fomat - according to the adapter

createStatement

Statement createStatement(URI context,
                          Resource subject,
                          URI predicate,
                          Node object)
Creates a statement with a context URI.

Parameters:
context -
subject -
predicate -
object -
Returns:

getModel

Model getModel(URI contextURI)
Get the Model with the passed URI. If the model does not exist yet, an empty model will be created and returned. Note that the returned model is tied to this modelset, and any changes in the model will be reflected here.

Parameters:
contextURI - the URI of the context. This is the same as the name of the named graph.
Returns:
the model identified by this context. May have a size of 0, if no data was added to it yet. Never returns null. It has to be isOpen() == true.

removeModel

boolean removeModel(URI contextURI)
Removes the Model (NamedGraph) denoted by contextURI from this modelset. If the model contains statements, they are deleted.

Parameters:
contextURI -
Returns:
true if successful

addModel

boolean addModel(Model model)
Adds a model to this ModelSet. Creating the named-graph if needed, adding the triples to it if not. Same semantics as: ModelSet.getModel(model.getContextUri).add(model). Note: This method might be much quicker than addAll(model.iterator()) depending on the implementation.

Parameters:
model -
Returns:
true if successful

addModel

void addModel(Model model,
              URI contextURI)
              throws ModelRuntimeException
Adds a complete Model to the given contextURI. The context URI of the model is ignored.

Parameters:
contextURI -
model -
Throws:
ModelRuntimeException - if any internal (I/O related) exception occurs
Since:
4.6

addModelSet

void addModelSet(ModelSet modelSet)
                 throws ModelRuntimeException
Adds a complete ModelSet to this ModelSet. Context URIs in the Statements of the modelSet are respected.

Parameters:
contextURI -
modelSet -
Throws:
ModelRuntimeException - if any internal (I/O related) exception occurs
Since:
4.6

containsModel

boolean containsModel(URI contextURI)
Parameters:
contextURI -
Returns:
true if a Model (NamedGraph) named 'contextURI' is known. The model might be empty. Some implementations don't manage models explicitly, here empty models cna never exist.

removeAll

void removeAll()
               throws ModelRuntimeException
Removes all models, which is not the same as removing all statements from all models in this ModelSet.

Throws:
ModelRuntimeException

getDefaultModel

Model getDefaultModel()
The default model is used when the modelset is loaded from a serialization that has no context. The default model has a context of 'null'

Returns:
the default model. It has to be isOpen() == true.

getModels

ClosableIterator<Model> getModels()
Returns:
an Interator over all models within this ModelSet. Some models might be empty. Since 4.4.10: Each model has to be isOpen() == true. For some implementations: While you read the iterator you may not WRITE to the models.

getModelURIs

ClosableIterator<URI> getModelURIs()
Returns:
an iterator over all URIs used as model URIs. For some implementations: While you read the iterator you may not WRITE to the models.

getUnderlyingModelSetImplementation

java.lang.Object getUnderlyingModelSetImplementation()
Returns:
the native implementation (e.g. a Jena Model). Using this method breaks strict triple store independence, but exposes the full power and reduces API dependence. This method is part of the main API.

dump

void dump()
Print the whole content of this ModelSet to System.out.



Copyright © 2005-2008 FZI - Forschungszentrum Informatik | Karlsruhe | Germany. All Rights Reserved.