org.jrdf.sparql
Class DefaultSparqlConnection

java.lang.Object
  extended byorg.jrdf.sparql.DefaultSparqlConnection
All Implemented Interfaces:
JrdfConnection, SparqlConnection

public final class DefaultSparqlConnection
extends Object
implements SparqlConnection

Default implementation of a SparqlConnection.

Version:
$Revision: 1.1 $
Author:
Tom Adams

Constructor Summary
DefaultSparqlConnection(Graph graph, URI securityDomain)
          Creates a new SPARQL connection.
 
Method Summary
 void close()
          Closes the connection to the graph.
 Answer executeQuery(String query)
          Executes a query that returns results.
protected  void finalize()
          Attempt to close the underlying session in case the client did not.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSparqlConnection

public DefaultSparqlConnection(Graph graph,
                               URI securityDomain)
Creates a new SPARQL connection.

Parameters:
graph - The graph to query.
securityDomain - The security domain of the graph.
Method Detail

executeQuery

public Answer executeQuery(String query)
                    throws InvalidQuerySyntaxException,
                           JrdfConnectionException
Executes a query that returns results.

Specified by:
executeQuery in interface JrdfConnection
Parameters:
query - The query to execute.
Returns:
The answer to the query, will never be null.
Throws:
InvalidQuerySyntaxException - If the syntax of the query is incorrect.
JrdfConnectionException - If an error occurs while executing the query.

close

public void close()
Closes the connection to the graph.

Calling this method will close the underlying Graph, making it unusable for future use.

Specified by:
close in interface JrdfConnection

finalize

protected void finalize()
                 throws Throwable
Attempt to close the underlying session in case the client did not.

Clients should not rely on this method being called, it is only here as a last minute check to see if any cleanup can be performed. This method is not guarenteed to be executed by the JVM.

Throws:
Throwable - An unknown error occurs, possibly in object finalisation.