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

java.lang.Object
  extended by com.hp.hpl.jena.sparql.engine.http.Params
      extended by com.hp.hpl.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 com.hp.hpl.jena.sparql.engine.http.Params
Params.Pair
 
Field Summary
static int urlLimit
          The definition of "large" queries
 
Constructor Summary
HttpQuery(String serviceURL)
          Create a execution object for a whole model GET
HttpQuery(URL url)
          Create a execution object for a whole model GET
 
Method Summary
 InputStream exec()
          Execute the operation
 org.apache.http.client.HttpClient getClient()
          Gets the HTTP client that is being used, may be null if no request has yet been made
 int getConnectTimeout()
          Gets the HTTP Connection timeout
 String getContentType()
          Gets the Content Type
 int getReadTimeout()
          Gets the HTTP Read timeout
 int getResponseCode()
          Gets the HTTP Response Code returned by the request (returns 0 if request has yet to be made)
 String getResponseMessage()
          Gets the HTTP Response Message returned by the request (returns null if request has yet to be made)
 void setAccept(String contentType)
          Set the content type (Accept header) for the results
 void setAllowDeflate(boolean allow)
          Sets whether the HTTP request will include a Accept-Encoding: deflate header
 void setAllowGZip(boolean allow)
          Sets whether the HTTP request will include a Accept-Encoding: gzip header
 void setAuthenticator(HttpAuthenticator authenticator)
          Sets the authenticator to use
 void setBasicAuthentication(String user, char[] password)
          Sets basic authentication.
 void setConnectTimeout(int timeout)
          Sets HTTP Connection timeout, any value <= 0 is taken to mean no timeout
 void setForcePOST()
          Force the use of HTTP POST for the query operation
 void setReadTimeout(int timeout)
          Sets HTTP Read timeout, any value <= 0 is taken to mean no timeout
 boolean shouldShutdownClient()
          Gets whether the HTTP client used should be shutdown
 String toString()
           
 boolean usesPOST()
          Return whether this request will go by GET or POST
 
Methods inherited from class com.hp.hpl.jena.sparql.engine.http.Params
addParam, addParam, containsParam, count, getValue, getValues, httpString, merge, names, pairs, remove
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

urlLimit

public static int urlLimit
The definition of "large" queries

Constructor Detail

HttpQuery

public HttpQuery(String serviceURL)
Create a execution object for a whole model GET

Parameters:
serviceURL - The model

HttpQuery

public HttpQuery(URL url)
Create a execution object for a whole model GET

Parameters:
url - The model
Method Detail

setAccept

public void setAccept(String contentType)
Set the content type (Accept header) for the results

Parameters:
contentType - Accept content type

getContentType

public String getContentType()
Gets the Content Type

If 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 String getResponseMessage()
Gets the HTTP Response Message returned by the request (returns null if request has yet to be made)

Returns:
Response Message

setAllowGZip

public void setAllowGZip(boolean allow)
Sets whether the HTTP request will include a Accept-Encoding: gzip header

Parameters:
allow - Whether to allow GZip encoding

setAllowDeflate

public void setAllowDeflate(boolean allow)
Sets whether the HTTP request will include a Accept-Encoding: deflate header

Parameters:
allow - Whether to allow Deflate encoding

setBasicAuthentication

public void setBasicAuthentication(String user,
                                   char[] password)
Sets basic authentication. It may be preferable to use the setAuthenticator(HttpAuthenticator) method since that provides more flexibility in the type of authentication supported.

Parameters:
user - User name
password - Password

setAuthenticator

public void setAuthenticator(HttpAuthenticator authenticator)
Sets the authenticator to use

Parameters:
authenticator - Authenticator

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

shouldShutdownClient

public boolean shouldShutdownClient()
Gets whether the HTTP client used should be shutdown

Returns:
True if the client should be shutdown, false otherwise

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 InputStream exec()
                 throws QueryExceptionHTTP
Execute the operation

Returns:
Model The resulting model
Throws:
QueryExceptionHTTP

toString

public String toString()
Overrides:
toString in class Object


Licenced under the Apache License, Version 2.0