public class ServerResponse
extends java.lang.Object
Class providing the structure of a HTTP response as recieved from the Branch API.
Supports the following methods:Constructor and Description |
---|
ServerResponse(java.lang.String tag,
int statusCode)
Main constructor method for the
ServerResponse class that allows for the instantiation
of a server response object as a direct result of a server call. |
Modifier and Type | Method and Description |
---|---|
org.json.JSONArray |
getArray()
Checks whether the post data associated with the current request is an instance of a
JSONArray object, and if so type-casts it to the corresponding class type. |
java.lang.String |
getFailReason()
Get the reason for failure if there any
|
org.json.JSONObject |
getObject()
Checks whether the post data associated with the current request is an instance of a
JSONObject object, and if so type-casts it to the corresponding class type. |
int |
getStatusCode()
Gets the HttpStatus code of the current response.
|
java.lang.String |
getTag()
Gets the
String value of the Tag attribute of the current link. |
void |
setPost(java.lang.Object post)
Sets the post data attached to the current server request, as a generic
Object
instance. |
public ServerResponse(java.lang.String tag, int statusCode)
Main constructor method for the ServerResponse
class that allows for the instantiation
of a server response object as a direct result of a server call.
tag
- A String
value of the Tag attribute of the current link.statusCode
- Integer
value of the HTTP status code.public java.lang.String getTag()
Gets the String
value of the Tag attribute of the current link.
String
value of the Tag attribute of the current link.public int getStatusCode()
Gets the HttpStatus code of the current response.
Integer
value of the HTTP status code.public void setPost(java.lang.Object post)
Sets the post data attached to the current server request, as a generic Object
instance. This object can be type-cast by other methods within this class:
post
- Generic Object
instance containing post data associated with current
response.public org.json.JSONObject getObject()
Checks whether the post data associated with the current request is an instance of a
JSONObject
object, and if so type-casts it to the corresponding class type.
JSONObject
containing the post data sent with a server request, or an empty JsonObject
if the post data is not of the JSONObject
type or null.public org.json.JSONArray getArray()
Checks whether the post data associated with the current request is an instance of a
JSONArray
object, and if so type-casts it to the corresponding class type.
JSONArray
containing the post data sent with a server request, or a null
value if the post data is not of the JSONArray
type.public java.lang.String getFailReason()
String
value with failure reason