public class RepositoryModelSet extends AbstractModelSetImpl
update(DiffReader)
, 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 and Description |
---|
RepositoryModelSet(org.openrdf.repository.Repository repository) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Iterator<? extends Statement> iterator)
For each statement in the iterator, this method creates a Model named
statement.getContextURI if needed.
|
boolean |
addModel(Model model)
Adds a model to this ModelSet.
|
void |
addModel(Model model,
URI contextURI)
subclasses should overwrite this for performance reasons
|
void |
addModelSet(ModelSet modelSet)
Adds a complete
ModelSet to this ModelSet. |
void |
addStatement(Statement statement)
This method creates a Model named statement.getContextURI if needed.
|
protected void |
assertModel()
same as model.assetModel()
|
void |
close()
Releases all resources held by the RepositoryModelSet.
|
void |
commit()
Deprecated.
|
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(String uriString)
Creates an RDF2Go URI.
|
void |
dump()
Print the whole content of this ModelSet to System.out.
|
void |
finalize() |
ClosableIterator<Statement> |
findStatements(QuadPattern pattern)
Inefficient: Looks into each model and asks to match the triplepattern
part of the quad pattern.
|
ClosableIterator<Statement> |
findStatements(UriOrVariable contextURI,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
Search across all existing models
|
Model |
getDefaultModel()
The default model is used when the ModelSet is loaded from a
serialisation that has no context.
|
Model |
getModel(URI contextURI)
Get the Model with the passed URI.
|
ClosableIterator<Model> |
getModels() |
ClosableIterator<URI> |
getModelURIs() |
String |
getNamespace(String prefix) |
Map<String,String> |
getNamespaces()
Get all namespaces as a map of prefix to namespace.
|
org.openrdf.repository.Repository |
getUnderlyingModelImplementation() |
org.openrdf.repository.Repository |
getUnderlyingModelSetImplementation() |
boolean |
isOpen()
Returns whether the RepositoryModelSet is currently opened.
|
ClosableIterator<Statement> |
iterator()
Returns an iterator over a set of elements of type T.
|
ModelSet |
open()
Prepares the RepositoryModelSet for operation.
|
ClosableIterable<Statement> |
queryConstruct(String queryString,
String queryLanguage) |
QueryResultTable |
querySelect(String queryString,
String queryLanguage)
returns results for queries in other query languages as a
QueryResultTable as supported by underlying implementation.
|
void |
readFrom(InputStream in)
Read from InputStream assuming to read an TRiX stream.
|
void |
readFrom(InputStream in,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(InputStream in,
Syntax syntax,
String baseURI)
Reads assuming the given syntax.
|
void |
readFrom(Reader reader)
Read from Reader assuming to read a TRiX stream in UTF8 encoding.
|
void |
readFrom(Reader reader,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(Reader reader,
Syntax syntax,
String baseURI)
Reads assuming the given syntax.
|
void |
removeAll()
Removes all models, which is not the same as removing all
statements from all models in this ModelSet.
|
void |
removeAll(Iterator<? extends Statement> iterator)
For each statement in the iterator, the statement is removed form the
model named statement.getContext(); If the model named
statement.getContext() becomes empty, it remains in the ModelSet.
|
boolean |
removeModel(URI contextURI)
Removes the Model (NamedGraph) denoted by contextURI from this modelset.
|
void |
removeNamespace(String prefix)
Throws no exception if the prefix was not present.
|
void |
removeStatement(Statement statement)
Removes the statement (s,p,o) from a model named statement.getContext().
|
void |
removeStatements(QuadPattern pattern)
Find all models matching the context of the pattern and remove all
matching triple patterms from them
|
void |
removeStatements(UriOrVariable context,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
Find all models matching the context, and remove all (subject, property
,object)-statements from these model
|
void |
setAutocommit(boolean autocommit)
Deprecated.
|
void |
setNamespace(String prefix,
String namespaceURI) |
void |
setUnderlyingModelSetImplementation(org.openrdf.repository.Repository repository) |
long |
size()
The number of explicit statements.
|
boolean |
sparqlAsk(String queryString)
SPARQL ask queries
|
ClosableIterable<Statement> |
sparqlConstruct(String queryString) |
ClosableIterable<Statement> |
sparqlDescribe(String queryString)
Iterator must be auto-close, i.e.
|
QueryResultTable |
sparqlSelect(String queryString)
returns results for SPARQL Select queries, as supported by underlying
implementation.
|
void |
update(DiffReader diff)
Apply the changes given by this diff
|
void |
writeTo(OutputStream out)
Writes the whole ModelSet in TriX syntax to the OutputStream.
|
void |
writeTo(OutputStream out,
Syntax syntax)
Writes the whole ModelSet to the OutputStream.
|
void |
writeTo(Writer writer)
Writes the whole ModelSet in TriX syntax to the writer.
|
void |
writeTo(Writer writer,
Syntax syntax)
Writes the whole ModelSet to the Writer.
|
addReificationOf, addReificationOf, addStatement, countStatements, createBlankNode, createBlankNode, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createStatement, deleteReification, getAllReificationsOf, hasReifications, isEmpty, isLocked, isValidURI, lock, newRandomUniqueURI, removeStatement, serialize, unlock
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public RepositoryModelSet(org.openrdf.repository.Repository repository) throws ModelRuntimeException
ModelRuntimeException
public void addAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelSetAddRemove
addAll
in interface ModelSetAddRemove
addAll
in class AbstractModelSetImpl
ModelRuntimeException
- if any internal (I/O related) exception occurspublic boolean addModel(Model model) throws ModelRuntimeException
ModelSet
addModel
in interface ModelSet
addModel
in class AbstractModelSetImpl
ModelRuntimeException
public void addModel(Model model, URI contextURI) throws ModelRuntimeException
AbstractModelSetImpl
addModel
in interface ModelSet
addModel
in class AbstractModelSetImpl
ModelRuntimeException
- if any internal (I/O related) exception
occurspublic void addModelSet(ModelSet modelSet) throws ModelRuntimeException
ModelSet
ModelSet
to this ModelSet. Context URIs in the
Statement
s of the modelSet are respected.addModelSet
in interface ModelSet
addModelSet
in class AbstractModelSetImpl
ModelRuntimeException
- if any internal (I/O related) exception
occurspublic void addStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic void close()
@Deprecated public void commit()
Commitable
public boolean contains(Statement s) throws ModelRuntimeException
contains
in interface FindableModelSet
contains
in class AbstractModelSetImpl
s
- a StatementModelRuntimeException
public boolean containsModel(URI contextURI)
public boolean containsStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
containsStatements
in interface FindableModelSet
containsStatements
in class AbstractModelSetImpl
ModelRuntimeException
public QuadPattern createQuadPattern(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
public URI createURI(String uriString) throws ModelRuntimeException
ModelSet
createURI
in interface ModelSet
createURI
in interface ModelValueFactory
createURI
in class AbstractModelSetImpl
ModelRuntimeException
- if URI has not a valid URI format -
according to the adapterpublic void dump()
ModelSet
dump
in interface ModelSet
dump
in class AbstractModelSetImpl
public void finalize() throws Throwable
public ClosableIterator<Statement> findStatements(QuadPattern pattern) throws ModelRuntimeException
AbstractModelSetImpl
findStatements
in interface FindableModelSet
findStatements
in class AbstractModelSetImpl
ModelRuntimeException
public ClosableIterator<Statement> findStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
FindableModelSet
findStatements
in interface FindableModelSet
findStatements
in class AbstractModelSetImpl
ModelRuntimeException
public Model getDefaultModel()
ModelSet
public Model getModel(URI contextURI)
ModelSet
ModelSet.isOpen()
is false.
Note that the returned model is tied to this ModelSet
. Any
changes in the model will be reflected here, closing this ModelSet will
close the returned Model. To avoid side-effects, closing the returned
Model will NOT close this ModelSet. Closing the returned model will not
affect objects returned by previous calls to this method, hence this
method should always return a new copy of the Model object to allow
callers to close() a returned model.contextURI
- the URI of the context. This is the same as the name of
the named graph.public ClosableIterator<Model> getModels()
public ClosableIterator<URI> getModelURIs()
public String getNamespace(String prefix)
public Map<String,String> getNamespaces()
NamespaceSupport
public org.openrdf.repository.Repository getUnderlyingModelImplementation()
public org.openrdf.repository.Repository getUnderlyingModelSetImplementation()
public boolean isOpen()
public ClosableIterator<Statement> iterator()
ClosableIterable
iterator
in interface Iterable<Statement>
iterator
in interface ClosableIterable<Statement>
iterator
in class AbstractModelSetImpl
public ModelSet open()
public ClosableIterable<Statement> queryConstruct(String queryString, String queryLanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
QueryLanguageNotSupportedException
- if the adapter can't
understand the given query languageModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid construct
query in the given query languagepublic QueryResultTable querySelect(String queryString, String queryLanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
Sparqlable
QueryLanguageNotSupportedException
- if the given query langauge is
not supportedModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid query in the
given query languagepublic void readFrom(InputStream in) throws IOException, ModelRuntimeException
ModelSetIO
in
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorspublic void readFrom(InputStream in, Syntax syntax) throws IOException, ModelRuntimeException
ModelSetIO
readFrom
in interface ModelSetIO
readFrom
in class AbstractModelSetImpl
syntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxpublic void readFrom(InputStream in, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
ModelSetIO
syntax
- syntax to usebaseURI
- base URI to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxpublic void readFrom(Reader reader) throws IOException, ModelRuntimeException
ModelSetIO
reader
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader reader, Syntax syntax) throws IOException, ModelRuntimeException
ModelSetIO
readFrom
in interface ModelSetIO
readFrom
in class AbstractModelSetImpl
reader
- the input to readsyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxpublic void readFrom(Reader reader, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
ModelSetIO
reader
- the input to readsyntax
- syntax to usebaseURI
- baseURI to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxpublic void removeAll() throws ModelRuntimeException
ModelSet
removeAll
in interface ModelSet
removeAll
in class AbstractModelSetImpl
ModelRuntimeException
public void removeAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelSetAddRemove
removeAll
in interface ModelSetAddRemove
removeAll
in class AbstractModelSetImpl
ModelRuntimeException
- if any internal (I/O related) exception occurspublic boolean removeModel(URI contextURI)
ModelSet
public void removeNamespace(String prefix)
NamespaceSupport
public void removeStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
statement
- a StatementModelRuntimeException
- if any internal (I/O related) exception occurspublic void removeStatements(QuadPattern pattern) throws ModelRuntimeException
ModelSetAddRemove
removeStatements
in interface ModelSetAddRemove
removeStatements
in class AbstractModelSetImpl
ModelRuntimeException
public void removeStatements(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
ModelSetAddRemove
removeStatements
in interface ModelSetAddRemove
removeStatements
in class AbstractModelSetImpl
ModelRuntimeException
@Deprecated public void setAutocommit(boolean autocommit)
Commitable
autocommit
- If true, all changes are immediately written to the
underlying persistence layer, if any is used.public void setNamespace(String prefix, String namespaceURI) throws IllegalArgumentException
IllegalArgumentException
- if the given namespaceURI is not a valid URI in this
environment.public void setUnderlyingModelSetImplementation(org.openrdf.repository.Repository repository)
public long size() throws ModelRuntimeException
ModelSet
ModelSet
.ModelRuntimeException
public boolean sparqlAsk(String queryString) throws ModelRuntimeException
Sparqlable
sparqlAsk
in interface Sparqlable
sparqlAsk
in class AbstractModelSetImpl
queryString
- a SPARQL AKS queryModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL ASK
querypublic ClosableIterable<Statement> sparqlConstruct(String queryString) throws ModelRuntimeException
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
CONSTRUCT querypublic ClosableIterable<Statement> sparqlDescribe(String queryString) throws ModelRuntimeException
Sparqlable
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
DESCRIBE querypublic QueryResultTable sparqlSelect(String queryString) throws ModelRuntimeException
Sparqlable
queryString
- The SPARQL select query stringModelRuntimeException
- if an error happens when executing the
queryMalformedQueryException
- if the query is not a valid SPARQL SELECT
querypublic void update(DiffReader diff) throws ModelRuntimeException
ModelSetAddRemove
update
in interface ModelSetAddRemove
update
in class AbstractModelSetImpl
ModelRuntimeException
- if the ModelSet is lockedpublic void writeTo(OutputStream out) throws IOException, ModelRuntimeException
out
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(OutputStream out, Syntax syntax) throws IOException, ModelRuntimeException
writeTo
in interface ModelSetIO
writeTo
in class AbstractModelSetImpl
out
- the output to write tosyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxpublic void writeTo(Writer writer) throws IOException, ModelRuntimeException
writer
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer writer, Syntax syntax) throws IOException, ModelRuntimeException
writeTo
in interface ModelSetIO
writeTo
in class AbstractModelSetImpl
writer
- the output to write tosyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorsSyntaxNotSupportedException
- if adapter can't handle the given syntaxprotected void assertModel()
Copyright © 2005–2016 IT-Consulting Dr. Max V?lkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.