org.ontoware.rdf2go.model.impl
Class AbstractModel

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
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:
AbstractLockingModel, DelegatingModel, DirtyAbstractModel

public abstract class AbstractModel
extends AbstractModelRemovePatterns
implements Model

adapter that maps the rdf2go model functions to a smaller subset of methods

Author:
mvo

Field Summary
protected  java.lang.Object model
          The underlying implementation.
 
Constructor Summary
AbstractModel()
           
 
Method Summary
 void addAll(java.util.Iterator<? extends Statement> other)
           
 void addModel(Model model)
          subclasses should overwrite this for performance reasons
 BlankNode addReificationOf(Statement statement)
           
 Resource addReificationOf(Statement statement, Resource resource)
           
 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)
           
protected  void assertModel()
          This method checks if the model is properly initialized and i.e. not closed.
 void close()
          Close connection to defined, unterlying implementation
 void commit()
          OVERWRITE ME
 boolean contains(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
          Convenience method.
 boolean contains(ResourceOrVariable subject, UriOrVariable predicate, java.lang.String plainLiteral)
          Convenience method.
 boolean contains(Statement s)
          Convenience method.
 long countStatements(TriplePattern pattern)
          Very inefficient.
 DatatypeLiteral createDatatypeLiteral(java.lang.String literal, URI datatypeURI)
           
 LanguageTagLiteral createLanguageTagLiteral(java.lang.String literal, java.lang.String languageTag)
           
 PlainLiteral createPlainLiteral(java.lang.String literal)
           
 Statement createStatement(Resource subject, URI predicate, Node object)
           
 TriplePattern createTriplePattern(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
           
 URI createURI(java.lang.String uriString)
           
 void deleteReification(Resource reificationResource)
           
 ClosableIterator<Statement> findStatements(TriplePattern triplepattern)
          Convenience method.
 java.util.Collection<Resource> getAllReificationsOf(Statement statement)
           
 Diff getDiff(java.util.Iterator<? extends Statement> other)
          Computes a Diff by using HashSets.
 java.lang.Object getProperty(URI propertyURI)
          Note: This is a property of the model, not an RDF property
 java.lang.Object getUnderlyingModelImplementation()
           
 boolean hasReifications(Statement statement)
           
 boolean isEmpty()
          sublcasses should override this method for performance
 boolean isOpen()
           
 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, Syntax syntax)
          Throws an exception if the syntax is not RDF/XML.
 void readFrom(java.io.InputStream in, Syntax syntax, java.lang.String baseURI)
          Throws an exception if the syntax is not RDF/XML.
 void readFrom(java.io.Reader reader, 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> statements)
           
 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 removeStatements(TriplePattern triplePattern)
           
 java.lang.String serialize(Syntax syntax)
          Convenience method.
 void setAutocommit(boolean autocommit)
          OVERWRITE ME
 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)
           
 void update(DiffReader diff)
          Implementations with support for transactions should use them instead of this implementation.
 void writeTo(java.io.OutputStream out, Syntax syntax)
          Throws an exception if the syntax is not known
 
Methods inherited from class org.ontoware.rdf2go.model.impl.AbstractModelAddRemove
addStatement, removeStatement, 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.Model
dump, getContextURI, isIsomorphicWith
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelValueFactory
createBlankNode, createBlankNode, isValidURI
 
Methods inherited from interface org.ontoware.rdf2go.model.FindableModel
findStatements
 
Methods inherited from interface org.ontoware.rdf2go.model.Sparqlable
sparqlConstruct, sparqlDescribe, sparqlSelect
 
Methods inherited from interface org.ontoware.rdf2go.model.FindableModel
findStatements
 
Methods inherited from interface org.ontoware.rdf2go.model.ModelIO
readFrom, readFrom, readFrom, writeTo, writeTo, writeTo
 
Methods inherited from interface org.ontoware.rdf2go.model.NamespaceSupport
getNamespace, getNamespaces, removeNamespace, setNamespace
 

