org.openrdf.rdf2go
Class RepositoryModelSet

java.lang.Object
  extended by org.ontoware.rdf2go.model.impl.AbstractModelSetImpl
      extended by org.openrdf.rdf2go.RepositoryModelSet
All Implemented Interfaces:
java.lang.Iterable<Statement>, ClosableIterable<Statement>, Commitable, FindableModelSet, Lockable, ModelSet, ModelSetAddRemove, ModelSetIO, ModelValueFactory, NamespaceSupport, ReificationSupport, Sparqlable

public class RepositoryModelSet
extends AbstractModelSetImpl

A ModelSet implementation for the OpenRDF (Sesame) 2.0.1 API. Note that RepositoryModel and RepositoryModelSet only work well together because they both keep their RepositoryConnections in auto-commit mode. This cannot be changed by the user. Do mass-updates using #update(Diff), addAll(Iterator) or removeAll(Iterator), then the current connection will be used in non-autocommit mode and commited, including a rollback when it fails.

Note: Every Model returned by this implementation should be explicitly closed by the user.


Constructor Summary
RepositoryModelSet(org.openrdf.repository.Repository repository)
           
 
Method Summary
 void addAll(java.util.Iterator<? extends Statement> iterator)
           
 boolean addModel(Model model)
           
 void addModel(Model model, URI contextURI)
           
 void addModelSet(ModelSet modelSet)
           
 void addStatement(Statement statement)
           
