com.hp.hpl.jena.sparql.engine.http
Class QueryEngineHTTP

java.lang.Object
  extended by com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP
All Implemented Interfaces:
QueryExecution

public class QueryEngineHTTP
extends Object
implements QueryExecution

A query execution implementation where queries are executed against a remote service


Field Summary
static String QUERY_MIME_TYPE
           
static String[] supportedAskContentTypes
          Supported content types for ASK queries
static String[] supportedSelectContentTypes
          Supported content types for SELECT queries
 
Constructor Summary
QueryEngineHTTP(String serviceURI, Query query)
           
QueryEngineHTTP(String serviceURI, Query query, HttpAuthenticator authenticator)
           
QueryEngineHTTP(String serviceURI, String queryString)
           
QueryEngineHTTP(String serviceURI, String queryString, HttpAuthenticator authenticator)
           
 
Method Summary
 void abort()
          Stop in mid execution.
 void addDefaultGraph(String defaultGraph)
           
 void addNamedGraph(String name)
           
 void addParam(String field, String value)
           
 void cancel()
          Cancel query evaluation
 void close()
          Close the query execution and stop query evaluation as soon as convenient.
static String defaultAskHeader()
           
static String defaultConstructHeader()
           
static String defaultSelectHeader()
           
 boolean execAsk()
          Execute an ASK query
 Model execConstruct()
          Execute a CONSTRUCT query
 Model execConstruct(Model model)
          Execute a CONSTRUCT query, putting the statements into 'model'.
 Iterator<Triple> execConstructTriples()
          Execute a CONSTRUCT query, returning the results as an iterator of Triple.
 Model execDescribe()
          Execute a DESCRIBE query
 Model execDescribe(Model model)
          Execute a DESCRIBE query, putting the statements into 'model'.
 Iterator<Triple> execDescribeTriples()
          Execute a DESCRIBE query, returning the results as an iterator of Triple.
 ResultSet execSelect()
          Execute a SELECT query
 boolean getAllowDeflate()
          Gets whether HTTP requests will indicate to the remote server that Deflate encoding of responses is accepted
 boolean getAllowGZip()
          Gets whether HTTP requests will indicate to the remote server that GZip encoding of responses is accepted
 Context getContext()
          The properties associated with a query execution - implementation specific parameters This includes Java objects (so it is not an RDF graph).
 Dataset getDataset()
          The dataset against which the query will execute.
 Query getQuery()
          The query associated with a query execution.
 long getTimeout1()
          Return the first timeout (time to first result), in millseconds: negative if unset
 long getTimeout2()
          Return the second timeout (overall query execution after first result), in millseconds: negative if unset
 boolean isUsingBasicAuthentication()
          Gets whether an authentication mechanism has been provided.
 void setAllowDeflate(boolean allowed)
          Sets whether the HTTP requests will specify Accept-Encoding: deflate
 void setAllowGZip(boolean allowed)
          Sets whether the HTTP request will specify Accept-Encoding: gzip
 void setAskContentType(String contentType)
          Sets the Content Type for ASK queries provided that the format is supported
 void setAuthenticator(HttpAuthenticator authenticator)
          Sets the HTTP authenticator to use, if none is set then the default authenticator is used.
 void setBasicAuthentication(String user, char[] password)
          Set user and password for basic authentication.
 void setDefaultGraphURIs(List<String> defaultGraphURIs)
           
 void setFileManager(FileManager fm)
          Deprecated. 
 void setInitialBinding(QuerySolution binding)
          Set the initial association of variables and values.
 void setInitialBindings(ResultSet table)
           
 void setModelContentType(String contentType)
          Sets the Content Type for CONSTRUCT/DESCRIBE queries provided that the format is supported
 void setNamedGraphURIs(List<String> namedGraphURIs)
           
 void setSelectContentType(String contentType)
          Sets the Content Type for SELECT queries provided that the format is supported
 void setTimeout(long readTimeout)
          Set time, in milliseconds
 void setTimeout(long readTimeout, long connectTimeout)
          Set time, in milliseconds
 void setTimeout(long readTimeout, TimeUnit timeoutUnits)
          Set a timeout on the query execution.
 void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
          Set timeouts on the query execution; the first timeout refers to time to first result, the second refers to overall query execution after the first result.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_MIME_TYPE

public static final String QUERY_MIME_TYPE
See Also:
Constant Field Values

supportedSelectContentTypes

public static String[] supportedSelectContentTypes
Supported content types for SELECT queries


supportedAskContentTypes

public static String[] supportedAskContentTypes
Supported content types for ASK queries

Constructor Detail

QueryEngineHTTP

public QueryEngineHTTP(String serviceURI,
                       Query query)

QueryEngineHTTP

