|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.alarexgroup.m2mplf.net.http.HttpCommunicator
public class HttpCommunicator
Class communicates throughHTTP protocol.
Example: simple request to method GET
HttpCommunicator com = new HttpCommunicator("bearer_type=gprs;access_point=internet;timeout=40");
|
HttpCommunicator com = new HttpCommunicator("bearer_type=gprs;access_point=internet;timeout=40");
|
| Field Summary | |
|---|---|
static int |
ERROR_CODE_ALL_OK
all right |
static int |
ERROR_CODE_CONNECTION_NOT_FOUND
connection is not possible |
static int |
ERROR_CODE_INVALID_PARAMETERS
wrong URL form or connectionProfile |
static int |
ERROR_CODE_INVALID_STATE
error of HTTP communicator's state |
static int |
ERROR_CODE_IO_EXCEPTION
IO exception |
static int |
ERROR_CODE_SECURITY_EXCEPTION
J2ME security exception |
static int |
ERROR_CODE_UNKNOWN_ERROR
unknown error |
static java.lang.String |
METHOD_GET
HTTP QUERY METHOD - GET |
static java.lang.String |
METHOD_HEAD
HTTP QUERY METHOD - HEAD |
static java.lang.String |
METHOD_POST
HTTP QUERY METHOD - POST |
static int |
STATE_CLOSED
communicator logged off |
static int |
STATE_CREATED
communicator created |
static int |
STATE_DATA_RECEIVED
Answer received |
static int |
STATE_DATA_RECEIVING
Answer receiving |
static int |
STATE_DATA_SENDING
Data sending |
static int |
STATE_DATA_SENT
data was send |
static int |
STATE_HEAD_COMPLETED
HTTP header finalized |
static int |
STATE_INIT
communicator initialized |
| Constructor Summary | |
|---|---|
HttpCommunicator()
Creates new communicatro |
|
HttpCommunicator(java.lang.String connectionProfile)
Creates new communicatro - connectionProfile already set |
|
| Method Summary | |
|---|---|
int |
addHeaderProperty(java.lang.String key,
java.lang.String value)
Appends a parameter to HTTP header. |
int |
closeConnection()
This method closes connection. |
java.io.DataInputStream |
getDataInputStream()
Returns InputStream, which includes answer to HTTP request. |
java.io.DataOutputStream |
getDataOutputStream()
Returns OutputStream for data sending. |
int |
getErrorCode()
Returns error code |
java.lang.String |
getMethod()
Returns HTTP Method |
java.lang.String |
getURL()
Returns URL request |
int |
openConnection(java.lang.String url,
java.lang.String method)
Opens connection |
byte[] |
receiveResponse()
This method returns loaded answer as an array of bytes. |
int |
sendRequest()
Completes OutpuStream's content sending and returns HTTP response code |
int |
sendRequest(byte[] message)
Sends array of bytes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String METHOD_POST
public static final java.lang.String METHOD_GET
public static final java.lang.String METHOD_HEAD
public static final int ERROR_CODE_ALL_OK
public static final int ERROR_CODE_CONNECTION_NOT_FOUND
public static final int ERROR_CODE_INVALID_PARAMETERS
public static final int ERROR_CODE_SECURITY_EXCEPTION
public static final int ERROR_CODE_IO_EXCEPTION
public static final int ERROR_CODE_INVALID_STATE
public static final int ERROR_CODE_UNKNOWN_ERROR
public static final int STATE_CREATED
public static final int STATE_INIT
public static final int STATE_HEAD_COMPLETED
public static final int STATE_DATA_SENDING
public static final int STATE_DATA_SENT
public static final int STATE_DATA_RECEIVING
public static final int STATE_DATA_RECEIVED
public static final int STATE_CLOSED
| Constructor Detail |
|---|
public HttpCommunicator()
public HttpCommunicator(java.lang.String connectionProfile)
connectionProfile - - example: bearer_type=gprs;access_point=internet;username=someone;password=something;timeout=40| Method Detail |
|---|
public int openConnection(java.lang.String url,
java.lang.String method)
url - - url example: http://www.google.commethod - - HTTP method - METHOD_GET, METHOD_POST
METHOD_GET,
METHOD_POST,
METHOD_HEAD
public int addHeaderProperty(java.lang.String key,
java.lang.String value)
key - - name of HTTP parametervalue - - value of HTTP parameter
public java.io.DataOutputStream getDataOutputStream()
public java.io.DataInputStream getDataInputStream()
public int sendRequest()
public int sendRequest(byte[] message)
message - - dates
public byte[] receiveResponse()
public int closeConnection()
public java.lang.String getURL()
public java.lang.String getMethod()
public int getErrorCode()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||