Field Detail

model

protected java.lang.Object model
The underlying implementation.

Constructor Detail

AbstractModel

public AbstractModel()
Method Detail

addModel

public void addModel(Model model)
subclasses should overwrite this for performance reasons

Specified by:
addModel in interface Model

addAll

public void addAll(java.util.Iterator<? extends Statement> other)
            throws ModelRuntimeException
Specified by:
addAll in interface ModelWriter
Overrides:
addAll in class AbstractModelWriter
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 AbstractModelWriter
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 AbstractModelWriter
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 AbstractModelWriter
Throws:
ModelRuntimeException

addStatement

public void addStatement(Statement statement)
                  throws ModelRuntimeException
Specified by:
addStatement in interface ModelWriter
Overrides:
addStatement in class AbstractModelWriter
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 AbstractModelWriter
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 AbstractModelWriter
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 AbstractModelWriter
Throws:
ModelRuntimeException

assertModel

protected void assertModel()
This method checks if the model is properly initialized and i.e. not closed.


close

public void close()
Close connection to defined, unterlying implementation

Specified by:
close in interface Model

commit

public void commit()
OVERWRITE ME

Specified by:
commit in interface Commitable

contains

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

Specified by:
contains in interface FindableModel
Throws:
ModelRuntimeException

contains

public boolean contains(ResourceOrVariable subject,
                        UriOrVariable predicate,
                        java.lang.String plainLiteral)
                 throws ModelRuntimeException
Convenience method.

Specified by:
contains in interface FindableModel
Throws:
ModelRuntimeException

contains

public boolean contains(Statement s)
                 throws ModelRuntimeException
Convenience method.

Specified by:
contains in interface FindableModel
Throws:
ModelRuntimeException

countStatements

public long countStatements(TriplePattern pattern)
                     throws ModelRuntimeException
Very inefficient. Please override.

Specified by:
countStatements in interface FindableModel
Throws:
ModelRuntimeException

createDatatypeLiteral

public DatatypeLiteral createDatatypeLiteral(java.lang.String literal,
                                             URI datatypeURI)
                                      throws ModelRuntimeException
Specified by:
createDatatypeLiteral in interface ModelValueFactory
Throws:
ModelRuntimeException

createLanguageTagLiteral

public LanguageTagLiteral createLanguageTagLiteral(java.lang.String literal,
                                                   java.lang.String languageTag)
                                            throws ModelRuntimeException
Specified by:
createLanguageTagLiteral in interface ModelValueFactory
Throws:
ModelRuntimeException

createPlainLiteral

public PlainLiteral createPlainLiteral(java.lang.String literal)
                                throws ModelRuntimeException
Specified by:
createPlainLiteral in interface ModelValueFactory
Throws:
ModelRuntimeException

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Node object)
Specified by:
createStatement in interface ModelValueFactory

createTriplePattern

public TriplePattern createTriplePattern(ResourceOrVariable subject,
                                         UriOrVariable predicate,
                                         NodeOrVariable object)
Specified by:
createTriplePattern in interface FindableModel

createURI

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

findStatements

public ClosableIterator<Statement> findStatements(TriplePattern triplepattern)
                                           throws ModelRuntimeException
Convenience method.

Specified by:
findStatements in interface FindableModel
Throws:
ModelRuntimeException

getDiff

public Diff getDiff(java.util.Iterator<? extends Statement> other)
             throws ModelRuntimeException
Computes a Diff by using HashSets.

Specified by:
getDiff in interface ModelAddRemove
Throws:
ModelRuntimeException

getProperty

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

Specified by:
getProperty in interface Model
Parameters:
propertyURI -
Returns:
stored property value for this model or null

getUnderlyingModelImplementation

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

isEmpty

public boolean isEmpty()
sublcasses should override this method for performance

Specified by:
isEmpty in interface Model

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Model

newRandomUniqueURI

