public class Response
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENCODING_UTF8 |
static int |
STATUS_CODE_ERROR |
static int |
STATUS_CODE_NONE |
Constructor and Description |
---|
Response()
Default constructor
|
Response(int statusCode,
byte[] data)
Constructs a new object with the given status code and data
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getData()
Converts the response data into a String by using UTF-8 encoding.
|
java.lang.String |
getData(java.lang.String encoding)
Gets the data as String with the given encoding.
|
java.lang.Throwable |
getException()
Gets the exception which was thrown by request.
|
byte[] |
getRawData()
Gets the response data.
|
int |
getStatusCode()
Gets the response status code.
|
java.lang.String |
getStatusMessage()
Gets the response status message.
|
void |
setData(byte[] data)
Sets the response data.
|
void |
setException(java.lang.Throwable exc)
Sets the exception.
|
void |
setStatusCode(int code)
Sets the status code.
|
void |
setStatusMessage(java.lang.String message)
Sets the status message.
|
java.lang.String |
toString() |
public static final java.lang.String ENCODING_UTF8
public static final int STATUS_CODE_ERROR
public static final int STATUS_CODE_NONE
public Response()
public Response(int statusCode, byte[] data)
statusCode
- - the received codedata
- - the received datapublic void setStatusCode(int code)
code
- public void setStatusMessage(java.lang.String message)
message
- public void setData(byte[] data)
data
- - received data.public void setException(java.lang.Throwable exc)
exc
- - an exception that was thrown during the request.public int getStatusCode()
public java.lang.String getStatusMessage()
public byte[] getRawData()
public java.lang.String getData()
public java.lang.String getData(java.lang.String encoding) throws java.io.UnsupportedEncodingException
encoding
- - to be used to convert data into the String.java.io.UnsupportedEncodingException
- - if the data cannot be converted to the string.public java.lang.Throwable getException()
Throwable
public java.lang.String toString()
toString
in class java.lang.Object