public QueryEngineHTTP(String serviceURI,
                       Query query,
                       HttpAuthenticator authenticator)

QueryEngineHTTP

public QueryEngineHTTP(String serviceURI,
                       String queryString)

QueryEngineHTTP

public QueryEngineHTTP(String serviceURI,
                       String queryString,
                       HttpAuthenticator authenticator)
Method Detail

setFileManager

@Deprecated
public void setFileManager(FileManager fm)
Deprecated. 

Description copied from interface: QueryExecution
Set the FileManger that might be used to load files. May not be supported by all QueryExecution implementations.

Specified by:
setFileManager in interface QueryExecution

setInitialBinding

public void setInitialBinding(QuerySolution binding)
Description copied from interface: QueryExecution
Set the initial association of variables and values. May not be supported by all QueryExecution implementations.

Specified by:
setInitialBinding in interface QueryExecution

setInitialBindings

public void setInitialBindings(ResultSet table)

setDefaultGraphURIs

public void setDefaultGraphURIs(List<String> defaultGraphURIs)
Parameters:
defaultGraphURIs - The defaultGraphURIs to set.

setNamedGraphURIs

public void setNamedGraphURIs(List<String> namedGraphURIs)
Parameters:
namedGraphURIs - The namedGraphURIs to set.

setAllowGZip

public void setAllowGZip(boolean allowed)
Sets whether the HTTP request will specify Accept-Encoding: gzip


setAllowDeflate

public void setAllowDeflate(boolean allowed)
Sets whether the HTTP requests will specify Accept-Encoding: deflate


addParam

public void addParam(String field,
                     String value)

addDefaultGraph

public void addDefaultGraph(String defaultGraph)
Parameters:
defaultGraph - The defaultGraph to add.

addNamedGraph

public void addNamedGraph(String name)
Parameters:
name - The URI to add.

isUsingBasicAuthentication

public boolean isUsingBasicAuthentication()
Gets whether an authentication mechanism has been provided.

Even if this returns false authentication may still be used if the default authenticator applies, this is controlled via the HttpOp.setDefaultAuthenticator(HttpAuthenticator) method

Returns:
True if an authenticator has been provided

setBasicAuthentication

public void setBasicAuthentication(String user,
                                   char[] password)
Set user and password for basic authentication. After the request is made (one of the exec calls), the application can overwrite the password array to remove details of the secret.

Note that it may be more flexible to

Parameters:
user -
password -

setAuthenticator

public void setAuthenticator(HttpAuthenticator authenticator)
Sets the HTTP authenticator to use, if none is set then the default authenticator is used. This may be configured via the HttpOp.setDefaultAuthenticator(HttpAuthenticator) method.

Parameters:
authenticator - HTTP authenticator

execSelect

public ResultSet execSelect()
Description copied from interface: QueryExecution
Execute a SELECT query

Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the SELECT query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

Specified by:
execSelect in interface QueryExecution

execConstruct

public Model execConstruct()
Description copied from interface: QueryExecution
Execute a CONSTRUCT query

Specified by:
execConstruct in interface QueryExecution

execConstruct

public Model execConstruct(Model model)
Description copied from interface: QueryExecution
Execute a CONSTRUCT query, putting the statements into 'model'.

Specified by:
execConstruct in interface QueryExecution
Returns:
Model The model argument for casaded code.

execConstructTriples

public Iterator<Triple> execConstructTriples()
Description copied from interface: QueryExecution
Execute a CONSTRUCT query, returning the results as an iterator of Triple.

Caution: This method may return duplicate Triples. This method may be useful if you only need the results for stream processing, as it can avoid having to place the results in a Model.

Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the CONSTRUCT query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

Specified by:
execConstructTriples in interface QueryExecution
Returns:
An iterator of Triple objects (possibly containing duplicates) generated by applying the CONSTRUCT template of the query to the bindings in the WHERE clause.

execDescribe

public Model execDescribe()
Description copied from interface: QueryExecution
Execute a DESCRIBE query

Specified by:
execDescribe in interface QueryExecution

execDescribe

public Model execDescribe(Model model)
Description copied from interface: QueryExecution
Execute a DESCRIBE query, putting the statements into 'model'.

Specified by:
execDescribe in interface QueryExecution
Returns:
Model The model argument for cascaded code.

execDescribeTriples

public Iterator<Triple> execDescribeTriples()
Description copied from interface: QueryExecution
Execute a DESCRIBE query, returning the results as an iterator of Triple.

Caution: This method may return duplicate Triples. This method may be useful if you only need the results for stream processing, as it can avoid having to place the results in a Model.

Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the DESCRIBE query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

Specified by:
execDescribeTriples in interface QueryExecution
Returns:
An iterator of Triple objects (possibly containing duplicates) generated as the output of the DESCRIBE query.