public URI newRandomUniqueURI()
Specified by:
newRandomUniqueURI in interface ModelValueFactory

open

public void open()
Open connection to defined, unterlying implementation.

Specified by:
open in interface Model

queryConstruct

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

Specified by:
queryConstruct in interface Sparqlable
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

querySelect

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

Specified by:
querySelect in interface Sparqlable
Throws:
QueryLanguageNotSupportedException
ModelRuntimeException

readFrom

public void readFrom(java.io.InputStream in,
                     Syntax syntax)
              throws java.io.IOException,
                     ModelRuntimeException
Throws an exception if the syntax is not RDF/XML. Subclasses are encouraged to overwrite this.

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

readFrom

public void readFrom(java.io.InputStream in,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws java.io.IOException,
                     ModelRuntimeException
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
Throws:
java.io.IOException
ModelRuntimeException

readFrom

public void readFrom(java.io.Reader reader,
                     Syntax syntax,
                     java.lang.String baseURI)
              throws ModelRuntimeException,
                     java.io.IOException
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
Throws:
java.io.IOException
ModelRuntimeException

removeAll

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

removeAll

public void removeAll(java.util.Iterator<? extends Statement> statements)
Specified by:
removeAll in interface ModelAddRemove
Overrides:
removeAll in class AbstractModelAddRemove

removeStatement

public void removeStatement(Resource subject,
                            URI predicate,
                            java.lang.String literal)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModelAddRemove
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 AbstractModelAddRemove
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 AbstractModelAddRemove
Throws:
ModelRuntimeException

removeStatement

public void removeStatement(Statement statement)
                     throws ModelRuntimeException
Specified by:
removeStatement in interface ModelAddRemove
Overrides:
removeStatement in class AbstractModelAddRemove
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 AbstractModelAddRemove
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 AbstractModelAddRemove
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 AbstractModelAddRemove
Throws:
ModelRuntimeException

removeStatements

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

removeStatements

public void removeStatements(TriplePattern triplePattern)
                      throws ModelRuntimeException
Specified by:
removeStatements in interface ModelRemovePatterns
Overrides:
removeStatements in class AbstractModelRemovePatterns
Throws:
ModelRuntimeException

serialize

public java.lang.String serialize(Syntax syntax)
                           throws SyntaxNotSupportedException
Convenience method.

Specified by:
serialize in interface ModelIO
Throws:
SyntaxNotSupportedException

setAutocommit

public void setAutocommit(boolean autocommit)
OVERWRITE ME

Specified by:
setAutocommit in interface Commitable

setProperty

public void setProperty(URI propertyURI,
                        java.lang.Object value)
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
Parameters:
propertyURI -
value -

size

public long size()
          throws ModelRuntimeException
This is a really slow implementation, please override.

Specified by:
size in interface Model
Throws:
ModelRuntimeException

sparqlAsk

public boolean sparqlAsk(java.lang.String query)
                  throws ModelRuntimeException,
                         MalformedQueryException
Specified by:
sparqlAsk in interface Sparqlable
Throws:
ModelRuntimeException
MalformedQueryException

update

public void update(DiffReader diff)
            throws ModelRuntimeException
Implementations with support for transactions should use them instead of this implementation.

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

writeTo

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

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

addReificationOf

public BlankNode addReificationOf(Statement statement)
Specified by:
addReificationOf in interface ReificationSupport

addReificationOf

public Resource addReificationOf(Statement statement,
                                 Resource resource)
Specified by:
addReificationOf in interface ReificationSupport

hasReifications

public boolean hasReifications(Statement statement)
Specified by:
hasReifications in interface ReificationSupport

getAllReificationsOf

public java.util.Collection<Resource> getAllReificationsOf(Statement statement)
Specified by:
getAllReificationsOf in interface ReificationSupport

deleteReification

public void deleteReification(Resource reificationResource)
Specified by:
deleteReification in interface ReificationSupport


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