Class 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 int urlLimit
      The definition of "large" queries
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpQuery​(java.lang.String serviceURL)
      Create a execution object for a whole model GET
      HttpQuery​(java.net.URL url)
      Create a execution object for a whole model GET
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.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
      java.lang.String getContentType()
      Gets the Content Type
      org.apache.http.protocol.HttpContext getContext()
      Gets the HTTP context that is being used, or sets and returns a default
      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)
      java.lang.String getResponseMessage()
      Gets the HTTP Response Message returned by the request (returns null if request has yet to be made)
      void setAccept​(java.lang.String contentType)
      Set the content type (Accept header) for the results
      void setAllowCompression​(boolean allow)
      Sets whether the HTTP request will include compressed encoding header
      void setClient​(org.apache.http.client.HttpClient client)
      Sets the client to use
      void setConnectTimeout​(int timeout)
      Sets HTTP Connection timeout, any value <= 0 is taken to mean no timeout
      void setContext​(org.apache.http.protocol.HttpContext context)
      Sets the context to use
      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
      java.lang.String toString()  
      boolean usesPOST()
      Return whether this request will go by GET or POST
      • 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​(java.lang.String serviceURL)
        Create a execution object for a whole model GET
        Parameters:
        serviceURL - The model
      • HttpQuery

        public HttpQuery​(java.net.URL url)
        Create a execution object for a whole model GET
        Parameters:
        url - The model
    • 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 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 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 HttpContext in 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Params