org.ontoware.rdf2go.model.impl
Class DelegatingModel

java.lang.Object
  extended by org.ontoware.rdf2go.model.impl.AbstractModelWriter
      extended by org.ontoware.rdf2go.model.impl.AbstractModelAddRemove
          extended by org.ontoware.rdf2go.model.impl.AbstractModelRemovePatterns
              extended by org.ontoware.rdf2go.model.impl.AbstractModel
                  extended by org.ontoware.rdf2go.model.impl.DelegatingModel
All Implemented Interfaces:
java.lang.Iterable<Statement>, ClosableIterable<Statement>, Commitable, FindableModel, Lockable, Model, ModelAddRemove, ModelIO, ModelRemovePatterns, ModelValueFactory, ModelWriter, NamespaceSupport, QueryableModel, ReificationSupport, Sparqlable
Direct Known Subclasses:
NotifyingModelLayer

public class DelegatingModel
extends AbstractModel
implements Model

Delegates all calls to underlying model. This class is meant to be subclassed and have some methods overriden. This was inspired by Sesame's SAIL API.

Author:
voelkel

Field Summary
 
Fields inherited from class org.ontoware.rdf2go.model.impl.AbstractModel
model
 
Constructor Summary
protected DelegatingModel()
          Please set model!
  DelegatingModel(Model model)
           
 
Method Summary
 void addAll(java.util.Iterator<? extends Statement> other)
           
 void addModel(Model model)
          subclasses should overwrite this for performance reasons
 void addStatement(Resource subject, URI predicate, Node object)
           
 void addStatement(Resource subject, URI predicate, java.lang.String literal)
           
 void addStatement(Resource subject, URI predicate, java.lang.String literal, java.lang.String languageTag)
           
 void addStatement(Resource subject, URI predicate, java.lang.String literal, URI datatypeURI)
           
 void addStatement(Statement statement)
           
 void addStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal)
           
 void addStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal, java.lang.String languageTag)
           
 void addStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal, URI datatypeURI)
           
 void close()
          Close connection to defined, unterlying implementation
 void commit()
          OVERWRITE ME
 boolean contains(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
          Convenience method.
 BlankNode createBlankNode()
           
 BlankNode createBlankNode(java.lang.String internalID)
           
 URI createURI(java.lang.String uriString)
           
 void dump()
           
 ClosableIterator<Statement> findStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 ClosableIterator<Statement> findStatements(TriplePattern pattern)
          Convenience method.
 URI getContextURI()
           
 Model getDelegatedModel()
           
 Diff getDiff(java.util.Iterator<? extends Statement> other)
          Computes a Diff by using HashSets.
 java.lang.String getNamespace(java.lang.String prefix)
           
 java.util.Map<java.lang.String,java.lang.String> getNamespaces()
           
 java.lang.Object getProperty(URI propertyURI)
          Note: This is a property of the model, not an RDF property
 java.lang.Object getUnderlyingModelImplementation()
           
 boolean isEmpty()
          sublcasses should override this method for performance
 boolean isIsomorphicWith(Model other)
           
 boolean isLocked()
           
 boolean isOpen()
           
 boolean isValidURI(java.lang.String uriString)
           
 ClosableIterator<Statement> iterator()
           
 void lock()
           
 URI newRandomUniqueURI()
           
 void open()
          Open connection to defined, unterlying implementation.
 ClosableIterable<Statement> queryConstruct(java.lang.String query, java.lang.String querylanguage)
          Throws an exception if the syntax is not SPARQL
 QueryResultTable querySelect(java.lang.String query, java.lang.String querylanguage)
          Throws an exception if the syntax is not SPARQL
 void readFrom(java.io.InputStream in)
           
 void readFrom(java.io.InputStream reader, Syntax syntax)
          Throws an exception if the syntax is not RDF/XML.
 void readFrom(java.io.InputStream reader, Syntax syntax, java.lang.String baseURI)
          Throws an exception if the syntax is not RDF/XML.
 void readFrom(java.io.Reader r)
           
 void readFrom(java.io.Reader reader, Syntax syntax)
           
 void readFrom(java.io.Reader in, Syntax syntax, java.lang.String baseURI)
          Throws an exception if the syntax is not RDF/XML.
 void removeAll()
           
 void removeAll(java.util.Iterator<? extends Statement> other)
           
 void removeNamespace(java.lang.String prefix)
           
 void removeStatement(Resource subject, URI predicate, Node object)
           
 void removeStatement(Resource subject, URI predicate, java.lang.String literal)
           
 void removeStatement(Resource subject, URI predicate, java.lang.String literal, java.lang.String languageTag)
           
 void removeStatement(Resource subject, URI predicate, java.lang.String literal, URI datatypeURI)
           
 void removeStatement(Statement statement)
           
 void removeStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal)
           
 void removeStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal, java.lang.String languageTag)
           
 void removeStatement(java.lang.String subjectURIString, URI predicate, java.lang.String literal, URI datatypeURI)
           
 void removeStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 void setAutocommit(boolean autocommit)
          OVERWRITE ME
