Class Status

A Status is used for communicating an API status code back to a client. A status consists of multiple StatusItem. Most often a Status contains only one StatusItem. For convenience, a message with parameters is formatted using standard formatting patterns. If you want to display locale-specific messages in your application, you should use the Status.getCode() as key for a resource bundle.

PropertyDescription
ERROR: Numberstatus value to indicate an ERROR status
OK: Numberstatus value to indicate an OK status
code: String (read-only)Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list.
details: Map (read-only)Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
error: Boolean (read-only)Checks if the status is an ERROR.
items: List (read-only)Returns all status items.
message: String (read-only)Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
parameters: List (read-only)Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
status: Number (read-only)Returns the overall status.
ConstructorDescription
Status()Creates a Status object with no StatusItems.
Status(Number)Creates a Status with a single StatusItem.
Status(Number, String)Creates a Status with a single StatusItem.
Status(Number, String, String, Object...)Creates a Status with a single StatusItem.
MethodDescription
addDetail(String, Object)Add detail information for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
addItem(StatusItem)Adds an additional status item to this status instance.
getCode()Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list.
getDetail(String)Returns the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getDetails()Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getItems()Returns all status items.
getMessage()Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getParameters()Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.
getStatus()Returns the overall status.
isError()Checks if the status is an ERROR.

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

ERROR: Number

status value to indicate an ERROR status


OK: Number

status value to indicate an OK status


code: String (read-only)

Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list.

The status code is the unique identifier for the message and can be used by client programs to check for a specific status and to generate a localized message.


details: Map (read-only)

Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.


error: Boolean (read-only)

Checks if the status is an ERROR. The Status is an ERROR if one of the contained StatusItems is an ERROR.


items: List (read-only)

Returns all status items.


message: String (read-only)

Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Note: Custom code and client programs must not use this message to identify a specific status. The getCode() must be used for that purpose. The actual message can change from release to release.


parameters: List (read-only)

Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.


status: Number (read-only)

Returns the overall status. If all StatusItems are OK, the method returns OK. If one StatusItem is an ERROR it returns ERROR.


Status()

Creates a Status object with no StatusItems.


Status(status: Number)

Creates a Status with a single StatusItem. The status is set to the given value.

Parameters:

  • status - either OK or ERROR

Status(status: Number, code: String)

Creates a Status with a single StatusItem. The StatusItem is initialized with the given values.

Parameters:

  • status - either OK or ERROR
  • code - a string representing a more detailed status code, e.g. "IMPEX-120"

Status(status: Number, code: String, message: String, parameters: Object...)

Creates a Status with a single StatusItem. The StatusItem is initialized with the given values.

Parameters:

  • status - either OK or ERROR
  • code - a string representing a more detailed status code, e.g. "IMPEX-120".
  • message - a default human readable message
  • parameters - a list of parameters to construct a custom message

addDetail(key: String, value: Object): void

Add detail information for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Parameters:

  • key - the key of the first ERROR StatusItem or the first StatusItem in the list.
  • value - the detail value.

addItem(item: StatusItem): void

Adds an additional status item to this status instance.

Parameters:

  • item - the status item to add.

getCode(): String

Returns the status code either of the first ERROR StatusItem or when there is no ERROR StatusITEM, the first StatusItem in the overall list.

The status code is the unique identifier for the message and can be used by client programs to check for a specific status and to generate a localized message.

Returns:

  • the status code

getDetail(key: String): Object

Returns the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Parameters:

  • key - the key for the detail to return.

Returns:

  • the detail value for the given key of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

getDetails(): Map

Returns the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Returns:

  • the details either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

getItems(): List

Returns all status items.

Returns:

  • all status items.

getMessage(): String

Returns the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Note: Custom code and client programs must not use this message to identify a specific status. The getCode() must be used for that purpose. The actual message can change from release to release.

Returns:

  • the message either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

getParameters(): List

Returns the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

Returns:

  • the parameters either of the first ERROR StatusItem or when there is no ERROR StatusItem, the first StatusItem in the overall list.

getStatus(): Number

Returns the overall status. If all StatusItems are OK, the method returns OK. If one StatusItem is an ERROR it returns ERROR.

Returns:

  • either OK or ERROR

isError(): Boolean

Checks if the status is an ERROR. The Status is an ERROR if one of the contained StatusItems is an ERROR.

Returns:

  • true if status is an ERROR, false otherwise.