public static class RemoteCommand.Response
extends java.lang.Object
RemoteCommand
respond to a TagBridge request.
This class can only send a single response, if multiple responses are
attempted an IllegalStateException
will be thrown on any send and
set operations.Modifier and Type | Field and Description |
---|---|
static int |
STATUS_BAD_REQUEST
Suggested value for
setStatus(int) when
getRequestPayload() does not provide the expected
arguments. |
static int |
STATUS_OK
Suggested value for
setStatus(int) when the
operation was performed successfully. |
Constructor and Description |
---|
Response(java.lang.String commandId,
java.lang.String responseId,
org.json.JSONObject requestPayload) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getBody() |
java.lang.String |
getCommandId() |
java.lang.String |
getId() |
org.json.JSONObject |
getRequestPayload() |
int |
getStatus() |
boolean |
isSent() |
void |
send()
Invokes the TagBridge callback.
|
RemoteCommand.Response |
setBody(java.lang.String body) |
RemoteCommand.Response |
setStatus(int status) |
public static final int STATUS_BAD_REQUEST
setStatus(int)
when
getRequestPayload()
does not provide the expected
arguments.public static final int STATUS_OK
setStatus(int)
when the
operation was performed successfully.
This is the default value.public Response(java.lang.String commandId, java.lang.String responseId, org.json.JSONObject requestPayload)
commandId
- The TagBridge request command id.responseId
- A response id or null.requestPayload
- A parsed JSONObject of the TagBridge Request Payload or
null. If null, an empty JSONObject is returned by
getRequestPayload()
.java.lang.IllegalArgumentException
- when mCommandId is null.public final java.lang.String getCommandId()
RemoteCommand
instance's command name this object has
been passed to.public final java.lang.String getId()
public final boolean isSent()
send()
was called.public final org.json.JSONObject getRequestPayload()
JSONObject
is provided.public final int getStatus()
setStatus(int)
,
STATUS_OK
by default.public final RemoteCommand.Response setStatus(int status)
status
- to be returned to the TagBridge callback, typically
STATUS_OK
or
STATUS_BAD_REQUEST
.java.lang.IllegalStateException
- when send()
has already been called.public final java.lang.String getBody()
public final RemoteCommand.Response setBody(java.lang.String body)
body
- to be returned to the TagBridge callback, can be any
string or null.java.lang.IllegalStateException
- when send()
has already been called.public void send()
setStatus(int)
and setBody(String)
are passed as the argument to
the callback.java.lang.IllegalStateException
- when multiple calls of this method are attempted.