Class HttpTransactionQueryBase

    • Constructor Detail

      • HttpTransactionQueryBase

        public HttpTransactionQueryBase()
        Constructor
    • Method Detail

      • setUrl

        public void setUrl​(String url)
        Set search URL
        Parameters:
        url - URL string
      • setUrl

        public void setUrl​(URL url)
        Set search URL
        Parameters:
        url - URL object
      • getUrl

        public String getUrl()
        Fetch the current search URL
        Specified by:
        getUrl in class QueryBase
        Returns:
        The URL (as a String)
      • setSearchString

        public void setSearchString​(String searchString)
        Specify the search text
        Parameters:
        searchString - Text to look for
      • getSearchString

        public String getSearchString()
        Fetch the current search text
        Specified by:
        getSearchString in class QueryBase
        Returns:
        The search string
      • getQueryMethod

        public String getQueryMethod()
        Fetch the current HTTP query method
        Returns:
        The method (as text)
      • getResponseHeader

        public String getResponseHeader​(String name)
        Fetch a named HTTP response parameter
        Parameters:
        name - Parameter name
        Returns:
        Parameter value
      • setDefaultCharacterSet

        public void setDefaultCharacterSet​(String cs)
        Set the default character set for this transaction
        Parameters:
        cs - Character set (UTF-8, ISO-8859-1, etc)
      • getResponseCharacterSet

        public String getResponseCharacterSet()
        Fetch the response character set
        Returns:
        Character set designation (as a String)
      • setQueryUrl

        public void setQueryUrl​(String consumer,
                                String queryUrl)
        Save the URL for the query page
        Parameters:
        consumer - A unique name for the "user" of this object
        queryUrl - Address of the final query page
      • getQueryUrl

        public String getQueryUrl​(String consumer)
        Fetch the URL for the query
        Parameters:
        consumer - A unique name for the "user" of this object
        Returns:
        Address of the final query page
      • removeQueryUrl

        public void removeQueryUrl​(String consumer)
        Delete a stored query URL
        Parameters:
        consumer - A unique name for the "user" of this object
      • setQueryDocument

        public void setQueryDocument​(String consumer,
                                     Document queryForm)
        Save the final query form as a DOM document
        Parameters:
        consumer - A unique name for the "user" of this object
        queryForm - Query page as a DOM document
      • getQueryDocument

        public Document getQueryDocument​(String consumer)
        Fetch the final query form as a DOM document
        Parameters:
        consumer - A unique name for the "user" of this object
        Returns:
        Query form (as a DOM document)
      • setSessionParameter

        public void setSessionParameter​(String consumer,
                                        String name,
                                        String value)
        Save a general purpose parameter
        Parameters:
        consumer - A unique name for the "user" of this object
        name - Parameter name
        value - Parameter value
      • getSessionParameter

        public String getSessionParameter​(String consumer,
                                          String name)
        Fetch the requested general purpose parameter
        Parameters:
        consumer - A unique name for the "user" of this object
        name - Parameter name
        Returns:
        Parameter value (null if none)
      • setSessionValue

        public void setSessionValue​(String consumer,
                                    String name,
                                    Object value)
        Save a general purpose parameter
        Parameters:
        consumer - A unique name for the "user" of this object
        name - Parameter name
        value - Parameter value
      • removeSessionParameter

        public void removeSessionParameter​(String consumer,
                                           String name)
        Delete the requested general purpose parameter
        Parameters:
        consumer - A unique name for the "user" of this object
        name - Parameter name
      • getSessionValue

        public Object getSessionValue​(String consumer,
                                      String name)
        Fetch the requested general purpose parameter
        Parameters:
        consumer - A unique name for the "user" of this object
        name - Parameter name
        Returns:
        Parameter value (null if none)
      • getSessionContext

        public SessionContext getSessionContext()
        Get the SessionContext object for this user
        Returns:
        The current SessionContext
      • setRedirectBehavior

        public void setRedirectBehavior​(int behavior)
                                 throws SearchException
        Establish a mechanism for handling redirects
        Specified by:
        setRedirectBehavior in interface HttpTransactionQueryInterface
        Parameters:
        behavior - Specifies the desired behavior. Use one of:
        • REDIRECT_AUTOMATIC - URLConnection handles all redirects
        • REDIRECT_MANAGED - The submit() code handles any redirects
        • REDIRECT_MANAGED_SINGLESTEP - The caller will handle each redirect
        Throws:
        SearchException
      • setPreserveBaseUrlFile

        public void setPreserveBaseUrlFile​(boolean state)
        Set the "file preservation state" for getBaseUrlSpecification()
        Parameters:
        state - true to preserve URL file portion
      • getFollowRedirects

        public boolean getFollowRedirects()
        Should URLConnection follow redirects?
        Returns:
        true if URLConnection should handle redirects
      • setParameter

        public void setParameter​(String name,
                                 String value)
        Set up a name=value pair
        Parameters:
        name - Parameter name
        value - Parameter value
      • getParameter

        public String getParameter​(String name)
        Get a named parameter
        Parameters:
        name - Parameter name
        Returns:
        Parameter value
      • getParameterName

        public String getParameterName​(String value)
        Get the parameter name associated with the 1st occurance of this value
        Parameters:
        value - Parameter value
        Returns:
        Parameter name
      • clearParameters

        public void clearParameters()
        Clear the parameter list
      • submit

        public int submit()
                   throws SearchException
        Submit a request (POST or GET) and read the response. Various aspects of the response can be inspected using the "getXXX()" methods.
        Returns:
        Submission status code (200 = success)
        Throws:
        SearchException
      • getResponseBytes

        public byte[] getResponseBytes()
        Get the server response text
        Specified by:
        getResponseBytes in interface QueryInterface
        Returns:
        The response (as a byte array)
      • getBody

        public Element getBody​(Document pageDocument)
        Locate the HTML BODY element in the page document
        Parameters:
        pageDocument - An HTML page (as a DOM)
        Returns:
        The body Element
      • newFullUrl

        public URL newFullUrl​(String baseComponent,
                              String relativeComponent)
        Construct a new URL from base and relative components
        Parameters:
        baseComponent - Base URL - the relative URL is added to this
        relativeComponent - A partial (or full) URL that represents our target
        Returns:
        A full URL composed of the relative URL combined with "missing" portions taken from the base
      • setParametersFromInputs

        public void setParametersFromInputs​(Document pageDocument,
                                            List nameList)
        Deprecated.
        Replaced by #setParametersFromInputNames()
        Set query parameters based on page-wide INPUTs
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        nameList - A list of the parameters we're looking for
      • setParametersFromInputNames

        public void setParametersFromInputNames​(Document pageDocument,
                                                List nameList)
        Set query parameters based on page-wide INPUTs
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        nameList - A list of the parameters we're looking for
      • setParametersFromInputValues

        public void setParametersFromInputValues​(Document pageDocument,
                                                 List nameList)
        Set query parameters based on page-wide INPUTs
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        nameList - A list of the parameters we're looking for
      • setParametersFromFormInputs

        public void setParametersFromFormInputs​(Document pageDocument,
                                                String formName,
                                                List nameList)
                                         throws SearchException
        Produce a target URL for this query by combining the form "action" value with the base URL of the query page
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        formName - The name of the FORM to lookup (eg FORM name="formName")
        nameList - A list of the parameters we're looking for
        Throws:
        SearchException
      • setParametersFromNameList

        public void setParametersFromNameList​(NodeList nodeList,
                                              List nameList)
        Set query parameters based on element names (save name=value pairs)
        Parameters:
        nodeList - List of Elements to evaluate
        nameList - A list of the parameters we're looking for
      • setParametersFromValueList

        public void setParametersFromValueList​(NodeList nodeList,
                                               List nameList)
        Set query parameters based on element values (save name=value pairs)
        Parameters:
        nodeList - List of Elements to evaluate
        nameList - A list of the parameters we're looking for
      • setUrlFromAnchor

        public void setUrlFromAnchor​(Element anchor)
                              throws SearchException
        Produce a target URL for this query by combining an anchor "href" value with the base URL of the query page
        Parameters:
        anchor - Anchor element
        Throws:
        SearchException
      • setUrlFromForm

        public void setUrlFromForm​(Document pageDocument,
                                   String formName)
                            throws SearchException
        Produce a target URL for this query by combining the form "action" value with the base URL of the query page
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        formName - The name of the FORM to lookup (eg FORM name="formName")
        Throws:
        SearchException
      • getFormElement

        public Element getFormElement​(Document pageDocument,
                                      String formName)
        Find a named FORM element
        Parameters:
        pageDocument - The search engine query page (as a DOM Document)
        formName - The name of the FORM to lookup (eg FORM name="formName")