org.openrdf.repository.object
Class ObjectConnection

java.lang.Object
  extended by org.openrdf.repository.base.RepositoryConnectionBase
      extended by org.openrdf.repository.base.RepositoryConnectionWrapper
          extended by org.openrdf.repository.contextaware.ContextAwareConnection
              extended by org.openrdf.repository.object.ObjectConnection
All Implemented Interfaces:
DelegatingRepositoryConnection, RepositoryConnection

public class ObjectConnection
extends ContextAwareConnection

Primary interface for object retrieval and persistence.

Author:
James Leigh

Constructor Summary
ObjectConnection(ObjectRepository repository, RepositoryConnection connection, ObjectFactory factory, TypeManager types)
           
 
Method Summary
 void addCommitTask(Runnable task)
           
<T> T
addDesignation(Object entity, Class<T> concept)
          Explicitly adds the concept to the entity.
 Object addDesignation(Object entity, String uri)
          Explicitly adds the type to the entity.
 Object addDesignation(Object entity, URI type)
          Explicitly adds the type to the entity.
 Object addDesignations(Object entity, String... uris)
          Explicitly adds the types to the entity.
 Object addDesignations(Object entity, URI... types)
          Explicitly adds the types to the entity.
 Value addObject(Object instance)
          Imports the instance into the RDF store, returning its RDF handle.
 void addObject(Resource resource, Object entity)
          Imports the entity into the RDF store using the given handle.
 void addObject(String uri, Object entity)
          Imports the entity into the RDF store using the given URI.
 void addRollbackTask(Runnable task)
           
 void close()
           
static void close(Iterator<?> iter)
          Closes open iterators.
 void commit()
           
 String getLanguage()
          The assign language for this connection, if any.
<T> T
getObject(Class<T> concept, Resource resource)
          Loads a single Object that is assumed to be of the given concept.
<T> T
getObject(Class<T> concept, String uri)
          Loads a single Object that is assumed to be of the given concept.
 Object getObject(String uri)
          Loads a single Object by URI in String form.
 Object getObject(Value value)
          Loads a single Object or converts the literal into an Object.
 ObjectFactory getObjectFactory()
          Access to the ObjectFactory used with this connection.
<T> Result<T>
getObjects(Class<T> concept)
          Matches objects that have the given concept rdf:type.
<T> Result<T>
getObjects(Class<T> concept, Resource... resources)
          Loads the list of resources assumed to implement the given concept.
<T> Result<T>
getObjects(Class<T> concept, String... uris)
           
 ObjectRepository getRepository()
           
 ObjectQuery prepareObjectQuery(QueryLanguage ql, String query)
          Creates a new query that returns object(s).
 ObjectQuery prepareObjectQuery(QueryLanguage ql, String query, String baseURI)
          Creates a new query that returns object(s).
 ObjectQuery prepareObjectQuery(String query)
          Creates a new query that returns object(s).
 void removeDesignation(Object entity, Class<?> concept)
          Explicitly removes the concept from the entity.
 void removeDesignation(Object entity, String uri)
          Explicitly removes the type from the entity.
 void removeDesignation(Object entity, URI type)
          Explicitly removes the type from the entity.
 void removeDesignations(Object entity, String... uris)
          Explicitly removes the types from the entity.
 void removeDesignations(Object entity, URI... types)
          Explicitly removes the types from the entity.
 void rollback()
           
 void setAutoCommit(boolean auto)
           
 void setLanguage(String lang)
          Assigns a language to this connection.
 
Methods inherited from class org.openrdf.repository.contextaware.ContextAwareConnection
add, add, add, add, add, add, add, add, clear, export, exportStatements, getAddContexts, getArchiveContexts, getMaxQueryTime, getQueryLanguage, getReadContexts, getRemoveContexts, getStatements, hasStatement, hasStatement, isDelegatingRemove, isIncludeInferred, prepareBooleanQuery, prepareBooleanQuery, prepareGraphQuery, prepareGraphQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareTupleQuery, prepareTupleQuery, remove, remove, remove, remove, removeWithoutCommit, setAddContexts, setArchiveContexts, setIncludeInferred, setMaxQueryTime, setQueryLanguage, setReadContexts, setRemoveContexts, size
 
