public class Response extends SampMap
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ERROR_KEY
Key for error map.
|
static java.lang.String |
ERROR_STATUS
STATUS_KEY value indicating failure. |
private static java.lang.String[] |
KNOWN_KEYS |
static java.lang.String |
OK_STATUS
STATUS_KEY value indicating success. |
static java.lang.String |
RESULT_KEY
Key for result map.
|
static java.lang.String |
STATUS_KEY
Key for response status.
|
static java.lang.String |
WARNING_STATUS
STATUS_KEY value indicating partial success. |
| Constructor and Description |
|---|
Response()
Constructs an empty response.
|
Response(java.util.Map map)
Constructs a response based on an existing map.
|
Response(java.lang.String status,
java.util.Map result,
ErrInfo errinfo)
Constructs a response with given status, result and error.
|
| Modifier and Type | Method and Description |
|---|---|
static Response |
asResponse(java.util.Map map)
Returns a map as a Response object.
|
void |
check()
Checks that this object is ready for use with the SAMP toolkit.
|
static Response |
createErrorResponse(ErrInfo errinfo)
Returns a new response which is an error.
|
static Response |
createSuccessResponse(java.util.Map result)
Returns a new response which is a success.
|
ErrInfo |
getErrInfo()
Returns the error object.
|
java.util.Map |
getResult()
Returns the result map.
|
java.lang.String |
getStatus()
Returns the status value.
|
boolean |
isOK()
Indicates whether the result was an unequivocal success.
|
void |
setErrInfo(java.util.Map errInfo)
Sets the error object.
|
void |
setResult(java.util.Map result)
Sets the result map.
|
void |
setStatus(java.lang.String status)
Sets the status value.
|
checkHasKeys, entrySet, getList, getMap, getString, getUrl, putclear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, valuespublic static final java.lang.String STATUS_KEY
public static final java.lang.String RESULT_KEY
public static final java.lang.String ERROR_KEY
private static final java.lang.String[] KNOWN_KEYS
public static final java.lang.String OK_STATUS
STATUS_KEY value indicating success.public static final java.lang.String WARNING_STATUS
STATUS_KEY value indicating partial success.public static final java.lang.String ERROR_STATUS
STATUS_KEY value indicating failure.public Response()
public Response(java.util.Map map)
map - map containing initial data for this objectpublic Response(java.lang.String status,
java.util.Map result,
ErrInfo errinfo)
status - STATUS_KEY valueresult - RESULT_KEY valueerrinfo - ERROR_KEY valuepublic void setStatus(java.lang.String status)
status - STATUS_KEY valuepublic java.lang.String getStatus()
STATUS_KEY valuepublic void setResult(java.util.Map result)
result - RESULT_KEY valuepublic java.util.Map getResult()
RESULT_KEY valuepublic void setErrInfo(java.util.Map errInfo)
public ErrInfo getErrInfo()
ERROR_KEY value as an ErrInfopublic boolean isOK()
getStatus()==OK_STATUSpublic void check()
SampMapSampUtils.checkMap(java.util.Map) (ensuring that all keys
are Strings, and all values Strings, Lists or Maps), subclass-specific
invariants may be checked. In the case that there's something wrong,
an informative DataException will be thrown.public static Response createSuccessResponse(java.util.Map result)
result - key-value map representing results of successful callpublic static Response createErrorResponse(ErrInfo errinfo)
errinfo - error informationpublic static Response asResponse(java.util.Map map)
map - map