Class HttpQuery
- java.lang.Object
-
- org.apache.jena.sparql.engine.http.Params
-
- org.apache.jena.sparql.engine.http.HttpQuery
-
public class HttpQuery extends Params
Create an execution object for performing a query on a model over HTTP. This is the main protocol engine for HTTP query. There are higher level classes for doing a query and presenting the results in an API fashion. If the query string is large, then HTTP POST is used.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jena.sparql.engine.http.Params
Params.Pair
-
-
Field Summary
Fields Modifier and Type Field Description static inturlLimitThe definition of "large" queries
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamexec()Execute the operationorg.apache.http.client.HttpClientgetClient()Gets the HTTP client that is being used, may be null if no request has yet been madeintgetConnectTimeout()Gets the HTTP Connection timeoutjava.lang.StringgetContentType()Gets the Content Typeorg.apache.http.protocol.HttpContextgetContext()Gets the HTTP context that is being used, or sets and returns a defaultintgetReadTimeout()Gets the HTTP Read timeoutintgetResponseCode()Gets the HTTP Response Code returned by the request (returns 0 if request has yet to be made)java.lang.StringgetResponseMessage()Gets the HTTP Response Message returned by the request (returns null if request has yet to be made)voidsetAccept(java.lang.String contentType)Set the content type (Accept header) for the resultsvoidsetAllowCompression(boolean allow)Sets whether the HTTP request will include compressed encoding headervoidsetClient(org.apache.http.client.HttpClient client)Sets the client to usevoidsetConnectTimeout(int timeout)Sets HTTP Connection timeout, any value <= 0 is taken to mean no timeoutvoidsetContext(org.apache.http.protocol.HttpContext context)Sets the context to usevoidsetForcePOST()Force the use of HTTP POST for the query operationvoidsetReadTimeout(int timeout)Sets HTTP Read timeout, any value <= 0 is taken to mean no timeoutjava.lang.StringtoString()booleanusesPOST()Return whether this request will go by GET or POST
-
-
-
Method Detail
-
setAccept
public void setAccept(java.lang.String contentType)
Set the content type (Accept header) for the results- Parameters:
contentType- Accept content type
-
getContentType
public java.lang.String getContentType()
Gets the Content TypeIf the query has been made this reflects the Content-Type header returns, if it has not been made this reflects only the Accept header that will be sent (as set via the
setAccept(String)method)- Returns:
- Content Type
-
getResponseCode
public int getResponseCode()
Gets the HTTP Response Code returned by the request (returns 0 if request has yet to be made)- Returns:
- Response Code
-
getResponseMessage
public java.lang.String getResponseMessage()
Gets the HTTP Response Message returned by the request (returns null if request has yet to be made)- Returns:
- Response Message
-
setAllowCompression
public void setAllowCompression(boolean allow)
Sets whether the HTTP request will include compressed encoding header- Parameters:
allow- Whether to allow compressed encoding
-
setClient
public void setClient(org.apache.http.client.HttpClient client)
Sets the client to use- Parameters:
client- Client
-
setContext
public void setContext(org.apache.http.protocol.HttpContext context)
Sets the context to use- Parameters:
context- HTTP context
-
getClient
public org.apache.http.client.HttpClient getClient()
Gets the HTTP client that is being used, may be null if no request has yet been made- Returns:
- HTTP Client or null
-
getContext
public org.apache.http.protocol.HttpContext getContext()
Gets the HTTP context that is being used, or sets and returns a default- Returns:
- the
HttpContextin scope
-
usesPOST
public boolean usesPOST()
Return whether this request will go by GET or POST- Returns:
- boolean
-
setForcePOST
public void setForcePOST()
Force the use of HTTP POST for the query operation
-
setConnectTimeout
public void setConnectTimeout(int timeout)
Sets HTTP Connection timeout, any value <= 0 is taken to mean no timeout- Parameters:
timeout- Connection Timeout
-
getConnectTimeout
public int getConnectTimeout()
Gets the HTTP Connection timeout- Returns:
- Connection Timeout
-
setReadTimeout
public void setReadTimeout(int timeout)
Sets HTTP Read timeout, any value <= 0 is taken to mean no timeout- Parameters:
timeout- Read Timeout
-
getReadTimeout
public int getReadTimeout()
Gets the HTTP Read timeout- Returns:
- Read Timeout
-
exec
public java.io.InputStream exec() throws QueryExceptionHTTPExecute the operation- Returns:
- Model The resulting model
- Throws:
QueryExceptionHTTP
-
-