Class GatewayConnector


  • public class GatewayConnector
    extends java.lang.Object
    Class for connecting to HTTP resources and sending GET and POST requests. For each SMS there should be a separate instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      GatewayConnector()
      Constructor for GatewayConnector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean connect()
      Perform a connection (GET or POST, depending on configuration).
      void forgetCookie​(java.lang.String name, java.lang.String domain, java.lang.String path)
      Remove specified cookie from the cookie cache.
      byte[] getBinaryContent()
      Get binary response
      java.lang.String getTextContent()
      Get text response
      boolean isTextContent()
      True if received response is textual, false if binary
      void setConnection​(java.lang.String url, java.lang.String[] params, boolean doPost, java.lang.String[] postData)
      Prepare connector for a new connection.
      void setLanguage​(java.lang.String languageCode)
      Sets preferred language to retrieve web content.
      void setReferer​(java.lang.String referer)
      Set referer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GatewayConnector

        public GatewayConnector()
        Constructor for GatewayConnector.
    • Method Detail

      • isTextContent

        public boolean isTextContent()
        True if received response is textual, false if binary
      • getTextContent

        public java.lang.String getTextContent()
        Get text response
      • getBinaryContent

        public byte[] getBinaryContent()
        Get binary response
      • setReferer

        public void setReferer​(java.lang.String referer)
        Set referer. Default is empty string. Use null to clear referer.
      • setLanguage

        public void setLanguage​(java.lang.String languageCode)
        Sets preferred language to retrieve web content.
        Parameters:
        languageCode - two-letter language code as defined in ISO 639-1
      • forgetCookie

        public void forgetCookie​(java.lang.String name,
                                 java.lang.String domain,
                                 java.lang.String path)
        Remove specified cookie from the cookie cache. Removes all cookies that satisfies the requirements (the parameters). The parameters are handled like having logical AND between them. Any of the parameter may be null to mean "any value". Therefore all null parameters mean remove all cookies.
        Parameters:
        name - name of the cookie; may be null
        domain - domain of the cookie; may be null
        path - path of the cookie; may be null
      • setConnection

        public void setConnection​(java.lang.String url,
                                  java.lang.String[] params,
                                  boolean doPost,
                                  java.lang.String[] postData)
                           throws java.io.IOException
        Prepare connector for a new connection.
        Parameters:
        url - URL where to connect. If you specify params, this must not contain '?'.
        params - Additional parameters to the URL (aka query string). The array is in the form [key1,value1,key2,value2,...]. Use null or empty array for no parameters.
        doPost - true if this should be POST request; false if this should bet GET request
        postData - Data to be sent in the POST request. The array is in the form [key1,value1,key2,value2,...]. Use null or empty array for no data.
        Throws:
        java.lang.IllegalArgumentException - When url is null.
        java.io.IOException - When the url and params together does not create a correct URL.
      • connect

        public boolean connect()
                        throws java.io.IOException
        Perform a connection (GET or POST, depending on configuration).
        Throws:
        java.io.IOException - when there is a problem with connection