public class DelegatingModel extends AbstractModel implements Model
model
Modifier | Constructor and Description |
---|---|
protected |
DelegatingModel()
Please set model!
|
|
DelegatingModel(Model model) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Iterator<? extends Statement> other)
Add all statements contained in 'other' to this model = 'union'
|
void |
addModel(Model model)
subclasses should overwrite this for performance reasons
|
void |
addStatement(Resource subject,
URI predicate,
Node object)
adds a (subject, property ,object)-statement to this model
|
void |
addStatement(Resource subject,
URI predicate,
String literal)
adds a (subject, property, literal)-statement to the model.
|
void |
addStatement(Resource subject,
URI predicate,
String literal,
String languageTag)
adds a (subject, property, liteal, language-tag)-statement to the model.
|
void |
addStatement(Resource subject,
URI predicate,
String literal,
URI datatypeURI)
adds a (subject, property, literal ,datatype)-statement to the model.
|
void |
addStatement(Statement statement)
adds a statement to this model
|
void |
addStatement(String subjectURIString,
URI predicate,
String literal)
adds a (subject, property, literal)-statement to the model.
|
void |
addStatement(String subjectURIString,
URI predicate,
String literal,
String languageTag)
adds a (subject, property, liteal, language-tag)-statement to the model.
|
void |
addStatement(String subjectURIString,
URI predicate,
String literal,
URI datatypeURI)
adds a (subject, property, literal, data-type)-statement to the model.
|
void |
close()
Close connection to defined, underlying implementation
|
void |
commit()
Deprecated.
|
boolean |
contains(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
Convenience method.
|
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.
|
URI |
createURI(String uriString)
The model must create URIs it would accept itself.
|
void |
dump()
Dumps the whole content of the model via System.out
|
ClosableIterator<Statement> |
findStatements(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
get all statements in the model with this subject, predicate and object.
|
ClosableIterator<Statement> |
findStatements(TriplePattern pattern)
Convenience method.
|
URI |
getContextURI() |
Model |
getDelegatedModel() |
Diff |
getDiff(Iterator<? extends Statement> other)
Computes a Diff by using HashSets.
|
String |
getNamespace(String prefix) |
Map<String,String> |
getNamespaces()
Get all namespaces as a map of prefix to namespace.
|
Object |
getProperty(URI propertyURI)
Note: This is a property of the model, not an RDF property
|
Object |
getUnderlyingModelImplementation() |
boolean |
isEmpty()
sublcasses should override this method for performance
|
boolean |
isIsomorphicWith(Model other)
Two models can be equal even if they do not contain the same statements.
|
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
|
Model |
open()
Open connection to defined, unterlying implementation.
|
ClosableIterable<Statement> |
queryConstruct(String query,
String querylanguage)
Throws an exception if the syntax is not SPARQL
|
QueryResultTable |
querySelect(String query,
String querylanguage)
Throws an exception if the syntax is not SPARQL
|
void |
readFrom(InputStream in)
Read from InputStream assuming to read an RDF/XML stream.
|
void |
readFrom(InputStream reader,
Syntax syntax)
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(InputStream reader,
Syntax syntax,
String baseURI)
Note: Subclasses are encouraged to overwrite this.
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(Reader r)
Read from Reader assuming in UTF8 encoding.
|
void |
readFrom(Reader reader,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(Reader in,
Syntax syntax,
String baseURI)
Note: Subclasses are encouraged to overwrite this.
Throws an exception if the syntax is not RDF/XML.
|
void |
removeAll()
Removes all statements from this model.
|
void |
removeAll(Iterator<? extends Statement> other)
Removes all statements contained in 'other' from this model =
'difference'
|
void |
removeNamespace(String prefix)
Throws no exception if the prefix was not present.
|
void |
removeStatement(Resource subject,
URI predicate,
Node object)
remove a (subject, property ,object)-statement from the model
|
void |
removeStatement(Resource subject,
URI predicate,
String literal) |
void |
removeStatement(Resource subject,
URI predicate,
String literal,
String languageTag)
remove a (subject, property ,literal, language tag)-statement from the
model
|
void |
removeStatement(Resource subject,
URI predicate,
String literal,
URI datatypeURI)
remove a (subject, property ,literal, datatype)-statement from the model
datatype often is an uri for a xml schema datatype (xsd)
|
void |
removeStatement(Statement statement)
remove a rdf2go-statement from the model
|
void |
removeStatement(String subjectURIString,
URI predicate,
String literal) |
void |
removeStatement(String subjectURIString,
URI predicate,
String literal,
String languageTag)
remove a (subject, property ,literal, language tag)-statement from the
model
|
void |
removeStatement(String subjectURIString,
URI predicate,
String literal,
URI datatypeURI)
remove a (subject, property ,literal, datatype)-statement from the model
datatype often is an uri for a xml schema datatype (xsd)
|
void |
removeStatements(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
remove a (subject, property ,object)-statement from the model
|
void |
setAutocommit(boolean autocommit)
Deprecated.
|
protected void |
setDelegatedModel(Model model) |
void |
setNamespace(String prefix,
String namespaceURI) |
void |
setProperty(URI propertyURI,
Object value)
Add an arbitrary property, this will not be persisted and is only
available at runtime.
|
long |
size()
This is a really slow implementation, please override.
|
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)
Implementations with support for transactions should use them instead of
this implementation.
|
void |
writeTo(OutputStream out)
Writing an RDF/XML stream in UTF8 encoding
|
void |
writeTo(OutputStream out,
Syntax syntax)
Throws an exception if the syntax is not known
|
void |
writeTo(Writer w)
Writing an RDF/XML stream in UTF8 encoding
|
void |
writeTo(Writer writer,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
addReificationOf, addReificationOf, assertModel, contains, contains, countStatements, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createTriplePattern, deleteReification, getAllReificationsOf, hasReifications, removeStatements, serialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement
removeStatements
forEach, spliterator
contains, contains, countStatements, createTriplePattern
addReificationOf, addReificationOf, deleteReification, getAllReificationsOf, hasReifications
protected DelegatingModel()
public DelegatingModel(Model model)
public void addAll(Iterator<? extends Statement> other) throws ModelRuntimeException
ModelWriter
addAll
in interface ModelWriter
addAll
in class AbstractModel
other
- another RDF2GO modelModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModelAddRemove
subject
- of the statementpredicate
- of the statementobject
- of the statementModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(Resource subject, URI predicate, String literal) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subject
- of the statementpredicate
- of the statementliteral
- of the statement. A PlainLiteral
will be created.ModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(Resource subject, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subject
- URI or Object (= blankNode)predicate
- of the statementliteral
- main part of literal value of the statementlanguageTag
- RDF language tagModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(Resource subject, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subject
- of the statementpredicate
- of the statementliteral
- main part of the literal of the statementdatatypeURI
- for the datatype part of the literalModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(Statement statement) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
statement
- the statement to addModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(String subjectURIString, URI predicate, String literal) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subjectURIString
- interpreted as URI of the statementpredicate
- of the statementliteral
- for the PlainLiteral
ModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(String subjectURIString, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subjectURIString
- interpreted as a URIpredicate
- of the statementliteral
- main part of the LanguageTagLiteral
languageTag
- RDF language tag of the LanguageTagLiteral
ModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void addStatement(String subjectURIString, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModel
subjectURIString
- interpreted as URI of the statementpredicate
- of the statementliteral
- for the DatatypeLiteral
datatypeURI
- for the DatatypeLiteral
ModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void close()
AbstractModel
close
in interface Model
close
in class AbstractModel
@Deprecated public void commit()
AbstractModel
commit
in interface Commitable
commit
in class AbstractModel
public boolean contains(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
AbstractModel
contains
in interface FindableModel
contains
in class AbstractModel
subject
- defined or a Variable
, e.g. Variable.ANY
predicate
- defined or a Variable
, e.g. Variable.ANY
object
- defined or a Variable
, e.g. Variable.ANY
ModelRuntimeException
- most often caused by underlying
IOException
, if anypublic BlankNode createBlankNode()
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public BlankNode createBlankNode(String internalID)
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public URI createURI(String uriString) throws ModelRuntimeException
ModelValueFactory
createURI
in interface ModelValueFactory
createURI
in class AbstractModel
ModelRuntimeException
public void dump()
Model
public ClosableIterator<Statement> findStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
FindableModel
findStatements
in interface FindableModel
subject
- URI or Object (= blankNode) or Variablepredicate
- URI or Variableobject
- URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteral or VariableModelRuntimeException
- most often caused by underlying
IOException
, if anypublic ClosableIterator<Statement> findStatements(TriplePattern pattern) throws ModelRuntimeException
AbstractModel
findStatements
in interface FindableModel
findStatements
in class AbstractModel
pattern
- to be matchedModelRuntimeException
- most often caused by underlying
IOException
, if anypublic URI getContextURI()
getContextURI
in interface Model
public Model getDelegatedModel()
public Diff getDiff(Iterator<? extends Statement> other) throws ModelRuntimeException
AbstractModel
getDiff
in interface ModelAddRemove
getDiff
in class AbstractModel
ModelRuntimeException
public Object getProperty(URI propertyURI)
AbstractModel
getProperty
in interface Model
getProperty
in class AbstractModel
propertyURI
- used as a property name to get the model propertypublic Object getUnderlyingModelImplementation()
getUnderlyingModelImplementation
in interface Model
getUnderlyingModelImplementation
in class AbstractModel
public boolean isEmpty()
AbstractModel
isEmpty
in interface Model
isEmpty
in class AbstractModel
public boolean isIsomorphicWith(Model other)
Model
isIsomorphicWith
in interface Model
public boolean isLocked()
public boolean isOpen()
isOpen
in interface Model
isOpen
in class AbstractModel
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
newRandomUniqueURI
in class AbstractModel
public Model open()
AbstractModel
open
in interface Model
open
in class AbstractModel
public ClosableIterable<Statement> queryConstruct(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModel
queryConstruct
in interface Sparqlable
queryConstruct
in class AbstractModel
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 query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModel
querySelect
in interface Sparqlable
querySelect
in class AbstractModel
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
ModelIO
readFrom
in interface ModelIO
in
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(InputStream reader, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
syntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader r) throws IOException, ModelRuntimeException
ModelIO
readFrom
in interface ModelIO
r
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader reader, Syntax syntax) throws ModelRuntimeException, IOException
ModelIO
readFrom
in interface ModelIO
reader
- the input to readsyntax
- syntax to useModelRuntimeException
- on RDF serialization errors or model errorsIOException
- on IOErrorspublic void removeAll() throws ModelRuntimeException
ModelAddRemove
removeAll
in interface ModelAddRemove
removeAll
in class AbstractModel
ModelRuntimeException
public void removeAll(Iterator<? extends Statement> other) throws ModelRuntimeException
ModelAddRemove
removeAll
in interface ModelAddRemove
removeAll
in class AbstractModel
ModelRuntimeException
public void removeStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModelAddRemove
subject
- URI or Object (= blankNode)object
- URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteralModelRuntimeException
public void removeStatement(Resource subject, URI predicate, String literal) throws ModelRuntimeException
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(Resource subject, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(Resource subject, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(Statement statement) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(String subjectURIString, URI predicate, String literal) throws ModelRuntimeException
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(String subjectURIString, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatement(String subjectURIString, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModel
ModelRuntimeException
public void removeStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
ModelRemovePatterns
removeStatements
in interface ModelRemovePatterns
removeStatements
in class AbstractModel
subject
- URI or Object (= blankNode)object
- URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteralModelRuntimeException
@Deprecated public void setAutocommit(boolean autocommit)
AbstractModel
setAutocommit
in interface Commitable
setAutocommit
in class AbstractModel
autocommit
- If true, all changes are immediately written to the
underlying persistence layer, if any is used.protected void setDelegatedModel(Model model)
public void setProperty(URI propertyURI, Object value)
AbstractModel
setProperty
in interface Model
setProperty
in class AbstractModel
propertyURI
- used as a parameter name for storing a model propertyvalue
- any java object. Only stored in memory, not in RDF.public long size() throws ModelRuntimeException
AbstractModel
size
in interface Model
size
in class AbstractModel
ModelRuntimeException
public boolean sparqlAsk(String query) throws ModelRuntimeException
Sparqlable
sparqlAsk
in interface Sparqlable
sparqlAsk
in class AbstractModel
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
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 ModelRuntimeException
Sparqlable
sparqlSelect
in interface 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 unlock()
Lockable
public void update(DiffReader diff) throws ModelRuntimeException
AbstractModel
update
in interface ModelAddRemove
update
in class AbstractModel
ModelRuntimeException
public void writeTo(OutputStream out) throws IOException, ModelRuntimeException
ModelIO
writeTo
in interface ModelIO
out
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(OutputStream out, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModel
writeTo
in interface ModelIO
writeTo
in class AbstractModel
out
- the output to write tosyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer w) throws IOException, ModelRuntimeException
ModelIO
writeTo
in interface ModelIO
w
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer writer, Syntax syntax) throws ModelRuntimeException, IOException
ModelIO
writeTo
in interface ModelIO
writer
- the output to write tosyntax
- syntax to useModelRuntimeException
- on RDF serialization errors or model errorsIOException
- on IOErrorspublic void readFrom(Reader in, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
IOException
- from readerModelRuntimeException
- from modelpublic void readFrom(InputStream reader, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
IOException
ModelRuntimeException
public 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) throws ModelRuntimeException
AbstractModel
addModel
in interface Model
addModel
in class AbstractModel
ModelRuntimeException
- if any internal (I/O related) exception
occursCopyright © 2005–2018 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.