public class QueryEngineHTTP extends Object implements QueryExecution
| Modifier and Type | Field and Description |
|---|---|
static String |
QUERY_MIME_TYPE |
static String[] |
supportedAskContentTypes
Supported content types for ASK queries
|
static String[] |
supportedSelectContentTypes
Supported content types for SELECT queries
|
| Constructor and Description |
|---|
QueryEngineHTTP(String serviceURI,
Query query) |
QueryEngineHTTP(String serviceURI,
Query query,
org.apache.http.client.HttpClient client) |
QueryEngineHTTP(String serviceURI,
Query query,
org.apache.http.client.HttpClient client,
org.apache.http.protocol.HttpContext httpContext) |
QueryEngineHTTP(String serviceURI,
String queryString) |
QueryEngineHTTP(String serviceURI,
String queryString,
org.apache.http.client.HttpClient client) |
QueryEngineHTTP(String serviceURI,
String queryString,
org.apache.http.client.HttpClient client,
org.apache.http.protocol.HttpContext httpContext) |
| Modifier and Type | Method and Description |
|---|---|
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 |
defaultConstructDatasetHeader() |
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'.
|
Dataset |
execConstructDataset()
Execute a CONSTRUCT query, putting the statements into 'dataset'.
|
Dataset |
execConstructDataset(Dataset dataset)
Execute a CONSTRUCT query, putting the statements into 'dataset'.
|
Iterator<Quad> |
execConstructQuads()
Execute a CONSTRUCT query, returning the results as an iterator of
Quad. |
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. |
JsonArray |
execJson()
Execute a JSON query and return a json array
|
Iterator<JsonObject> |
execJsonItems()
Execute a JSON query and return an interator
|
ResultSet |
execSelect()
Execute a SELECT query
|
String |
getAcceptHeader()
Get the HTTP Accept header for the request.
|
boolean |
getAllowCompression()
Gets whether HTTP requests will indicate to the remote server that
compressed encoding of responses is accepted
|
org.apache.http.client.HttpClient |
getClient()
Get the HTTP client in use, if none is set then null.
|
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.
|
org.apache.http.protocol.HttpContext |
getHttpContext()
Get the HTTP context in use, if none is set then null.
|
String |
getHttpResponseContentType()
The Content-Type response header received (null before the remote operation is attempted).
|
Query |
getQuery()
The query associated with a query execution.
|
String |
getQueryString()
Return the query string.
|
long |
getTimeout1()
Return the first timeout (time to first result), in milliseconds: negative if unset
|
long |
getTimeout2()
Return the second timeout (overall query execution after first result), in milliseconds: negative if unset
|
boolean |
isClosed()
Answer whether this QueryExecution object has been closed or not.
|
void |
setAcceptHeader(String acceptHeader)
Set the HTTP Accept header for the request.
|
void |
setAllowCompression(boolean allowed)
Sets whether the HTTP requests will permit compressed encoding
|
void |
setAskContentType(String contentType)
Sets the Content Type for ASK queries provided that the format is
supported
|
void |
setClient(org.apache.http.client.HttpClient client)
Sets the HTTP client to use, if none is set then the default
client is used.
|
void |
setDatasetContentType(String contentType) |
void |
setDefaultGraphURIs(List<String> defaultGraphURIs) |
void |
setHttpContext(org.apache.http.protocol.HttpContext context)
Sets the HTTP context to use, if none is set then the default context is used.
|
void |
setInitialBinding(Binding binding)
Set the initial association of variables and values.
|
void |
setInitialBinding(QuerySolution binding)
Set the initial association of variables and values.
|
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() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitcreatepublic static final String QUERY_MIME_TYPE
public static String[] supportedSelectContentTypes
public static String[] supportedAskContentTypes
public QueryEngineHTTP(String serviceURI, Query query, org.apache.http.client.HttpClient client)
public QueryEngineHTTP(String serviceURI, Query query, org.apache.http.client.HttpClient client, org.apache.http.protocol.HttpContext httpContext)
public QueryEngineHTTP(String serviceURI, String queryString, org.apache.http.client.HttpClient client)
public void setInitialBinding(QuerySolution binding)
QueryExecutionsetInitialBinding in interface QueryExecutionpublic void setInitialBinding(Binding binding)
QueryExecutionsetInitialBinding in interface QueryExecutionpublic void setDefaultGraphURIs(List<String> defaultGraphURIs)
defaultGraphURIs - The defaultGraphURIs to set.public void setNamedGraphURIs(List<String> namedGraphURIs)
namedGraphURIs - The namedGraphURIs to set.public void setAllowCompression(boolean allowed)
public void addDefaultGraph(String defaultGraph)
defaultGraph - The defaultGraph to add.public void addNamedGraph(String name)
name - The URI to add.public void setClient(org.apache.http.client.HttpClient client)
client - HTTP clientpublic org.apache.http.client.HttpClient getClient()
public void setHttpContext(org.apache.http.protocol.HttpContext context)
context - HTTP contextpublic org.apache.http.protocol.HttpContext getHttpContext()
HttpContext in scopepublic String getHttpResponseContentType()
public ResultSet execSelect()
QueryExecutionImportant: 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.
execSelect in interface QueryExecutionpublic Model execConstruct()
QueryExecutionexecConstruct in interface QueryExecutionpublic Model execConstruct(Model model)
QueryExecutionexecConstruct in interface QueryExecutionpublic Iterator<Triple> execConstructTriples()
QueryExecutionTriple.
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.
execConstructTriples in interface QueryExecutionpublic Iterator<Quad> execConstructQuads()
QueryExecutionQuad.
Caution: This method may return duplicate Quads. 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.
execConstructQuads in interface QueryExecution
See QueryExecution.execConstructTriples() for usage and features.
public Dataset execConstructDataset()
QueryExecutionexecConstructDataset in interface QueryExecutionpublic Dataset execConstructDataset(Dataset dataset)
QueryExecutionexecConstructDataset in interface QueryExecutionpublic Model execDescribe()
QueryExecutionexecDescribe in interface QueryExecutionpublic Model execDescribe(Model model)
QueryExecutionexecDescribe in interface QueryExecutionpublic Iterator<Triple> execDescribeTriples()
QueryExecutionTriple.
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.
execDescribeTriples in interface QueryExecutionpublic boolean execAsk()
QueryExecutionexecAsk in interface QueryExecutionpublic JsonArray execJson()
QueryExecutionexecJson in interface QueryExecutionpublic Iterator<JsonObject> execJsonItems()
QueryExecutionexecJsonItems in interface QueryExecutionpublic Context getContext()
QueryExecutiongetContext in interface QueryExecutionpublic Dataset getDataset()
QueryExecutiongetDataset in interface QueryExecutionpublic Query getQuery()
QueryExecutiongetQuery in interface QueryExecutionpublic String getQueryString()
public void setTimeout(long readTimeout)
QueryExecutionsetTimeout in interface QueryExecutionQueryExecution.setTimeout(long, TimeUnit)public void setTimeout(long readTimeout,
long connectTimeout)
QueryExecutionsetTimeout in interface QueryExecutionQueryExecution.setTimeout(long, TimeUnit, long, TimeUnit)public void setTimeout(long readTimeout,
TimeUnit timeoutUnits)
QueryExecutionsetTimeout in interface QueryExecutionpublic void setTimeout(long timeout1,
TimeUnit timeUnit1,
long timeout2,
TimeUnit timeUnit2)
QueryExecutionsetTimeout in interface QueryExecutionpublic long getTimeout1()
QueryExecutiongetTimeout1 in interface QueryExecutionpublic long getTimeout2()
QueryExecutiongetTimeout2 in interface QueryExecutionpublic boolean getAllowCompression()
public void cancel()
public void abort()
QueryExecutionabort in interface QueryExecutionpublic void close()
QueryExecutionResultSet from QueryExecution.execSelect(),
can not be used once the QueryExecution is closed.
Model results from QueryExecution.execConstruct() and QueryExecution.execDescribe()
are still valid.
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.close in interface AutoCloseableclose in interface QueryExecutionpublic boolean isClosed()
QueryExecutionisClosed in interface QueryExecutionpublic void setSelectContentType(String contentType)
contentType - public void setAskContentType(String contentType)
contentType - public void setModelContentType(String contentType)
contentType - public void setDatasetContentType(String contentType)
public static String defaultSelectHeader()
public static String defaultAskHeader()
public static String defaultConstructHeader()
public static String defaultConstructDatasetHeader()
public String getAcceptHeader()
public void setAcceptHeader(String acceptHeader)
set??ContentType operations, this is not checked
for validity.Licenced under the Apache License, Version 2.0