protected  void setDelegatedModel(Model model)
           
 void setNamespace(java.lang.String prefix, java.lang.String namespaceURI)
           
 void setProperty(URI propertyURI, java.lang.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(java.lang.String query)
           
 ClosableIterable<Statement> sparqlConstruct(java.lang.String query)
           
 ClosableIterable<Statement> sparqlDescribe(java.lang.String query)
           
 QueryResultTable sparqlSelect(java.lang.String queryString)
           
 void unlock()
           
 void update(DiffReader diff)
          Implementations with support for transactions should use them instead of this implementation.
 void writeTo(java.io.OutputStream out)
           
 void writeTo(java.io.OutputStream out, Syntax syntax)
          Throws an exception if the syntax is not known
 void writeTo(java.io.Writer w)
           
 void writeTo(java.io.Writer writer, Syntax syntax)
           
 
Methods inherited from class org.ontoware.rdf2go.model.impl.AbstractModel
addReificationOf, addReificationOf, assertModel, contains, contains, countStatements, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createTriplePattern, deleteReification, getAllReificationsOf, hasReifications, removeStatements, serialize
 
Methods inherited from class org.ontoware.rdf2go.model.impl.AbstractModelAddRemove
update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelValueFactory
createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelRemovePatterns
removeStatements
 
Methods inherited from interface org.ontoware.rdf2go.model.FindableModel
contains, contains, countStatements, createTriplePattern
 
Methods inherited from interface org.ontoware.rdf2go.model.FindableModel
contains, contains, countStatements, createTriplePattern
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelIO
serialize
 
Methods inherited from interface org.ontoware.rdf2go.model.ReificationSupport
addReificationOf, addReificationOf, deleteReification, getAllReificationsOf, hasReifications
 

Constructor Detail

DelegatingModel

protected DelegatingModel()
Please set model!


DelegatingModel

public DelegatingModel(Model model)
Method Detail

addAll

public void addAll(java.util.Iterator<? extends Statement> other)
            throws ModelRuntimeException
Specified by:
addAll in interface ModelWriter
Overrides:
addAll in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(Resource subject,
                         URI predicate,
                         Node object)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Specified by:
addStatement in class AbstractModelAddRemove
Throws:
ModelRuntimeException

addStatement

public void addStatement(Resource subject,
                         URI predicate,
                         java.lang.String literal)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(Resource subject,
                         URI predicate,
                         java.lang.String literal,
                         java.lang.String languageTag)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(Resource subject,
                         URI predicate,
                         java.lang.String literal,
                         URI datatypeURI)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(Statement statement)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(java.lang.String subjectURIString,
                         URI predicate,
                         java.lang.String literal)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(java.lang.String subjectURIString,
                         URI predicate,
                         java.lang.String literal,
                         java.lang.String languageTag)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

addStatement

public void addStatement(java.lang.String subjectURIString,
                         URI predicate,
                         java.lang.String literal,
                         URI datatypeURI)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModel
Throws:
ModelRuntimeException

close

public void close()
Description copied from class: AbstractModel
Close connection to defined, unterlying implementation

Specified by:
close in interface Model
Overrides:
close in class AbstractModel

commit

public void commit()
Description copied from class: AbstractModel
OVERWRITE ME

Specified by:
commit in interface Commitable
Overrides:
commit in class AbstractModel

contains

public boolean contains(ResourceOrVariable subject,
                        UriOrVariable predicate,
                        NodeOrVariable object)
                 throws ModelRuntimeException
Description copied from class: AbstractModel
Convenience method. Might have faster implementations. Overwrite me!

Specified by:
contains in interface FindableModel
Overrides:
contains in class AbstractModel
Throws:
ModelRuntimeException

createBlankNode

public BlankNode createBlankNode()
Specified by:
createBlankNode in interface ModelValueFactory

createBlankNode

public BlankNode createBlankNode(java.lang.String internalID)
Specified by:
createBlankNode in interface ModelValueFactory

createURI

public URI createURI(java.lang.String uriString)
              throws ModelRuntimeException
Specified by:
createURI in interface ModelValueFactory
Overrides:
createURI in class AbstractModel
Throws:
ModelRuntimeException

dump

public void dump()
Specified by:
dump in interface Model

findStatements

public ClosableIterator<Statement> findStatements(ResourceOrVariable subject,
                                                  UriOrVariable predicate,
                                                  NodeOrVariable object)
                                           throws ModelRuntimeException
Specified by:
findStatements in interface FindableModel
Throws:
ModelRuntimeException

findStatements

public ClosableIterator<Statement> findStatements(TriplePattern pattern)
                                           throws ModelRuntimeException
Description copied from class: AbstractModel
Convenience method.

Specified by:
findStatements in interface FindableModel
Overrides:
findStatements in class AbstractModel
Throws:
ModelRuntimeException

getContextURI

public URI getContextURI()
Specified by:
getContextURI in interface Model

getDelegatedModel

public Model getDelegatedModel()

getDiff

public Diff getDiff(java.util.Iterator<? extends Statement> other)
             throws ModelRuntimeException
Description copied from class: AbstractModel
Computes a Diff by using HashSets.

Specified by:
getDiff in interface ModelAddRemove
Overrides:
getDiff in class AbstractModel
Throws:
ModelRuntimeException

getProperty

public java.lang.Object getProperty(URI propertyURI)
Description copied from class: AbstractModel
Note: This is a property of the model, not an RDF property

Specified by:
getProperty in interface Model
Overrides:
getProperty in class AbstractModel
Returns:
stored property value for this model or null

getUnderlyingModelImplementation

public java.lang.Object getUnderlyingModelImplementation()
Specified by:
getUnderlyingModelImplementation in interface Model
Overrides:
getUnderlyingModelImplementation in class AbstractModel

isEmpty

public boolean isEmpty()
Description copied from class: AbstractModel
sublcasses should override this method for performance

Specified by:
isEmpty in interface Model
Overrides:
isEmpty in class AbstractModel

isIsomorphicWith

public boolean isIsomorphicWith(Model other)
Specified by:
isIsomorphicWith in interface Model

isLocked

public boolean isLocked()
Specified by:
isLocked in interface Lockable

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Model
Overrides:
isOpen in class AbstractModel

isValidURI

public boolean isValidURI(java.lang.String uriString)
Specified by:
isValidURI in interface ModelValueFactory

iterator

public ClosableIterator<Statement> iterator()
Specified by:
iterator in interface java.lang.Iterable<Statement>
Specified by:
iterator in interface ClosableIterable<Statement>

lock

public void lock()
          throws LockException
Specified by:
lock in interface Lockable
Throws:
LockException

newRandomUniqueURI

public URI newRandomUniqueURI()
Specified by:
newRandomUniqueURI in interface ModelValueFactory
Overrides:
newRandomUniqueURI in class AbstractModel

open

public void open()
Description copied from class: AbstractModel
Open connection to defined, unterlying implementation.

Specified by:
open in interface Model
Overrides:
open in class AbstractModel

queryConstruct

public ClosableIterable<Statement> queryConstruct(java.lang.String query,
                                                  java.lang.String querylanguage)
                                           throws QueryLanguageNotSupportedException,
                                                  ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not SPARQL

Specified by:
queryConstruct in interface Sparqlable
Overrides:
queryConstruct in class AbstractModel
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

querySelect

public QueryResultTable querySelect(java.lang.String query,
                                    java.lang.String querylanguage)
                             throws QueryLanguageNotSupportedException,
                                    ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not SPARQL

Specified by:
querySelect in interface Sparqlable
Overrides:
querySelect in class AbstractModel
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream in)
              throws java.io.IOException,
                     ModelRuntimeException