Methods inherited from class org.openrdf.repository.base.RepositoryConnectionWrapper
addWithoutCommit, clearNamespaces, exportStatements, exportStatements, getContextIDs, getDelegate, getNamespace, getNamespaces, getStatements, hasStatement, hasStatement, isAutoCommit, isDelegatingAdd, isDelegatingRead, isEmpty, isOpen, removeNamespace, setDelegate, setNamespace
 
Methods inherited from class org.openrdf.repository.base.RepositoryConnectionBase
addInputStreamOrReader, addWithoutCommit, autoCommit, getValueFactory, removeWithoutCommit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.repository.RepositoryConnection
getValueFactory
 

Constructor Detail

ObjectConnection

public ObjectConnection(ObjectRepository repository,
                        RepositoryConnection connection,
                        ObjectFactory factory,
                        TypeManager types)
                 throws RepositoryException
Throws:
RepositoryException
Method Detail

close

public static void close(Iterator<?> iter)
Closes open iterators.

Parameters:
iter -

getRepository

public ObjectRepository getRepository()
Specified by:
getRepository in interface RepositoryConnection
Overrides:
getRepository in class RepositoryConnectionBase

close

public void close()
           throws RepositoryException
Specified by:
close in interface RepositoryConnection
Overrides:
close in class RepositoryConnectionWrapper
Throws:
RepositoryException

rollback

public void rollback()
              throws RepositoryException
Specified by:
rollback in interface RepositoryConnection
Overrides:
rollback in class RepositoryConnectionWrapper
Throws:
RepositoryException

commit

public void commit()
            throws RepositoryException
Specified by:
commit in interface RepositoryConnection
Overrides:
commit in class RepositoryConnectionWrapper
Throws:
RepositoryException

setAutoCommit

public void setAutoCommit(boolean auto)
                   throws RepositoryException
Specified by:
setAutoCommit in interface RepositoryConnection
Overrides:
setAutoCommit in class RepositoryConnectionWrapper
Throws:
RepositoryException

addCommitTask

public void addCommitTask(Runnable task)

addRollbackTask

public void addRollbackTask(Runnable task)

getLanguage

public String getLanguage()
The assign language for this connection, if any.

Returns:
language tag ("en") or null

setLanguage

public void setLanguage(String lang)
Assigns a language to this connection.

Parameters:
lang - such as "en"
See Also:
localized

getObjectFactory

public ObjectFactory getObjectFactory()
Access to the ObjectFactory used with this connection.

Returns:
ObjectFactory bound to this connection.

addObject

public Value addObject(Object instance)
                throws RepositoryException
Imports the instance into the RDF store, returning its RDF handle.

Throws:
RepositoryException

addObject

public void addObject(String uri,
                      Object entity)
               throws RepositoryException
Imports the entity into the RDF store using the given URI.

Throws:
RepositoryException

addObject

public void addObject(Resource resource,
                      Object entity)
               throws RepositoryException
Imports the entity into the RDF store using the given handle.

Throws:
RepositoryException

addDesignation

public <T> T addDesignation(Object entity,
                            Class<T> concept)
                 throws RepositoryException
Explicitly adds the concept to the entity.

Returns:
the entity with new composed concept
Throws:
RepositoryException

addDesignation

public Object addDesignation(Object entity,
                             String uri)
                      throws RepositoryException
Explicitly adds the type to the entity.

Returns:
the entity with new composed types
Throws:
RepositoryException

addDesignation

public Object addDesignation(Object entity,
                             URI type)
                      throws RepositoryException
Explicitly adds the type to the entity.

Returns:
the entity with new composed type
Throws:
RepositoryException

addDesignations