protected  void assertModel()
          same as model.assetModel()
 void close()
          Releases all resources held by the RepositoryModelSet.
 void commit()
           
 boolean contains(Statement s)
           
 boolean containsModel(URI contextURI)
           
 boolean containsStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 QuadPattern createQuadPattern(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 URI createURI(java.lang.String uriString)
           
 void dump()
           
 void finalize()
           
 ClosableIterator<Statement> findStatements(QuadPattern pattern)
           
 ClosableIterator<Statement> findStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 Model getDefaultModel()
           
 Model getModel(URI contextURI)
           
 ClosableIterator<Model> getModels()
           
 ClosableIterator<URI> getModelURIs()
           
 java.lang.String getNamespace(java.lang.String prefix)
           
 java.util.Map<java.lang.String,java.lang.String> getNamespaces()
           
 org.openrdf.repository.Repository getUnderlyingModelImplementation()
           
 org.openrdf.repository.Repository getUnderlyingModelSetImplementation()
           
 boolean isOpen()
          Returns whether the RepositoryModelSet is currently opened.
 ClosableIterator<Statement> iterator()
           
 void open()
          Prepares the RepositoryModelSet for operation.
 ClosableIterable<Statement> queryConstruct(java.lang.String queryString, java.lang.String queryLanguage)
           
 QueryResultTable querySelect(java.lang.String queryString, java.lang.String queryLanguage)
           
 void readFrom(java.io.InputStream in)
           
 void readFrom(java.io.InputStream in, Syntax syntax)
           
 void readFrom(java.io.InputStream in, Syntax syntax, java.lang.String baseURI)
           
 void readFrom(java.io.Reader reader)
           
 void readFrom(java.io.Reader reader, Syntax syntax)
           
 void readFrom(java.io.Reader reader, Syntax syntax, java.lang.String baseURI)
           
 void removeAll()
           
 void removeAll(java.util.Iterator<? extends Statement> iterator)
           
 boolean removeModel(URI contextURI)
           
 void removeNamespace(java.lang.String prefix)
           
 void removeStatement(Statement statement)
           
 void removeStatements(QuadPattern pattern)
           
 void removeStatements(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 void setAutocommit(boolean autocommit)
           
 void setNamespace(java.lang.String prefix, java.lang.String namespaceURI)
           
 void setUnderlyingModelSetImplementation(org.openrdf.repository.Repository repository)
           
 long size()
           
 boolean sparqlAsk(java.lang.String queryString)
           
 ClosableIterable<Statement> sparqlConstruct(java.lang.String queryString)
           
 ClosableIterable<Statement> sparqlDescribe(java.lang.String queryString)
           
 QueryResultTable sparqlSelect(java.lang.String queryString)
           
 void update(DiffReader diff)
           
 void writeTo(java.io.OutputStream out)
          Writes the whole ModelSet in TriX syntax to the OutputStream.
 void writeTo(java.io.OutputStream out, Syntax syntax)
          Writes the whole ModelSet to the OutputStream.
 void writeTo(java.io.Writer writer)
          Writes the whole ModelSet in TriX syntax to the writer.
 void writeTo(java.io.Writer writer, Syntax syntax)
          Writes the whole ModelSet to the Writer.
 
Methods inherited from class org.ontoware.rdf2go.model.impl.AbstractModelSetImpl
addReificationOf, addReificationOf, addStatement, countStatements, createBlankNode, createBlankNode, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createStatement, deleteReification, getAllReificationsOf, hasReifications, isEmpty, isLocked, isValidURI, lock, newRandomUniqueURI, removeStatement, serialize, unlock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryModelSet

public RepositoryModelSet(org.openrdf.repository.Repository repository)
                   throws ModelRuntimeException
Throws:
ModelRuntimeException
Method Detail

addAll

public void addAll(java.util.Iterator<? extends Statement> iterator)
            throws ModelRuntimeException
Specified by:
addAll in interface ModelSetAddRemove
Overrides:
addAll in class AbstractModelSetImpl
Throws:
ModelRuntimeException

addModel

public boolean addModel(Model model)
                 throws ModelRuntimeException
Specified by:
addModel in interface ModelSet
Overrides:
addModel in class AbstractModelSetImpl
Throws:
ModelRuntimeException

addModel

public void addModel(Model model,
                     URI contextURI)
              throws ModelRuntimeException
Specified by:
addModel in interface ModelSet
Overrides:
addModel in class AbstractModelSetImpl
Throws:
ModelRuntimeException

addModelSet

public void addModelSet(ModelSet modelSet)
                 throws ModelRuntimeException
Specified by:
addModelSet in interface ModelSet
Overrides:
addModelSet in class AbstractModelSetImpl
Throws:
ModelRuntimeException

addStatement

public void addStatement(Statement statement)
                  throws ModelRuntimeException
Throws:
ModelRuntimeException

close

public void close()
Releases all resources held by the RepositoryModelSet. After this, the effect and results of all other operations are undefined.


commit

public void commit()

contains

public boolean contains(Statement s)
                 throws ModelRuntimeException
Specified by:
contains in interface FindableModelSet
Overrides:
contains in class AbstractModelSetImpl
Throws:
ModelRuntimeException

containsModel

public boolean containsModel(URI contextURI)

containsStatements

public boolean containsStatements(UriOrVariable contextURI,
                                  ResourceOrVariable subject,
                                  UriOrVariable predicate,
                                  NodeOrVariable object)
                           throws ModelRuntimeException
Specified by:
containsStatements in interface FindableModelSet
Overrides:
containsStatements in class AbstractModelSetImpl
Throws:
ModelRuntimeException

createQuadPattern

public QuadPattern createQuadPattern(UriOrVariable context,
                                     ResourceOrVariable subject,
                                     UriOrVariable predicate,
                                     NodeOrVariable object)

createURI

public URI createURI(java.lang.String uriString)
              throws ModelRuntimeException
Specified by:
createURI in interface ModelSet
Specified by:
createURI in interface ModelValueFactory
Overrides:
createURI in class AbstractModelSetImpl
Throws:
ModelRuntimeException

dump

public void dump()
Specified by:
dump in interface ModelSet
Overrides:
dump in class AbstractModelSetImpl

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

findStatements

public ClosableIterator<Statement> findStatements(QuadPattern pattern)
                                           throws ModelRuntimeException
Specified by:
findStatements in interface FindableModelSet
Overrides:
findStatements in class AbstractModelSetImpl
Throws:
ModelRuntimeException

findStatements

public ClosableIterator<Statement> findStatements(UriOrVariable contextURI,
                                                  ResourceOrVariable subject,
                                                  UriOrVariable predicate,
                                                  NodeOrVariable object)
                                           throws ModelRuntimeException
Specified by:
findStatements in interface FindableModelSet
Overrides:
findStatements in class AbstractModelSetImpl
Throws:
ModelRuntimeException

getDefaultModel

public Model getDefaultModel()

getModel

public Model getModel(URI contextURI)

getModels

public ClosableIterator<Model> getModels()

getModelURIs

public ClosableIterator<URI> getModelURIs()

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)

getNamespaces

public java.util.Map<java.lang.String,java.lang.String> getNamespaces()

getUnderlyingModelImplementation

public org.openrdf.repository.Repository getUnderlyingModelImplementation()

getUnderlyingModelSetImplementation

public org.openrdf.repository.Repository getUnderlyingModelSetImplementation()

isOpen

public boolean isOpen()
Returns whether the RepositoryModelSet is currently opened.


iterator

public ClosableIterator<Statement> iterator()
Specified by:
iterator in interface java.lang.Iterable<Statement>
Specified by:
iterator in interface ClosableIterable<Statement>
Overrides:
iterator in class AbstractModelSetImpl

open

public void open()
Prepares the RepositoryModelSet for operation. Before opening, the result and effects of all other operations are undefined.


queryConstruct

public ClosableIterable<Statement> queryConstruct(java.lang.String queryString,
                                                  java.lang.String queryLanguage)
                                           throws QueryLanguageNotSupportedException,
                                                  ModelRuntimeException
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

querySelect

public QueryResultTable querySelect(java.lang.String queryString,
                                    java.lang.String queryLanguage)
                             throws QueryLanguageNotSupportedException,
                                    ModelRuntimeException
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream in)
              throws java.io.IOException,
                     ModelRuntimeException
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream in,
                     Syntax syntax)
              throws java.io.IOException,
                     ModelRuntimeException
