public class RepositoryModel extends AbstractLockingModel implements Model
update(DiffReader), addAll(Iterator) or
removeAll(Iterator), then the current connection will be used in
non-autocommit mode and commited, including a rollback when it fails.| Modifier and Type | Field and Description |
|---|---|
protected org.openrdf.repository.RepositoryConnection |
connection |
protected URI |
context |
static String |
DEFAULT_CONTEXT |
static org.openrdf.model.URI |
DEFAULT_OPENRDF_CONTEXT |
protected org.openrdf.repository.Repository |
repository |
protected org.openrdf.model.ValueFactory |
valueFactory |
model| Constructor and Description |
|---|
RepositoryModel(org.openrdf.repository.Repository repository) |
RepositoryModel(URI context,
org.openrdf.repository.Repository repository) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAll(Iterator<? extends Statement> iterator)
Add all statements contained in 'other' to this model = 'union'
|
void |
addStatement(Resource subject,
URI predicate,
Node object)
adds a (subject, property ,object)-statement to this model
|
protected void |
assertModel()
This method checks if the model is properly initialized and i.e.
|
void |
close()
Closes the Connection to the wrapper Repository.
|
void |
commit()
Deprecated.
|
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.
|
void |
dump()
Dumps the whole content of the model via System.out
|
void |
finalize()
Makes sure that the Connection to the wrapped Repository has been closed.
|
ClosableIterator<Statement> |
findStatements(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
get all statements in the model with this subject, predicate and object.
|
URI |
getContextURI() |
String |
getNamespace(String prefix) |
Map<String,String> |
getNamespaces()
Get all namespaces as a map of prefix to namespace.
|
org.openrdf.model.URI |
getOpenRDFContextURI()
Returns the context as a OpenRDF URI.
|
static org.openrdf.rio.RDFFormat |
getRDFFormat(Syntax syntax)
Resolves an RDF2Go
Syntax to an OpenRDF RDFFormat. |
Object |
getUnderlyingModelImplementation() |
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()
Locking a RepositoryModel disables auto-commit mode and starts a new
transaction, which is left open until this RepositoryModel is unlocked.
|
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 stream)
Read from InputStream assuming to read an RDF/XML stream.
|
void |
readFrom(InputStream stream,
org.openrdf.rio.RDFFormat format,
String baseURI) |
void |
readFrom(InputStream stream,
Syntax syntax)
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(InputStream stream,
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)
Read from Reader assuming in UTF8 encoding.
|
void |
readFrom(Reader reader,
org.openrdf.rio.RDFFormat format,
String baseURL) |
void |
readFrom(Reader reader,
Syntax syntax)
Reads assuming the given syntax.
|
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> iterator)
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 |
rollback() |
void |
setAutocommit(boolean autocommit)
Deprecated.
|
void |
setNamespace(String prefix,
String namespaceURI) |
void |
setUnderlyingModelImplementation(Object object) |
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()
Ends the locking status, committing all changed that have been made since
this RepositoryModel was locked and switching back to auto-commit mode.
|
void |
update(DiffReader diff)
Using lock() and unlock()
|
void |
writeTo(OutputStream stream)
Writing an RDF/XML stream in UTF8 encoding
|
void |
writeTo(OutputStream stream,
Syntax syntax)
Throws an exception if the syntax is not known
|
void |
writeTo(org.openrdf.rio.RDFWriter writer) |
void |
writeTo(Writer writer)
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.
|
addModel, addReificationOf, addReificationOf, addStatement, addStatement, addStatement, addStatement, addStatement, addStatement, addStatement, contains, contains, contains, countStatements, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createTriplePattern, createURI, deleteReification, findStatements, getAllReificationsOf, getDiff, getProperty, hasReifications, isEmpty, newRandomUniqueURI, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatements, removeStatements, serialize, setPropertyclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddModel, getProperty, isEmpty, setPropertycreateDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createURI, newRandomUniqueURIremoveStatements, removeStatementsgetDiff, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatementforEach, spliteratoraddStatement, addStatement, addStatement, addStatement, addStatement, addStatement, addStatementcontains, contains, contains, countStatements, createTriplePattern, findStatementsaddReificationOf, addReificationOf, deleteReification, getAllReificationsOf, hasReificationspublic static final String DEFAULT_CONTEXT
public static final org.openrdf.model.URI DEFAULT_OPENRDF_CONTEXT
protected org.openrdf.repository.Repository repository
protected org.openrdf.repository.RepositoryConnection connection
protected org.openrdf.model.ValueFactory valueFactory
protected URI context
public RepositoryModel(org.openrdf.repository.Repository repository)
throws ModelRuntimeException
ModelRuntimeExceptionpublic RepositoryModel(URI context, org.openrdf.repository.Repository repository) throws ModelRuntimeException
ModelRuntimeExceptionpublic org.openrdf.model.URI getOpenRDFContextURI()
public Model open()
AbstractModelopen in interface Modelopen in class AbstractModelpublic boolean isOpen()
throws ModelRuntimeException
isOpen in interface ModelisOpen in class AbstractModelModelRuntimeExceptionpublic void close()
close in interface Modelclose in class AbstractModelpublic BlankNode createBlankNode()
ModelValueFactorycreateBlankNode in interface ModelValueFactorypublic BlankNode createBlankNode(String internalID)
ModelValueFactorycreateBlankNode in interface ModelValueFactorypublic boolean isValidURI(String uriString)
ModelValueFactoryisValidURI in interface ModelValueFactorypublic void addStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelWriteraddStatement in interface ModelWriteraddStatement in class AbstractModelAddRemovesubject - of the statementpredicate - of the statementobject - of the statementModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void removeAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelAddRemoveremoveAll in interface ModelAddRemoveremoveAll in class AbstractModelModelRuntimeExceptionpublic void removeAll()
throws ModelRuntimeException
ModelAddRemoveremoveAll in interface ModelAddRemoveremoveAll in class AbstractModelModelRuntimeExceptionpublic void addAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelWriteraddAll in interface ModelWriteraddAll in class AbstractModeliterator - another RDF2GO modelModelRuntimeException - if there is either an error with the
underlying model or an IOExceptionpublic void removeStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelAddRemoveremoveStatement in interface ModelAddRemoveremoveStatement in class AbstractModelAddRemovesubject - URI or Object (= blankNode)object - URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteralModelRuntimeExceptionpublic ClosableIterator<Statement> findStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
FindableModelfindStatements in interface FindableModelsubject - 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 boolean sparqlAsk(String query) throws ModelRuntimeException
SparqlablesparqlAsk in interface SparqlablesparqlAsk in class AbstractModelquery - a SPARQL AKS queryModelRuntimeException - if the execution throws an exceptionMalformedQueryException - if the query is not a valid SPARQL ASK
querypublic ClosableIterable<Statement> sparqlDescribe(String query) throws ModelRuntimeException
SparqlablesparqlDescribe in interface SparqlableModelRuntimeException - if the execution throws an exceptionMalformedQueryException - if the query is not a valid SPARQL
DESCRIBE querypublic ClosableIterable<Statement> sparqlConstruct(String query) throws ModelRuntimeException
sparqlConstruct in interface SparqlableModelRuntimeException - if the execution throws an exceptionMalformedQueryException - if the query is not a valid SPARQL
CONSTRUCT querypublic QueryResultTable querySelect(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModelquerySelect in interface SparqlablequerySelect in class AbstractModelQueryLanguageNotSupportedException - 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 ClosableIterable<Statement> queryConstruct(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModelqueryConstruct in interface SparqlablequeryConstruct in class AbstractModelQueryLanguageNotSupportedException - 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 sparqlSelect(String queryString) throws ModelRuntimeException
SparqlablesparqlSelect in interface SparqlablequeryString - The SPARQL select query stringModelRuntimeException - if an error happens when executing the
queryMalformedQueryException - if the query is not a valid SPARQL SELECT
querypublic ClosableIterator<Statement> iterator()
ClosableIterablepublic Object getUnderlyingModelImplementation()
getUnderlyingModelImplementation in interface ModelgetUnderlyingModelImplementation in class AbstractModelpublic void setUnderlyingModelImplementation(Object object)
public long size()
throws ModelRuntimeException
AbstractModelsize in interface Modelsize in class AbstractModelModelRuntimeExceptionpublic URI getContextURI()
getContextURI in interface Modelpublic boolean isLocked()
public void lock()
throws LockException
lock in interface LockableLockException - if already lockedpublic void unlock()
public void rollback()
public void dump()
Modelpublic void readFrom(InputStream stream) throws IOException, ModelRuntimeException
ModelIOreadFrom in interface ModelIOstream - the input to readIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void readFrom(InputStream stream, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModelreadFrom in interface ModelIOreadFrom in class AbstractModelsyntax - syntax to useIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void readFrom(InputStream stream, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
AbstractModelreadFrom in interface ModelIOreadFrom in class AbstractModelIOExceptionModelRuntimeExceptionpublic void readFrom(Reader reader, Syntax syntax, String baseURI) throws ModelRuntimeException, IOException
AbstractModelreadFrom in interface ModelIOreadFrom in class AbstractModelModelRuntimeException - from modelIOException - from readerpublic void readFrom(InputStream stream, org.openrdf.rio.RDFFormat format, String baseURI) throws IOException, ModelRuntimeException
IOExceptionModelRuntimeExceptionpublic void readFrom(Reader reader) throws IOException, ModelRuntimeException
ModelIOreadFrom in interface ModelIOreader - the input to readIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void readFrom(Reader reader, Syntax syntax) throws IOException, ModelRuntimeException
ModelIOreadFrom in interface ModelIOreader - the input to readsyntax - syntax to useIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void readFrom(Reader reader, org.openrdf.rio.RDFFormat format, String baseURL) throws IOException, ModelRuntimeException
IOExceptionModelRuntimeExceptionpublic void writeTo(OutputStream stream) throws IOException, ModelRuntimeException
ModelIOwriteTo in interface ModelIOstream - the output to write toIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void writeTo(OutputStream stream, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModelwriteTo in interface ModelIOwriteTo in class AbstractModelstream - the output to write tosyntax - syntax to useIOException - on IOErrorsModelRuntimeException - on RDF serialization errors or model errorspublic void writeTo(Writer writer) throws ModelRuntimeException
ModelIOwriteTo in interface ModelIOwriter - the output to write toModelRuntimeException - on RDF serialization errors or model errorspublic void writeTo(Writer writer, Syntax syntax) throws ModelRuntimeException
ModelIOwriteTo in interface ModelIOwriter - the output to write tosyntax - syntax to useModelRuntimeException - on RDF serialization errors or model errorspublic static org.openrdf.rio.RDFFormat getRDFFormat(Syntax syntax) throws SyntaxNotSupportedException
Syntax to an OpenRDF RDFFormat.syntax - The RDF2Go Syntax to resolve.SyntaxNotSupportedException - When the Syntax could not be resolved to a
RDFFormat.public void writeTo(org.openrdf.rio.RDFWriter writer)
throws ModelRuntimeException
ModelRuntimeException@Deprecated public void commit()
AbstractModelcommit in interface Commitablecommit in class AbstractModel@Deprecated public void setAutocommit(boolean autocommit)
AbstractModelsetAutocommit in interface CommitablesetAutocommit in class AbstractModelautocommit - If true, all changes are immediately written to the
underlying persistence layer, if any is used.public void finalize()
throws Throwable
protected void assertModel()
AbstractModelassertModel in class AbstractModelpublic boolean isIsomorphicWith(Model other)
ModelisIsomorphicWith in interface Modelpublic void update(DiffReader diff) throws ModelRuntimeException
AbstractLockingModelupdate in interface ModelAddRemoveupdate in class AbstractLockingModelModelRuntimeExceptionpublic String getNamespace(String prefix)
getNamespace in interface NamespaceSupportpublic Map<String,String> getNamespaces()
NamespaceSupportgetNamespaces in interface NamespaceSupportpublic void removeNamespace(String prefix)
NamespaceSupportremoveNamespace in interface NamespaceSupportpublic void setNamespace(String prefix, String namespaceURI) throws IllegalArgumentException
setNamespace in interface NamespaceSupportIllegalArgumentException - if the given namespaceURI is not a valid URI in this
environment.Copyright © 2005–2016 IT-Consulting Dr. Max V?lkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.