AbstractMap.SimpleEntry, AbstractMap.SimpleImmutableEntry
Modifier and Type | Field and Description |
---|---|
static String |
ERROR_KEY
Key for error map.
|
static String |
ERROR_STATUS
STATUS_KEY value indicating failure. |
static String |
OK_STATUS
STATUS_KEY value indicating success. |
static String |
RESULT_KEY
Key for result map.
|
static String |
STATUS_KEY
Key for response status.
|
static String |
WARNING_STATUS
STATUS_KEY value indicating partial success. |
Constructor and Description |
---|
Response()
Constructs an empty response.
|
Response(Map map)
Constructs a response based on an existing map.
|
Response(String status,
Map result,
ErrInfo errinfo)
Constructs a response with given status, result and error.
|
Modifier and Type | Method and Description |
---|---|
static Response |
asResponse(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(Map result)
Returns a new response which is a success.
|
ErrInfo |
getErrInfo()
Returns the error object.
|
Map |
getResult()
Returns the result map.
|
String |
getStatus()
Returns the status value.
|
boolean |
isOK()
Indicates whether the result was an unequivocal success.
|
void |
setErrInfo(Map errInfo)
Sets the error object.
|
void |
setResult(Map result)
Sets the result map.
|
void |
setStatus(String status)
Sets the status value.
|
checkHasKeys, entrySet, getList, getMap, getString, getUrl, put
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static final String STATUS_KEY
public static final String RESULT_KEY
public static final String ERROR_KEY
public static final String OK_STATUS
STATUS_KEY
value indicating success.public static final String WARNING_STATUS
STATUS_KEY
value indicating partial success.public static final String ERROR_STATUS
STATUS_KEY
value indicating failure.public Response()
public Response(Map map)
map
- map containing initial data for this objectpublic Response(String status, Map result, ErrInfo errinfo)
status
- STATUS_KEY
valueresult
- RESULT_KEY
valueerrinfo
- ERROR_KEY
valuepublic void setStatus(String status)
status
- STATUS_KEY
valuepublic String getStatus()
STATUS_KEY
valuepublic void setResult(Map result)
result
- RESULT_KEY
valuepublic Map getResult()
RESULT_KEY
valuepublic void setErrInfo(Map errInfo)
public ErrInfo getErrInfo()
ERROR_KEY
value as an ErrInfo
public boolean isOK()
getStatus()==OK_STATUS
public void check()
SampMap
SampUtils.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(Map result)
result
- key-value map representing results of successful callpublic static Response createErrorResponse(ErrInfo errinfo)
errinfo
- error informationCopyright © 2008–2024. All rights reserved.