public abstract class AbstractModel extends AbstractModelRemovePatterns implements Model
| Modifier and Type | Field and Description |
|---|---|
protected Object |
model
The underlying implementation.
|
| Constructor and Description |
|---|
AbstractModel() |
| 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
|
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(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.
|
protected void |
assertModel()
This method checks if the model is properly initialized and i.e.
|
void |
close()
Close connection to defined, underlying implementation
|
void |
commit()
Deprecated.
|
boolean |
contains(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
Convenience method.
|
boolean |
contains(ResourceOrVariable subject,
UriOrVariable predicate,
String plainLiteral)
Convenience method.
|
boolean |
contains(Statement s)
Convenience method.
|
long |
countStatements(TriplePattern pattern)
Very inefficient.
|
DatatypeLiteral |
createDatatypeLiteral(String literal,
URI datatypeURI) |
LanguageTagLiteral |
createLanguageTagLiteral(String literal,
String languageTag) |
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
|
TriplePattern |
createTriplePattern(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object) |
URI |
createURI(String uriString)
The model must create URIs it would accept itself.
|
void |
deleteReification(Resource reificationResource)
Delete reifications made by this resource.
|
ClosableIterator<Statement> |
findStatements(TriplePattern triplepattern)
Convenience method.
|
Collection<Resource> |
getAllReificationsOf(Statement statement) |
Diff |
getDiff(Iterator<? extends Statement> other)
Computes a Diff by using HashSets.
|
Object |
getProperty(URI propertyURI)
Note: This is a property of the model, not an RDF property
|
Object |
getUnderlyingModelImplementation() |
boolean |
hasReifications(Statement statement) |
boolean |
isEmpty()
sublcasses should override this method for performance
|
boolean |
isOpen() |
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,
Syntax syntax)
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(InputStream in,
Syntax syntax,
String baseURI)
Note: Subclasses are encouraged to overwrite this.
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(Reader reader,
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> statements)
Removes all statements contained in 'other' from this model =
'difference'
|
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 |
removeStatements(TriplePattern triplePattern)
remove all matching triple patterms from the model
|
String |
serialize(Syntax syntax)
Convenience method.
|
void |
setAutocommit(boolean autocommit)
Deprecated.
|
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
|
void |
update(DiffReader diff)
Implementations with support for transactions should use them instead of
this implementation.
|
void |
writeTo(OutputStream out,
Syntax syntax)
Throws an exception if the syntax is not known
|
addStatement, removeStatementclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdump, getContextURI, isIsomorphicWithcreateBlankNode, createBlankNode, isValidURIremoveStatementiteratorforEach, spliteratoraddStatementsparqlConstruct, sparqlDescribe, sparqlSelectfindStatementsreadFrom, readFrom, readFrom, writeTo, writeTo, writeTogetNamespace, getNamespaces, removeNamespace, setNamespaceprotected Object model
public void addModel(Model model)
public void addAll(Iterator<? extends Statement> other) throws ModelRuntimeException
ModelWriteraddAll in interface ModelWriteraddAll in class AbstractModelWriterother - another RDF2GO modelModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void addStatement(Resource subject, URI predicate, String literal) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubject - 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 IOExceptionpublic void addStatement(Resource subject, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubject - 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 IOExceptionpublic void addStatement(Resource subject, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubject - 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 IOExceptionpublic void addStatement(Statement statement) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWriterstatement - the statement to addModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void addStatement(String subjectURIString, URI predicate, String literal) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubjectURIString - interpreted as URI of the statementpredicate - of the statementliteral - for the PlainLiteralModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void addStatement(String subjectURIString, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubjectURIString - interpreted as a URIpredicate - of the statementliteral - main part of the LanguageTagLiterallanguageTag - RDF language tag of the LanguageTagLiteralModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void addStatement(String subjectURIString, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelWritersubjectURIString - interpreted as URI of the statementpredicate - of the statementliteral - for the DatatypeLiteraldatatypeURI - for the DatatypeLiteralModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionprotected void assertModel()
public void close()
@Deprecated public void commit()
commit in interface Commitablepublic boolean contains(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
contains in interface FindableModelsubject - defined or a Variable, e.g. Variable.ANYpredicate - defined or a Variable, e.g. Variable.ANYobject - defined or a Variable, e.g. Variable.ANYModelRuntimeException - most often caused by underlying
IOException, if anypublic boolean contains(ResourceOrVariable subject, UriOrVariable predicate, String plainLiteral) throws ModelRuntimeException
contains in interface FindableModelsubject - defined or a Variable, e.g. Variable.ANYpredicate - defined or a Variable, e.g. Variable.ANYplainLiteral - a string interpreted as adefined PlainLiteralModelRuntimeException - most often caused by underlying
IOException, if anypublic boolean contains(Statement s) throws ModelRuntimeException
contains in interface FindableModels - a StatementModelRuntimeException - most often caused by underlying
IOException, if anypublic long countStatements(TriplePattern pattern) throws ModelRuntimeException
countStatements in interface FindableModelModelRuntimeExceptionpublic DatatypeLiteral createDatatypeLiteral(String literal, URI datatypeURI) throws ModelRuntimeException
createDatatypeLiteral in interface ModelValueFactoryModelRuntimeException - e.g. if the datatype URI causes problemspublic LanguageTagLiteral createLanguageTagLiteral(String literal, String languageTag) throws ModelRuntimeException
createLanguageTagLiteral in interface ModelValueFactoryModelRuntimeException - e.g. if the language tag is malformedpublic PlainLiteral createPlainLiteral(String literal) throws ModelRuntimeException
ModelValueFactorycreatePlainLiteral in interface ModelValueFactoryModelRuntimeExceptionpublic Statement createStatement(Resource subject, URI predicate, Node object)
ModelValueFactorycreateStatement in interface ModelValueFactorypublic TriplePattern createTriplePattern(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
createTriplePattern in interface FindableModelsubject - defined or a Variable, e.g. Variable.ANYpredicate - defined or a Variable, e.g. Variable.ANYobject - defined or a Variable, e.g. Variable.ANYpublic URI createURI(String uriString) throws ModelRuntimeException
ModelValueFactorycreateURI in interface ModelValueFactoryModelRuntimeExceptionpublic ClosableIterator<Statement> findStatements(TriplePattern triplepattern) throws ModelRuntimeException
findStatements in interface FindableModeltriplepattern - to be matchedModelRuntimeException - most often caused by underlying
IOException, if anypublic Diff getDiff(Iterator<? extends Statement> other) throws ModelRuntimeException
getDiff in interface ModelAddRemoveModelRuntimeExceptionpublic Object getProperty(URI propertyURI)
getProperty in interface ModelpropertyURI - used as a property name to get the model propertypublic Object getUnderlyingModelImplementation()
getUnderlyingModelImplementation in interface Modelpublic boolean isEmpty()
public boolean isOpen()
public URI newRandomUniqueURI()
ModelValueFactorynewRandomUniqueURI in interface ModelValueFactorypublic Model open()
public ClosableIterable<Statement> queryConstruct(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
queryConstruct in interface SparqlableQueryLanguageNotSupportedException - 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
querySelect in interface SparqlableQueryLanguageNotSupportedException - 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, Syntax syntax) throws IOException, ModelRuntimeException
readFrom in interface ModelIOsyntax - syntax to useIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void readFrom(InputStream in, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
readFrom in interface ModelIOIOExceptionModelRuntimeExceptionpublic void readFrom(Reader reader, Syntax syntax, String baseURI) throws ModelRuntimeException, IOException
readFrom in interface ModelIOIOException - from readerModelRuntimeException - from modelpublic void removeAll()
throws ModelRuntimeException
ModelAddRemoveremoveAll in interface ModelAddRemoveremoveAll in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeAll(Iterator<? extends Statement> statements)
ModelAddRemoveremoveAll in interface ModelAddRemoveremoveAll in class AbstractModelAddRemovepublic void removeStatement(Resource subject, URI predicate, String literal) throws ModelRuntimeException
removeStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(Resource subject, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(Resource subject, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(Statement statement) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(String subjectURIString, URI predicate, String literal) throws ModelRuntimeException
removeStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(String subjectURIString, URI predicate, String literal, String languageTag) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatement(String subjectURIString, URI predicate, String literal, URI datatypeURI) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemoveModelRuntimeExceptionpublic void removeStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
ModelRemovePatternsremoveStatements in interface ModelRemovePatternsremoveStatements in class AbstractModelRemovePatternssubject - URI or Object (= blankNode)object - URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteralModelRuntimeExceptionpublic void removeStatements(TriplePattern triplePattern) throws ModelRuntimeException
ModelRemovePatternsremoveStatements in interface ModelRemovePatternsremoveStatements in class AbstractModelRemovePatternsModelRuntimeExceptionpublic String serialize(Syntax syntax) throws SyntaxNotSupportedException
serialize in interface ModelIOSyntaxNotSupportedException - if the syntax is not supported@Deprecated public void setAutocommit(boolean autocommit)
setAutocommit in interface Commitableautocommit - If true, all changes are immediately written to the
underlying persistence layer, if any is used.public void setProperty(URI propertyURI, Object value)
setProperty in interface ModelpropertyURI - 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
size in interface ModelModelRuntimeExceptionpublic boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException
SparqlablesparqlAsk in interface Sparqlablequery - a SPARQL AKS queryModelRuntimeException - if the execution throws an exceptionMalformedQueryException - if the query is not a valid SPARQL ASK
querypublic void update(DiffReader diff) throws ModelRuntimeException
update in interface ModelAddRemoveupdate in class AbstractModelAddRemoveModelRuntimeExceptionpublic void writeTo(OutputStream out, Syntax syntax) throws IOException, ModelRuntimeException
writeTo in interface ModelIOout - the output to write tosyntax - syntax to useIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic BlankNode addReificationOf(Statement statement)
ReificationSupportaddReificationOf in interface ReificationSupportpublic 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 ReificationSupportstatement - 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 ReificationSupportpublic 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 ReificationSupportCopyright © 2005–2016 IT-Consulting Dr. Max V?lkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.