Package esmska.transfer
Class GatewayConnector
- java.lang.Object
-
- esmska.transfer.GatewayConnector
-
public class GatewayConnector extends java.lang.ObjectClass 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 booleanconnect()Perform a connection (GET or POST, depending on configuration).voidforgetCookie(java.lang.String name, java.lang.String domain, java.lang.String path)Remove specified cookie from the cookie cache.byte[]getBinaryContent()Get binary responsejava.lang.StringgetTextContent()Get text responsebooleanisTextContent()True if received response is textual, false if binaryvoidsetConnection(java.lang.String url, java.lang.String[] params, boolean doPost, java.lang.String[] postData)Prepare connector for a new connection.voidsetLanguage(java.lang.String languageCode)Sets preferred language to retrieve web content.voidsetReferer(java.lang.String referer)Set referer.
-
-
-
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 nulldomain- domain of the cookie; may be nullpath- 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.IOExceptionPrepare 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 requestpostData- 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.IOExceptionPerform a connection (GET or POST, depending on configuration).- Throws:
java.io.IOException- when there is a problem with connection
-
-