public class LoggingModelSet extends Object implements ModelSet
Constructor and Description |
---|
LoggingModelSet(ModelSet modelset) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Iterator<? extends Statement> statement)
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)
Adds a complete
Model to the given contextURI. |
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 |
addStatement(URI contextURI,
Resource subject,
URI predicate,
Node object)
This method creates a Model named 'contextURI' if needed.
|
void |
close()
Close connection of the underlying implementation
|
void |
commit()
Deprecated.
|
boolean |
contains(Statement s) |
boolean |
containsModel(URI contextURI) |
boolean |
containsStatements(UriOrVariable contextURI,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object) |
long |
countStatements(QuadPattern pattern) |
BlankNode |
createBlankNode()
Create (but do not add) a new blank node
|
BlankNode |
createBlankNode(String internalID)
Create a new blank node with the given internal ID.
|
DatatypeLiteral |
createDatatypeLiteral(String literal,
URI datatypeURI) |
LanguageTagLiteral |
createLanguageTagLiteral(String literal,
String langugeTag) |
PlainLiteral |
createPlainLiteral(String literal)
Create a new plain literal
|
QuadPattern |
createQuadPattern(UriOrVariable context,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object) |
Statement |
createStatement(Resource subject,
URI predicate,
Node object)
Create a new statement - but DOES NOT add it to the model
|
Statement |
createStatement(URI context,
Resource subject,
URI predicate,
Node object)
Creates a statement with a context URI.
|
URI |
createURI(String uriString)
Creates an RDF2Go URI.
|
void |
deleteReification(Resource reificationResource)
Delete reifications made by this resource.
|
void |
dump()
Print the whole content of this ModelSet to System.out.
|
ClosableIterator<Statement> |
findStatements(QuadPattern pattern)
Search across all existing models
|
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.
|
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 |
getUnderlyingModelSetImplementation() |
boolean |
hasReifications(Statement stmt) |
boolean |
isEmpty() |
boolean |
isLocked() |
boolean |
isOpen() |
boolean |
isValidURI(String uriString)
CHecks URI for syntax errors.
|
ClosableIterator<Statement> |
iterator()
Returns an iterator over a set of elements of type T.
|
void |
lock()
Tries to obtain a lock.
|
URI |
newRandomUniqueURI()
Implementations are free to choose if their semantics are unique within
the this model, the ModelSet, or unique in the universe
|
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 reader,
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.
|
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> statement)
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 |
removeStatement(URI contextURI,
Resource subject,
URI predicate,
Node object)
Removes the statement (s,p,o) from a model named contextURI.
|
void |
removeStatements(QuadPattern quadPattern)
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
|
String |
serialize(Syntax syntax)
Convenience method to export a ModelSet to a String in a given syntax.
|
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 |
unlock()
Removes a lock.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public LoggingModelSet(ModelSet modelset)
public void addAll(Iterator<? extends Statement> statement) throws ModelRuntimeException
ModelSetAddRemove
addAll
in interface ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic void addModel(Model model, URI contextURI) throws ModelRuntimeException
ModelSet
Model
to the given contextURI. The context URI of
the model is ignored.addModel
in interface ModelSet
ModelRuntimeException
- if any internal (I/O related) exception
occurspublic boolean addModel(Model model)
ModelSet
public 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
ModelRuntimeException
- if any internal (I/O related) exception
occurspublic 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
statement
- which will be reifiedresource
- used to represent the reified statementpublic BlankNode addReificationOf(Statement statement)
ReificationSupport
addReificationOf
in interface ReificationSupport
public void addStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
addStatement
in interface ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic void addStatement(URI contextURI, Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelSetAddRemove
addStatement
in interface ModelSetAddRemove
contextURI
- a URI or nullsubject
- a Resource (URI or BlankNode)object
- a NodeModelRuntimeException
- if any internal (I/O related) exception occurspublic void close()
ModelSet
@Deprecated public void commit() throws ModelRuntimeException
Commitable
commit
in interface Commitable
ModelRuntimeException
- if the commit could not be executedpublic boolean contains(Statement s) throws ModelRuntimeException
contains
in interface FindableModelSet
s
- a StatementModelRuntimeException
public boolean containsModel(URI contextURI)
containsModel
in interface ModelSet
public boolean containsStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
containsStatements
in interface FindableModelSet
ModelRuntimeException
public long countStatements(QuadPattern pattern) throws ModelRuntimeException
countStatements
in interface FindableModelSet
ModelRuntimeException
public BlankNode createBlankNode()
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public BlankNode createBlankNode(String internalID)
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public DatatypeLiteral createDatatypeLiteral(String literal, URI datatypeURI) throws ModelRuntimeException
createDatatypeLiteral
in interface ModelValueFactory
ModelRuntimeException
- e.g. if the datatype URI causes problemspublic LanguageTagLiteral createLanguageTagLiteral(String literal, String langugeTag) throws ModelRuntimeException
createLanguageTagLiteral
in interface ModelValueFactory
ModelRuntimeException
- e.g. if the language tag is malformedpublic PlainLiteral createPlainLiteral(String literal)
ModelValueFactory
createPlainLiteral
in interface ModelValueFactory
public QuadPattern createQuadPattern(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
createQuadPattern
in interface FindableModelSet
public Statement createStatement(Resource subject, URI predicate, Node object)
ModelValueFactory
createStatement
in interface ModelValueFactory
public Statement createStatement(URI context, Resource subject, URI predicate, Node object)
ModelSet
createStatement
in interface ModelSet
public URI createURI(String uriString) throws ModelRuntimeException
ModelSet
createURI
in interface ModelSet
createURI
in interface ModelValueFactory
ModelRuntimeException
- if URI has not a valid URI format -
according to the adapterpublic 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
public void dump()
ModelSet
public ClosableIterator<Statement> findStatements(QuadPattern pattern) throws ModelRuntimeException
FindableModelSet
findStatements
in interface FindableModelSet
ModelRuntimeException
public ClosableIterator<Statement> findStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
FindableModelSet
findStatements
in interface FindableModelSet
ModelRuntimeException
public Collection<Resource> getAllReificationsOf(Statement statement)
getAllReificationsOf
in interface ReificationSupport
public Model getDefaultModel()
ModelSet
getDefaultModel
in interface 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.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
public String getNamespace(String prefix)
getNamespace
in interface NamespaceSupport
public Map<String,String> getNamespaces()
NamespaceSupport
getNamespaces
in interface NamespaceSupport
public Object getUnderlyingModelSetImplementation()
getUnderlyingModelSetImplementation
in interface ModelSet
public boolean hasReifications(Statement stmt)
hasReifications
in interface ReificationSupport
?reificationResource rdf:type rdf:Statement .
?reificationResource rdf:subject ?s .
?reificationResource rdf:predicate ?p .
?reificationResource rdf:object ?o .
public boolean isEmpty()
public boolean isLocked()
public boolean isOpen()
public boolean isValidURI(String uriString)
ModelValueFactory
isValidURI
in interface ModelValueFactory
public ClosableIterator<Statement> iterator()
ClosableIterable
public void lock() throws LockException
Lockable
lock
in interface Lockable
LockException
- if already lockedpublic URI newRandomUniqueURI()
ModelValueFactory
newRandomUniqueURI
in interface ModelValueFactory
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 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(InputStream reader, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
readFrom
in interface ModelSetIO
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) throws IOException, ModelRuntimeException
ModelSetIO
readFrom
in interface ModelSetIO
in
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialisation errors or model errorspublic 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 void readFrom(Reader in, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
readFrom
in interface ModelSetIO
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 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 removeAll() throws ModelRuntimeException
ModelSet
removeAll
in interface ModelSet
ModelRuntimeException
public void removeAll(Iterator<? extends Statement> statement) throws ModelRuntimeException
ModelSetAddRemove
removeAll
in interface ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic boolean removeModel(URI contextURI)
ModelSet
removeModel
in interface ModelSet
public void removeNamespace(String prefix)
NamespaceSupport
removeNamespace
in interface NamespaceSupport
public void removeStatement(Statement statement) throws ModelRuntimeException
ModelSetAddRemove
removeStatement
in interface ModelSetAddRemove
statement
- a StatementModelRuntimeException
- if any internal (I/O related) exception occurspublic void removeStatement(URI contextURI, Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelSetAddRemove
removeStatement
in interface ModelSetAddRemove
subject
- a Resource (URI or BlankNode)object
- a NodeModelRuntimeException
- if any internal (I/O related) exception occurspublic void removeStatements(QuadPattern quadPattern) throws ModelRuntimeException
ModelSetAddRemove
removeStatements
in interface ModelSetAddRemove
ModelRuntimeException
public void removeStatements(UriOrVariable context, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
ModelSetAddRemove
removeStatements
in interface ModelSetAddRemove
ModelRuntimeException
public String serialize(Syntax syntax) throws SyntaxNotSupportedException
ModelSetIO
serialize
in interface ModelSetIO
SyntaxNotSupportedException
- if the syntax is not supported@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 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 long size() throws ModelRuntimeException
ModelSet
size
in interface ModelSet
ModelSet
.ModelRuntimeException
public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException
Sparqlable
sparqlAsk
in interface Sparqlable
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 unlock()
Lockable
public void update(DiffReader diff) throws ModelRuntimeException
ModelSetAddRemove
update
in interface ModelSetAddRemove
ModelRuntimeException
- if a model or statement in a model to be removed does not
exist.public void writeTo(OutputStream out, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
writeTo
in interface ModelSetIO
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(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(Writer out, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
writeTo
in interface ModelSetIO
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 errorsCopyright © 2005–2018 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.