Specified by:
readFrom in interface ModelIO
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream reader,
                     Syntax syntax)
              throws java.io.IOException,
                     ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not RDF/XML. Subclasses are encouraged to overwrite this.

Specified by:
readFrom in interface ModelIO
Overrides:
readFrom in class AbstractModel
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader r)
              throws java.io.IOException,
                     ModelRuntimeException
Specified by:
readFrom in interface ModelIO
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader reader,
                     Syntax syntax)
              throws ModelRuntimeException,
                     java.io.IOException
Specified by:
readFrom in interface ModelIO
Throws:
ModelRuntimeException
java.io.IOException

removeAll

public void removeAll()
               throws ModelRuntimeException
Specified by:
removeAll in interface ModelAddRemove
Overrides:
removeAll in class AbstractModel
Throws:
ModelRuntimeException

removeAll

public void removeAll(java.util.Iterator<? extends Statement> other)
               throws ModelRuntimeException
Specified by:
removeAll in interface ModelAddRemove
Overrides:
removeAll in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Resource subject,
                            URI predicate,
                            Node object)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Specified by:
removeStatement in class AbstractModelAddRemove
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Resource subject,
                            URI predicate,
                            java.lang.String literal)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Resource subject,
                            URI predicate,
                            java.lang.String literal,
                            java.lang.String languageTag)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Resource subject,
                            URI predicate,
                            java.lang.String literal,
                            URI datatypeURI)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Statement statement)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(java.lang.String subjectURIString,
                            URI predicate,
                            java.lang.String literal)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(java.lang.String subjectURIString,
                            URI predicate,
                            java.lang.String literal,
                            java.lang.String languageTag)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(java.lang.String subjectURIString,
                            URI predicate,
                            java.lang.String literal,
                            URI datatypeURI)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModel
Throws:
ModelRuntimeException

removeStatements

public void removeStatements(ResourceOrVariable subject,
                             UriOrVariable predicate,
                             NodeOrVariable object)
                      throws ModelRuntimeException
Specified by:
removeStatements in interface ModelRemovePatterns
Overrides:
removeStatements in class AbstractModel
Throws:
ModelRuntimeException

setAutocommit

public void setAutocommit(boolean autocommit)
Description copied from class: AbstractModel
OVERWRITE ME

Specified by:
setAutocommit in interface Commitable
Overrides:
setAutocommit in class AbstractModel

setDelegatedModel

protected void setDelegatedModel(Model model)

setProperty

public void setProperty(URI propertyURI,
                        java.lang.Object value)
Description copied from class: AbstractModel
Add an arbitrary property, this will not be persisted and is only available at runtime. This allows Model to serve as a central data model in larger applications (like SemVersion.ontoware.org)

Specified by:
setProperty in interface Model
Overrides:
setProperty in class AbstractModel

size

public long size()
          throws ModelRuntimeException
Description copied from class: AbstractModel
This is a really slow implementation, please override.

Specified by:
size in interface Model
Overrides:
size in class AbstractModel
Throws:
ModelRuntimeException

sparqlAsk

public boolean sparqlAsk(java.lang.String query)
                  throws ModelRuntimeException