execAsk

public boolean execAsk()
Description copied from interface: QueryExecution
Execute an ASK query

Specified by:
execAsk in interface QueryExecution

getContext

public Context getContext()
Description copied from interface: QueryExecution
The properties associated with a query execution - implementation specific parameters This includes Java objects (so it is not an RDF graph). Keys should be URIs as strings. May be null (this implementation does not provide any configuration).

Specified by:
getContext in interface QueryExecution

getDataset

public Dataset getDataset()
Description copied from interface: QueryExecution
The dataset against which the query will execute. May be null, implying it is expected that the query itself has a dataset description.

Specified by:
getDataset in interface QueryExecution

getQuery

public Query getQuery()
Description copied from interface: QueryExecution
The query associated with a query execution. May be null (QueryExecution may have been created by other means)

Specified by:
getQuery in interface QueryExecution

setTimeout

public void setTimeout(long readTimeout)
Description copied from interface: QueryExecution
Set time, in milliseconds

Specified by:
setTimeout in interface QueryExecution
See Also:
QueryExecution.setTimeout(long, TimeUnit)

setTimeout

public void setTimeout(long readTimeout,
                       long connectTimeout)
Description copied from interface: QueryExecution
Set time, in milliseconds

Specified by:
setTimeout in interface QueryExecution
See Also:
QueryExecution.setTimeout(long, TimeUnit, long, TimeUnit)

setTimeout

public void setTimeout(long readTimeout,
                       TimeUnit timeoutUnits)
Description copied from interface: QueryExecution
Set a timeout on the query execution. Processing will be aborted after the timeout (which starts when the approprate exec call is made). Not all query execution systems support timeouts. A timeout of less than zero means no timeout.

Specified by:
setTimeout in interface QueryExecution

setTimeout

public void setTimeout(long timeout1,
                       TimeUnit timeUnit1,
                       long timeout2,
                       TimeUnit timeUnit2)
Description copied from interface: QueryExecution
Set timeouts on the query execution; the first timeout refers to time to first result, the second refers to overall query execution after the first result. Processing will be aborted if a timeout expires. Not all query execution systems support timeouts. A timeout of less than zero means no timeout; this can be used for timeout1 or timeout2.

Specified by:
setTimeout in interface QueryExecution

getTimeout1

public long getTimeout1()
Description copied from interface: QueryExecution
Return the first timeout (time to first result), in millseconds: negative if unset

Specified by:
getTimeout1 in interface QueryExecution

getTimeout2

public long getTimeout2()
Description copied from interface: QueryExecution
Return the second timeout (overall query execution after first result), in millseconds: negative if unset

Specified by:
getTimeout2 in interface QueryExecution

getAllowGZip

public boolean getAllowGZip()
Gets whether HTTP requests will indicate to the remote server that GZip encoding of responses is accepted

Returns:
True if GZip encoding will be accepted

getAllowDeflate

public boolean getAllowDeflate()
Gets whether HTTP requests will indicate to the remote server that Deflate encoding of responses is accepted

Returns:
True if Deflate encoding will be accepted

cancel

public void cancel()
Cancel query evaluation


abort

public void abort()
Description copied from interface: QueryExecution
Stop in mid execution. This method can be called in parallel with other methods on the QueryExecution object. There is no guarantee that the concrete implementation actual will stop or that it will do so immediately. No operations on the query execution or any associated result set are permitted after this call and may cause exceptions to be thrown.

Specified by:
abort in interface QueryExecution

close

public void close()
Description copied from interface: QueryExecution
Close the query execution and stop query evaluation as soon as convenient. It is important to close query execution objects in order to release resources such as working memory and to stop the query execution. Some storage subsystems require explicit ends of operations and this operation will cause those to be called where necessary. No operations on the query execution or any associated result set are permitted after this call. This method should not be called in parallel with other methods on the QueryExecution object.

Specified by:
close in interface QueryExecution

toString

public String toString()
Overrides:
toString in class Object

setSelectContentType

public void setSelectContentType(String contentType)
Sets the Content Type for SELECT queries provided that the format is supported

Parameters:
contentType -

setAskContentType

public void setAskContentType(String contentType)
Sets the Content Type for ASK queries provided that the format is supported

Parameters:
contentType -

setModelContentType

public void setModelContentType(String contentType)
Sets the Content Type for CONSTRUCT/DESCRIBE queries provided that the format is supported

Parameters:
contentType -

defaultSelectHeader

public static String defaultSelectHeader()

defaultAskHeader

public static String defaultAskHeader()

defaultConstructHeader

public static String defaultConstructHeader()


Licenced under the Apache License, Version 2.0