@Immutable public class ErrorObject extends java.lang.Object
Example error object as HTTP response:
HTTP/1.1 400 Bad Request Content-Type: application/json;charset=UTF-8 Cache-Control: no-store Pragma: no-cache { "error" : "invalid_request" }
Constructor and Description |
---|
ErrorObject(java.lang.String code)
Creates a new error with the specified code.
|
ErrorObject(java.lang.String code,
java.lang.String description)
Creates a new error with the specified code and description.
|
ErrorObject(java.lang.String code,
java.lang.String description,
int httpStatusCode)
Creates a new error with the specified code, description and HTTP
status code.
|
ErrorObject(java.lang.String code,
java.lang.String description,
int httpStatusCode,
java.net.URI uri)
Creates a new error with the specified code, description, HTTP
status code and page URI.
|
Modifier and Type | Method and Description |
---|---|
ErrorObject |
appendDescription(java.lang.String text)
Appends the specified text to the error description.
|
boolean |
equals(java.lang.Object object) |
java.lang.String |
getCode()
Gets the error code.
|
java.lang.String |
getDescription()
Gets the error description.
|
int |
getHTTPStatusCode()
Gets the HTTP status code.
|
java.net.URI |
getURI()
Gets the error page URI.
|
int |
hashCode() |
static ErrorObject |
parse(HTTPResponse httpResponse)
Parses an error object from the specified HTTP response.
|
static ErrorObject |
parse(net.minidev.json.JSONObject jsonObject)
Parses an error object from the specified JSON object.
|
ErrorObject |
setDescription(java.lang.String description)
Sets the error description.
|
ErrorObject |
setHTTPStatusCode(int httpStatusCode)
Sets the HTTP status code.
|
ErrorObject |
setURI(java.net.URI uri)
Sets the error page URI.
|
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of this error object.
|
java.lang.String |
toString() |
public ErrorObject(java.lang.String code)
code
- The error code, null
if not specified.public ErrorObject(java.lang.String code, java.lang.String description)
code
- The error code, null
if not specified.description
- The error description, null
if not
specified.public ErrorObject(java.lang.String code, java.lang.String description, int httpStatusCode)
code
- The error code, null
if not specified.description
- The error description, null
if not
specified.httpStatusCode
- The HTTP status code, zero if not specified.public ErrorObject(java.lang.String code, java.lang.String description, int httpStatusCode, java.net.URI uri)
code
- The error code, null
if not specified.description
- The error description, null
if not
specified.httpStatusCode
- The HTTP status code, zero if not specified.uri
- The error page URI, null
if not
specified.public java.lang.String getCode()
null
if not specified.public java.lang.String getDescription()
null
if not specified.public ErrorObject setDescription(java.lang.String description)
description
- The error description, null
if not
specified.public ErrorObject appendDescription(java.lang.String text)
text
- The text to append to the error description,
null
if not specified.public int getHTTPStatusCode()
public ErrorObject setHTTPStatusCode(int httpStatusCode)
httpStatusCode
- The HTTP status code, zero if not specified.public java.net.URI getURI()
null
if not specified.public ErrorObject setURI(java.net.URI uri)
uri
- The error page URI, null
if not specified.public net.minidev.json.JSONObject toJSONObject()
Example:
{ "error" : "invalid_grant", "error_description" : "Invalid resource owner credentials" }
public java.lang.String toString()
toString
in class java.lang.Object
getCode()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public static ErrorObject parse(net.minidev.json.JSONObject jsonObject)
jsonObject
- The JSON object to parse. Must not be
null
.public static ErrorObject parse(HTTPResponse httpResponse)
httpResponse
- The HTTP response to parse. Must not be
null
.Copyright © 2015 Connect2id Ltd.. All Rights Reserved.