Specified by:
sparqlAsk in interface Sparqlable
Overrides:
sparqlAsk in class AbstractModel
Throws:
ModelRuntimeException

sparqlConstruct

public ClosableIterable<Statement> sparqlConstruct(java.lang.String query)
                                            throws ModelRuntimeException
Specified by:
sparqlConstruct in interface Sparqlable
Throws:
ModelRuntimeException

sparqlDescribe

public ClosableIterable<Statement> sparqlDescribe(java.lang.String query)
                                           throws ModelRuntimeException
Specified by:
sparqlDescribe in interface Sparqlable
Throws:
ModelRuntimeException

sparqlSelect

public QueryResultTable sparqlSelect(java.lang.String queryString)
                              throws ModelRuntimeException
Specified by:
sparqlSelect in interface Sparqlable
Throws:
ModelRuntimeException

unlock

public void unlock()
Specified by:
unlock in interface Lockable

update

public void update(DiffReader diff)
            throws ModelRuntimeException
Description copied from class: AbstractModel
Implementations with support for transactions should use them instead of this implementation.

Specified by:
update in interface ModelAddRemove
Overrides:
update in class AbstractModel
Throws:
ModelRuntimeException

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException,
                    ModelRuntimeException
Specified by:
writeTo in interface ModelIO
Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.OutputStream out,
                    Syntax syntax)
             throws java.io.IOException,
                    ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not known

Specified by:
writeTo in interface ModelIO
Overrides:
writeTo in class AbstractModel
Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.Writer w)
             throws java.io.IOException,
                    ModelRuntimeException
Specified by:
writeTo in interface ModelIO
Throws:
java.io.IOException
ModelRuntimeException

writeTo

public void writeTo(java.io.Writer writer,
                    Syntax syntax)
             throws ModelRuntimeException,
                    java.io.IOException
Specified by:
writeTo in interface ModelIO
Throws:
ModelRuntimeException
java.io.IOException

readFrom

public void readFrom(java.io.Reader in,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws java.io.IOException,
                     ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not RDF/XML. Sets base URI to the empty string (default). Subclasses are encouraged to overwrite this.

Specified by:
readFrom in interface ModelIO
Overrides:
readFrom in class AbstractModel
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream reader,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws java.io.IOException,
                     ModelRuntimeException
Description copied from class: AbstractModel
Throws an exception if the syntax is not RDF/XML. Set baseURI to the empty string. Subclasses are encouraged to overwrite this.

Specified by:
readFrom in interface ModelIO
Overrides:
readFrom in class AbstractModel
Throws:
java.io.IOException
ModelRuntimeException

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Specified by:
getNamespace in interface NamespaceSupport

getNamespaces

public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
Specified by:
getNamespaces in interface NamespaceSupport

removeNamespace

public void removeNamespace(java.lang.String prefix)
Specified by:
removeNamespace in interface NamespaceSupport

setNamespace

public void setNamespace(java.lang.String prefix,
                         java.lang.String namespaceURI)
                  throws java.lang.IllegalArgumentException
Specified by:
setNamespace in interface NamespaceSupport
Throws:
java.lang.IllegalArgumentException

addModel

public void addModel(Model model)
              throws ModelRuntimeException
Description copied from class: AbstractModel
subclasses should overwrite this for performance reasons

Specified by:
addModel in interface Model
Overrides:
addModel in class AbstractModel
Throws:
ModelRuntimeException


Copyright © 2005-2008 FZI - Forschungszentrum Informatik | Karlsruhe | Germany. All Rights Reserved.