public abstract class AbstractModelSetImpl extends Object implements ModelSet
Constructor and Description |
---|
AbstractModelSetImpl() |
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)
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(URI context,
Resource subject,
URI predicate,
Node object)
This method creates a Model named 'contextURI' if needed.
|
boolean |
contains(Statement s) |
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
|
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)
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
|
Collection<Resource> |
getAllReificationsOf(Statement statement) |
boolean |
hasReifications(Statement statement) |
boolean |
isEmpty()
sublcasses should override this method for performance
|
boolean |
isLocked() |
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
|
void |
readFrom(InputStream in,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(Reader in,
Syntax syntax)
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.
|
void |
removeStatement(URI context,
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.
|
boolean |
sparqlAsk(String query)
SPARQL ask queries
|
void |
unlock()
Removes a lock.
|
void |
update(DiffReader diff)
Apply the changes given by this diff
|
void |
writeTo(OutputStream out,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
void |
writeTo(Writer writer,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, containsModel, getDefaultModel, getModel, getModels, getModelURIs, getUnderlyingModelSetImplementation, isOpen, open, removeModel, size
queryConstruct, querySelect, sparqlConstruct, sparqlDescribe, sparqlSelect
readFrom, readFrom, readFrom, readFrom, writeTo, writeTo
createQuadPattern
addStatement, removeStatement
forEach, spliterator
commit, setAutocommit
getNamespace, getNamespaces, removeNamespace, setNamespace
public void dump()
ModelSet
public void removeAll() throws ModelRuntimeException
ModelSet
removeAll
in interface ModelSet
ModelRuntimeException
public Statement createStatement(URI context, Resource subject, URI predicate, Node object)
ModelSet
createStatement
in interface ModelSet
public 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(InputStream in, 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 writeTo(Writer writer, Syntax syntax) throws IOException, ModelRuntimeException, SyntaxNotSupportedException
ModelSetIO
writeTo
in interface ModelSetIO
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 syntaxpublic 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 String serialize(Syntax syntax) throws SyntaxNotSupportedException
ModelSetIO
serialize
in interface ModelSetIO
SyntaxNotSupportedException
- if the syntax is not supportedpublic boolean containsStatements(UriOrVariable contextURI, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
containsStatements
in interface FindableModelSet
ModelRuntimeException
public void addStatement(URI context, Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelSetAddRemove
addStatement
in interface ModelSetAddRemove
context
- a URI or nullsubject
- a Resource (URI or BlankNode)object
- a NodeModelRuntimeException
- if any internal (I/O related) exception occurspublic void addAll(Iterator<? extends Statement> statement) throws ModelRuntimeException
ModelSetAddRemove
addAll
in interface ModelSetAddRemove
ModelRuntimeException
- if any internal (I/O related) exception occurspublic void removeStatement(URI context, 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 removeAll(Iterator<? extends Statement> statement) throws ModelRuntimeException
ModelSetAddRemove
removeAll
in interface ModelSetAddRemove
ModelRuntimeException
- 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 BlankNode createBlankNode()
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public BlankNode createBlankNode(String internalID)
ModelValueFactory
createBlankNode
in interface ModelValueFactory
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 boolean isValidURI(String uriString)
ModelValueFactory
isValidURI
in interface ModelValueFactory
public PlainLiteral createPlainLiteral(String literal)
ModelValueFactory
createPlainLiteral
in interface ModelValueFactory
public LanguageTagLiteral createLanguageTagLiteral(String literal, String langugeTag) throws ModelRuntimeException
createLanguageTagLiteral
in interface ModelValueFactory
ModelRuntimeException
- e.g. if the language tag is malformedpublic DatatypeLiteral createDatatypeLiteral(String literal, URI datatypeURI) throws ModelRuntimeException
createDatatypeLiteral
in interface ModelValueFactory
ModelRuntimeException
- e.g. if the datatype URI causes problemspublic Statement createStatement(Resource subject, URI predicate, Node object)
ModelValueFactory
createStatement
in interface ModelValueFactory
public URI newRandomUniqueURI()
ModelValueFactory
newRandomUniqueURI
in interface ModelValueFactory
public boolean isLocked()
public void lock() throws LockException
Lockable
lock
in interface Lockable
LockException
- if already lockedpublic void unlock()
Lockable
public boolean contains(Statement s) throws ModelRuntimeException
contains
in interface FindableModelSet
s
- a StatementModelRuntimeException
public long countStatements(QuadPattern pattern) throws ModelRuntimeException
countStatements
in interface FindableModelSet
ModelRuntimeException
public ClosableIterator<Statement> findStatements(QuadPattern pattern) throws ModelRuntimeException
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 ClosableIterator<Statement> iterator()
ClosableIterable
public boolean addModel(Model model)
ModelSet
public void addModelSet(ModelSet modelSet)
ModelSet
ModelSet
to this ModelSet. Context URIs in the
Statement
s of the modelSet are respected.addModelSet
in interface ModelSet
public void update(DiffReader diff) throws ModelRuntimeException
ModelSetAddRemove
update
in interface ModelSetAddRemove
ModelRuntimeException
- if the ModelSet is lockedpublic boolean isEmpty()
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 BlankNode addReificationOf(Statement statement)
ReificationSupport
addReificationOf
in interface ReificationSupport
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
statement
- which will be reifiedresource
- used to represent the reified statementpublic boolean hasReifications(Statement statement)
hasReifications
in interface ReificationSupport
?reificationResource rdf:type rdf:Statement .
?reificationResource rdf:subject ?s .
?reificationResource rdf:predicate ?p .
?reificationResource rdf:object ?o .
public Collection<Resource> getAllReificationsOf(Statement statement)
getAllReificationsOf
in interface ReificationSupport
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
Copyright © 2005–2019 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.