@Immutable public class Payload extends Object
Non-initial views are created on demand to conserve resources.
UTF-8 is the character set for all conversions between strings and byte arrays.
Conversion relations:
JSONObject <=> String <=> Base64URL
<=> byte[]
| Modifier and Type | Class and Description |
|---|---|
static class |
Payload.Origin
Enumeration of the original data types used to create a
Payload. |
| Constructor and Description |
|---|
Payload(Base64URL base64URL)
Creates a new payload from the specified Base64URL-encoded object.
|
Payload(byte[] bytes)
Creates a new payload from the specified byte array.
|
Payload(net.minidev.json.JSONObject json)
Creates a new payload from the specified JSON object.
|
Payload(String string)
Creates a new payload from the specified string.
|
| Modifier and Type | Method and Description |
|---|---|
Payload.Origin |
getOrigin()
Gets the original data type used to create this payload.
|
Base64URL |
toBase64URL()
Returns a Base64URL view of this payload.
|
byte[] |
toBytes()
Returns a byte array view of this payload.
|
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object view of this payload.
|
String |
toString()
Returns a string view of this payload.
|
public Payload(net.minidev.json.JSONObject json)
json - The JSON object representing the payload. Must not be
null.public Payload(String string)
string - The string representing the payload. Must not be
null.public Payload(byte[] bytes)
bytes - The byte array representing the payload. Must not be
null.public Payload.Origin getOrigin()
public net.minidev.json.JSONObject toJSONObject()
null if the payload couldn't
be converted to a JSON object.public byte[] toBytes()
public Base64URL toBase64URL()
Copyright © 2014 Connect2id Ltd.. All Rights Reserved.