public class DelegatingModelSet extends AbstractModelSetImpl implements ModelSet
Modifier and Type | Field and Description |
---|---|
protected ModelSet |
baseModelSet |
Constructor and Description |
---|
DelegatingModelSet(ModelSet baseModelSet) |
Modifier and Type | Method and Description |
---|---|
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. |
BlankNode |
addReificationOf(Statement statement)
A convenience function for addReficationOf( createBlankNode(), statement
);
|
Resource |
addReificationOf(Statement statement,
Resource resource)
Reifies the statement, whether the statement was present in the model or
not.
|
void |
addStatement(Statement statement)
This method creates a Model named statement.getContextURI if needed.
|
void |
close()
Close connection of the underlying implementation
|
void |
commit()
Deprecated.
|
boolean |
containsModel(URI contextURI) |
boolean |
containsStatements(UriOrVariable contextURI,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object) |
BlankNode |
createBlankNode(String internalID)
Create a new blank node with the given internal ID.
|
QuadPattern |
createQuadPattern(UriOrVariable context,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object) |
URI |
createURI(String uriString)
Creates an RDF2Go URI.
|
void |
deleteReification(Resource reificationResource)
Delete reifications made by this resource.
|
ClosableIterator<Statement> |
findStatements(UriOrVariable contextURI,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
Search across all existing models
|
Collection<Resource> |
getAllReificationsOf(Statement statement) |
Model |
getDefaultModel()
The default model is used when the ModelSet is loaded from a
serialisation that has no context.
|
ModelSet |
getDelegatedModelSet() |
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.
|
Object |
getUnderlyingModelImplementation()
Deprecated.
|
Object |
getUnderlyingModelSetImplementation() |
boolean |
hasReifications(Statement stmt) |
boolean |
isEmpty()
sublcasses should override this method for performance
|
boolean |
isOpen() |
ModelSet |
open()
Open connection to the underlying implementation
|
ClosableIterable<Statement> |
queryConstruct(String query,
String querylanguage) |
QueryResultTable |
querySelect(String query,
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 reader,
Syntax syntax,
String baseURI)
Reads assuming the given syntax.
|
void |
readFrom(Reader in)
Read from Reader assuming to read a TRiX stream in UTF8 encoding.
|
void |
readFrom(Reader in,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(Reader in,
Syntax syntax,
String baseURI)
Reads assuming the given syntax.
|
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 |
setAutocommit(boolean autocommit)
Deprecated.
|
void |
setNamespace(String prefix,
String namespaceURI) |
long |
size()
The number of explicit statements.
|
boolean |
sparqlAsk(String query)
SPARQL ask queries
|
ClosableIterable<Statement> |
sparqlConstruct(String query) |
ClosableIterable<Statement> |
sparqlDescribe(String query)
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)
Writing a TRiX stream in UTF8 encoding For more info on TRiX read:
http://www.hpl.hp.com/techreports/2003/HPL-2003-268.html
|
void |
writeTo(OutputStream out,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
void |
writeTo(Writer out)
Write to writer in UTF8 and TRiX.
|
void |
writeTo(Writer out,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
addAll, addStatement, contains, countStatements, createBlankNode, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createStatement, dump, findStatements, isLocked, isValidURI, iterator, lock, newRandomUniqueURI, removeAll, removeAll, removeStatement, removeStatements, removeStatements, serialize, unlock
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createStatement, dump, removeAll
serialize
contains, countStatements, findStatements
addAll, addStatement, removeAll, removeStatement, removeStatements, removeStatements
iterator
forEach, spliterator
createBlankNode, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, isValidURI, newRandomUniqueURI
protected ModelSet baseModelSet
public DelegatingModelSet(ModelSet baseModelSet)
public boolean addModel(Model model)
ModelSet
addModel
in interface ModelSet
addModel
in class AbstractModelSetImpl
public void addStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
addStatement
in interface ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic void close()
ModelSet
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)
createQuadPattern
in interface FindableModelSet
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 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
getDefaultModel
in interface ModelSet
public ModelSet getDelegatedModelSet()
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.getModel
in interface ModelSet
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()
getModelURIs
in interface ModelSet
@Deprecated public Object getUnderlyingModelImplementation()
public Object getUnderlyingModelSetImplementation()
getUnderlyingModelSetImplementation
in interface ModelSet
public boolean isOpen()
public ModelSet open()
ModelSet
public ClosableIterable<Statement> queryConstruct(String query, String querylanguage) throws QueryLanguageNotSupportedException, MalformedQueryException, ModelRuntimeException
queryConstruct
in interface Sparqlable
QueryLanguageNotSupportedException
- if the adapter can't
understand the given query languageMalformedQueryException
- if the query is not a valid construct
query in the given query languageModelRuntimeException
- if the execution throws an exceptionpublic QueryResultTable querySelect(String query, String querylanguage) throws QueryLanguageNotSupportedException, MalformedQueryException, ModelRuntimeException
Sparqlable
querySelect
in interface Sparqlable
QueryLanguageNotSupportedException
- if the given query langauge is
not supportedMalformedQueryException
- if the query is not a valid query in the
given query languageModelRuntimeException
- if the execution throws an exceptionpublic void readFrom(InputStream in) throws IOException, ModelRuntimeException
ModelSetIO
readFrom
in interface ModelSetIO
in
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorspublic void readFrom(InputStream in, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
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(Reader in) throws IOException, ModelRuntimeException
ModelSetIO
readFrom
in interface ModelSetIO
in
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader in, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
readFrom
in interface ModelSetIO
readFrom
in class AbstractModelSetImpl
in
- 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 removeStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
removeStatement
in interface ModelSetAddRemove
statement
- a StatementModelRuntimeException
- if any internal (I/O related) exception occurspublic long size() throws ModelRuntimeException
ModelSet
size
in interface ModelSet
ModelSet
.ModelRuntimeException
public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException
Sparqlable
sparqlAsk
in interface Sparqlable
sparqlAsk
in class AbstractModelSetImpl
query
- a SPARQL AKS queryModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL ASK
querypublic ClosableIterable<Statement> sparqlConstruct(String query) throws ModelRuntimeException, MalformedQueryException
sparqlConstruct
in interface Sparqlable
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
CONSTRUCT querypublic ClosableIterable<Statement> sparqlDescribe(String query) throws ModelRuntimeException
Sparqlable
sparqlDescribe
in interface Sparqlable
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
DESCRIBE querypublic QueryResultTable sparqlSelect(String queryString) throws MalformedQueryException, ModelRuntimeException
Sparqlable
sparqlSelect
in interface Sparqlable
queryString
- The SPARQL select query stringMalformedQueryException
- if the query is not a valid SPARQL SELECT
queryModelRuntimeException
- if an error happens when executing the
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
ModelSetIO
writeTo
in interface ModelSetIO
out
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(OutputStream out, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
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 out) throws IOException, ModelRuntimeException
ModelSetIO
writeTo
in interface ModelSetIO
out
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer out, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
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 boolean isEmpty()
AbstractModelSetImpl
isEmpty
in interface ModelSet
isEmpty
in class AbstractModelSetImpl
public boolean containsModel(URI contextURI)
containsModel
in interface ModelSet
public boolean removeModel(URI contextURI)
ModelSet
removeModel
in interface ModelSet
public BlankNode createBlankNode(String internalID)
ModelValueFactory
createBlankNode
in interface ModelValueFactory
createBlankNode
in class AbstractModelSetImpl
@Deprecated public void commit()
Commitable
commit
in interface Commitable
@Deprecated public void setAutocommit(boolean autocommit)
Commitable
setAutocommit
in interface Commitable
autocommit
- If true, all changes are immediately written to the
underlying persistence layer, if any is used.public Resource addReificationOf(Statement statement, Resource resource)
ReificationSupport
(resource) rdf:type rdf:Statement .
(resource) rdf:subject (statement.getSubject()) .
(resource) rdf:predicate (statement.getPredicate()) .
(resource) rdf:object (statement.getObject()) .
addReificationOf
in interface ReificationSupport
addReificationOf
in class AbstractModelSetImpl
statement
- which will be reifiedresource
- used to represent the reified statementpublic BlankNode addReificationOf(Statement statement)
ReificationSupport
addReificationOf
in interface ReificationSupport
addReificationOf
in class AbstractModelSetImpl
public void deleteReification(Resource reificationResource)
ReificationSupport
(reificationResource) rdf:type rdf:Statement .
(reificationResource) rdf:subject * .
(reificationResource) rdf:predicate * .
(reificationResource) rdf:object * .
Note that one resource might have been used in several
reifications. Although semantic nonsense, this can happen. This method
cleans up also these cases.
Note that this method deletes the reification from all contexts.deleteReification
in interface ReificationSupport
deleteReification
in class AbstractModelSetImpl
public Collection<Resource> getAllReificationsOf(Statement statement)
getAllReificationsOf
in interface ReificationSupport
getAllReificationsOf
in class AbstractModelSetImpl
public boolean hasReifications(Statement stmt)
hasReifications
in interface ReificationSupport
hasReifications
in class AbstractModelSetImpl
?reificationResource rdf:type rdf:Statement .
?reificationResource rdf:subject ?s .
?reificationResource rdf:predicate ?p .
?reificationResource rdf:object ?o .
public void readFrom(InputStream reader, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
readFrom
in interface 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 in, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
readFrom
in interface ModelSetIO
in
- 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 String getNamespace(String prefix)
getNamespace
in interface NamespaceSupport
public Map<String,String> getNamespaces()
NamespaceSupport
getNamespaces
in interface NamespaceSupport
public void removeNamespace(String prefix)
NamespaceSupport
removeNamespace
in interface NamespaceSupport
public void setNamespace(String prefix, String namespaceURI) throws IllegalArgumentException
setNamespace
in interface NamespaceSupport
IllegalArgumentException
- if the given namespaceURI is not a valid URI in this
environment.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
occursCopyright © 2005–2019 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.