public Object addDesignations(Object entity,
                              String... uris)
                       throws RepositoryException
Explicitly adds the types to the entity.

Returns:
the entity with new composed types
Throws:
RepositoryException

addDesignations

public Object addDesignations(Object entity,
                              URI... types)
                       throws RepositoryException
Explicitly adds the types to the entity.

Returns:
the entity with new composed types
Throws:
RepositoryException

removeDesignation

public void removeDesignation(Object entity,
                              Class<?> concept)
                       throws RepositoryException
Explicitly removes the concept from the entity.

Throws:
RepositoryException

removeDesignation

public void removeDesignation(Object entity,
                              String uri)
                       throws RepositoryException
Explicitly removes the type from the entity.

Throws:
RepositoryException

removeDesignation

public void removeDesignation(Object entity,
                              URI type)
                       throws RepositoryException
Explicitly removes the type from the entity.

Throws:
RepositoryException

removeDesignations

public void removeDesignations(Object entity,
                               String... uris)
                        throws RepositoryException
Explicitly removes the types from the entity.

Throws:
RepositoryException

removeDesignations

public void removeDesignations(Object entity,
                               URI... types)
                        throws RepositoryException
Explicitly removes the types from the entity.

Throws:
RepositoryException

getObject

public Object getObject(String uri)
                 throws RepositoryException
Loads a single Object by URI in String form.

Throws:
RepositoryException

getObject

public Object getObject(Value value)
                 throws RepositoryException
Loads a single Object or converts the literal into an Object.

Throws:
RepositoryException

getObject

public <T> T getObject(Class<T> concept,
                       String uri)
            throws RepositoryException,
                   QueryEvaluationException
Loads a single Object that is assumed to be of the given concept.

Throws:
RepositoryException
QueryEvaluationException

getObject

public <T> T getObject(Class<T> concept,
                       Resource resource)
            throws RepositoryException,
                   QueryEvaluationException
Loads a single Object that is assumed to be of the given concept.

Throws:
RepositoryException
QueryEvaluationException

getObjects

public <T> Result<T> getObjects(Class<T> concept)
                     throws RepositoryException,
                            QueryEvaluationException
Matches objects that have the given concept rdf:type. This method will include all objects that implement the given concept or a subclass of the concept. The concept must be a named concept and cannot be mapped to rdfs:Resource. The result of this method is not guaranteed to be unique and may continue duplicates. Use the Result.asSet() method to ensure uniqueness.

Throws:
RepositoryException
QueryEvaluationException
See Also:
addDesignation(Object, Class)

getObjects

public <T> Result<T> getObjects(Class<T> concept,
                                String... uris)
                     throws RepositoryException,
                            QueryEvaluationException
Throws:
RepositoryException
QueryEvaluationException

getObjects

public <T> Result<T> getObjects(Class<T> concept,
                                Resource... resources)
                     throws RepositoryException,
                            QueryEvaluationException
Loads the list of resources assumed to implement the given concept. The concept must be a named concept and cannot be mapped to rdfs:Resource.

Throws:
RepositoryException
QueryEvaluationException

prepareObjectQuery

public ObjectQuery prepareObjectQuery(QueryLanguage ql,
                                      String query,
                                      String baseURI)
                               throws MalformedQueryException,
                                      RepositoryException
Creates a new query that returns object(s).

Throws:
MalformedQueryException
RepositoryException

prepareObjectQuery

public ObjectQuery prepareObjectQuery(QueryLanguage ql,
                                      String query)
                               throws MalformedQueryException,
                                      RepositoryException
Creates a new query that returns object(s).

Throws:
MalformedQueryException
RepositoryException

prepareObjectQuery

public ObjectQuery prepareObjectQuery(String query)
                               throws MalformedQueryException,
                                      RepositoryException
Creates a new query that returns object(s).

Throws:
MalformedQueryException
RepositoryException


Copyright © 2004-2011 James Leigh Services Inc.. All Rights Reserved.