Specified by:
readFrom in interface ModelSetIO
Overrides:
readFrom in class AbstractModelSetImpl
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream in,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws java.io.IOException,
                     ModelRuntimeException
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader reader)
              throws java.io.IOException,
                     ModelRuntimeException
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader reader,
                     Syntax syntax)
              throws java.io.IOException,
                     ModelRuntimeException
Specified by:
readFrom in interface ModelSetIO
Overrides:
readFrom in class AbstractModelSetImpl
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader reader,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws java.io.IOException,
                     ModelRuntimeException
Throws:
java.io.IOException
ModelRuntimeException

removeAll

public void removeAll()
               throws ModelRuntimeException
Specified by:
removeAll in interface ModelSet
Overrides:
removeAll in class AbstractModelSetImpl
Throws:
ModelRuntimeException

removeAll

public void removeAll(java.util.Iterator<? extends Statement> iterator)
               throws ModelRuntimeException
Specified by:
removeAll in interface ModelSetAddRemove
Overrides:
removeAll in class AbstractModelSetImpl
Throws:
ModelRuntimeException

removeModel

public boolean removeModel(URI contextURI)

removeNamespace

public void removeNamespace(java.lang.String prefix)

removeStatement

public void removeStatement(Statement statement)
                     throws ModelRuntimeException
Throws:
ModelRuntimeException

removeStatements

public void removeStatements(QuadPattern pattern)
                      throws ModelRuntimeException
Specified by:
removeStatements in interface ModelSetAddRemove
Overrides:
removeStatements in class AbstractModelSetImpl
Throws:
ModelRuntimeException

removeStatements

public void removeStatements(UriOrVariable context,
                             ResourceOrVariable subject,
                             UriOrVariable predicate,
                             NodeOrVariable object)
                      throws ModelRuntimeException
Specified by:
removeStatements in interface ModelSetAddRemove
Overrides:
removeStatements in class AbstractModelSetImpl
Throws:
ModelRuntimeException

setAutocommit

public void setAutocommit(boolean autocommit)

setNamespace

public void setNamespace(java.lang.String prefix,
                         java.lang.String namespaceURI)
                  throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

setUnderlyingModelSetImplementation

public void setUnderlyingModelSetImplementation(org.openrdf.repository.Repository repository)

size

public long size()
          throws ModelRuntimeException
Throws:
ModelRuntimeException

sparqlAsk

public boolean sparqlAsk(java.lang.String queryString)
                  throws ModelRuntimeException
Specified by:
sparqlAsk in interface Sparqlable
Overrides:
sparqlAsk in class AbstractModelSetImpl
Throws:
ModelRuntimeException

sparqlConstruct

public ClosableIterable<Statement> sparqlConstruct(java.lang.String queryString)
                                            throws ModelRuntimeException
Throws:
ModelRuntimeException

sparqlDescribe

public ClosableIterable<Statement> sparqlDescribe(java.lang.String queryString)
                                           throws ModelRuntimeException
Throws:
ModelRuntimeException

sparqlSelect

public QueryResultTable sparqlSelect(java.lang.String queryString)
                              throws ModelRuntimeException
Throws:
ModelRuntimeException

update

public void update(DiffReader diff)
            throws ModelRuntimeException
Specified by:
update in interface ModelSetAddRemove
Overrides:
update in class AbstractModelSetImpl
Throws:
ModelRuntimeException

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException,
                    ModelRuntimeException
Writes the whole ModelSet in TriX syntax to the OutputStream.

Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.OutputStream out,
                    Syntax syntax)
             throws java.io.IOException,
                    ModelRuntimeException
Writes the whole ModelSet to the OutputStream. Depending on the Syntax the context URIs might or might not be serialized. TriX should be able to serialize contexts.

Specified by:
writeTo in interface ModelSetIO
Overrides:
writeTo in class AbstractModelSetImpl
Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.Writer writer)
             throws java.io.IOException,
                    ModelRuntimeException
Writes the whole ModelSet in TriX syntax to the writer.

Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.Writer writer,
                    Syntax syntax)
             throws java.io.IOException,
                    ModelRuntimeException
Writes the whole ModelSet to the Writer. Depending on the Syntax the context URIs might or might not be serialized. TriX should be able to serialize contexts.

Specified by:
writeTo in interface ModelSetIO
Overrides:
writeTo in class AbstractModelSetImpl
Throws:
java.io.IOException
ModelRuntimeException

assertModel

protected void assertModel()
same as model.assetModel()



Copyright © 2001-2008 FZI. All Rights Reserved.