public abstract class JSONParsable
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
JSONParsable()
Base empty constructor
|
protected |
JSONParsable(javax.json.JsonObject jsonObject)
JSON Parseable constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(javax.json.JsonObjectBuilder jsonObjectBuilder,
java.lang.String key,
java.lang.Object value)
Method to add a field to a json object builder.
|
protected void |
addB58(javax.json.JsonObjectBuilder jsonObjectBuilder,
java.lang.String key,
java.lang.String value)
Special method when adding a B58 encoded value.
|
protected void |
addNotRequired(javax.json.JsonObjectBuilder jsonObjectBuilder,
java.lang.String key,
java.lang.Object value)
Help method that can be used in convertToJson implementations to set a key
in json if not null, otherwise the key is skipped.
|
protected void |
addNotRequiredB58(javax.json.JsonObjectBuilder jsonObjectBuilder,
java.lang.String key,
java.lang.String value)
Special method when adding a B58 encoded value.
|
abstract void |
convertToJson(javax.json.JsonObjectBuilder jsonObjectBuilder)
Method that should set the objects property to Json representation.
|
protected java.lang.Boolean |
getBoolean(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a boolean value
if set in JsonObject otherwise returns null.
|
protected java.lang.Boolean |
getBooleanIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a boolean value
|
protected byte[] |
getByteArrayFromB58(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a b58 string value and decode
it into byte array if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected byte[] |
getByteArrayFromB58IfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a b58 string value and decode it into byte[]
|
protected byte[] |
getByteArrayFromB64(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a b64 string value and decode
it into byte array if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected byte[] |
getByteArrayFromB64IfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a b64 string value and decode it into byte[]
|
protected byte[] |
getByteArrayFromHex(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a hex string value and decode
it into byte array if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected byte[] |
getByteArrayFromHexIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a hex string value and decode it into byte[]
|
protected java.util.Date |
getDate(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a Date value in "yyyy-MM-ddTHH:mm:ss.SSSZ" format.
|
protected java.util.Date |
getDateIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a Date value
|
protected java.lang.Double |
getDouble(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a double value
|
protected java.lang.Double |
getDoubleIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a double value
|
protected java.lang.Integer |
getInt(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a int value
if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected java.lang.Integer |
getIntIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a int value
|
protected javax.json.JsonArray |
getJsonArray(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a json array
if set in JsonObject otherwise returns null.
|
protected javax.json.JsonArray |
getJsonArrayIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a json array
|
protected javax.json.JsonObject |
getJsonObject(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a json object
if set in JsonObject otherwise returns null.
|
protected javax.json.JsonObject |
getJsonObjectIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a json object
|
protected java.lang.Long |
getLong(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a long value
if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected java.lang.Long |
getLongIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a long value
|
protected java.lang.String |
getString(javax.json.JsonObject object,
java.lang.String key,
boolean required)
Help method used in parseJson implementation to fetch a string value
if set in JsonObject otherwise returns null or throws JsonException if required.
|
protected java.lang.String |
getStringIfSet(javax.json.JsonObject object,
java.lang.String key)
Help method used in parseJson implementation to fetch a string value
|
abstract void |
parseJson(javax.json.JsonObject jsonObject)
Method to read all properties from a JsonObject into this value object.
|
javax.json.JsonObjectBuilder |
toJson()
Help method to convert object into JSON as a JsonObjectBuilder.
|
java.lang.String |
toJsonAsString(boolean prettyPrint)
Help method to convert the data to a String representation.
|
java.lang.String |
toString()
Converts data content to pretty printed Json string.
|
protected JSONParsable()
protected JSONParsable(javax.json.JsonObject jsonObject) throws javax.json.JsonException
jsonObject
- the jsonObject to parse.javax.json.JsonException
public javax.json.JsonObjectBuilder toJson() throws javax.json.JsonException
javax.json.JsonException
public java.lang.String toJsonAsString(boolean prettyPrint) throws javax.json.JsonException
prettyPrint
- true if generated string should be pretty printed, otherwise compact.javax.json.JsonException
- if problems occurred converting object to JSON.public abstract void convertToJson(javax.json.JsonObjectBuilder jsonObjectBuilder) throws javax.json.JsonException
jsonObjectBuilder
- the json object build to use to set key/values in jsonjavax.json.JsonException
- if problems occurred converting object to JSON.public abstract void parseJson(javax.json.JsonObject jsonObject) throws javax.json.JsonException
jsonObject
- the json object to read key and values from and set object properties.javax.json.JsonException
- if problems occurred converting object from JSON.protected void addNotRequired(javax.json.JsonObjectBuilder jsonObjectBuilder, java.lang.String key, java.lang.Object value)
jsonObjectBuilder
- the objects jsonObjectBuilderkey
- the key of json object to add.value
- the value to add.protected void add(javax.json.JsonObjectBuilder jsonObjectBuilder, java.lang.String key, java.lang.Object value) throws javax.json.JsonException
jsonObjectBuilder
- the objects jsonObjectBuilderkey
- the key of json object to add.value
- the value to add.javax.json.JsonException
- if json problems occurred.protected void addB58(javax.json.JsonObjectBuilder jsonObjectBuilder, java.lang.String key, java.lang.String value) throws javax.json.JsonException
jsonObjectBuilder
- the objects jsonObjectBuilderkey
- the key of json object to add.value
- the value to add.javax.json.JsonException
- if json problems occurred.protected void addNotRequiredB58(javax.json.JsonObjectBuilder jsonObjectBuilder, java.lang.String key, java.lang.String value)
jsonObjectBuilder
- the objects jsonObjectBuilderkey
- the key of json object to add.value
- the value to add.javax.json.JsonException
- if json problems occurred.protected java.lang.String getStringIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.lang.String getString(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected byte[] getByteArrayFromHexIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected byte[] getByteArrayFromHex(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected byte[] getByteArrayFromB64IfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected byte[] getByteArrayFromB64(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected byte[] getByteArrayFromB58IfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected byte[] getByteArrayFromB58(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected java.lang.Long getLongIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.lang.Long getLong(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected java.util.Date getDateIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.util.Date getDate(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected java.lang.Integer getIntIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.lang.Integer getInt(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected java.lang.Boolean getBooleanIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.lang.Boolean getBoolean(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected java.lang.Double getDoubleIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected java.lang.Double getDouble(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected javax.json.JsonObject getJsonObjectIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected javax.json.JsonObject getJsonObject(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.protected javax.json.JsonArray getJsonArrayIfSet(javax.json.JsonObject object, java.lang.String key)
object
- the related json objectkey
- the key of field to fetchprotected javax.json.JsonArray getJsonArray(javax.json.JsonObject object, java.lang.String key, boolean required) throws javax.json.JsonException
object
- the related json objectkey
- the key of field to fetchrequired
- true if exception should be thrown if field doesn't exist.javax.json.JsonException
- if field is not set but required.public java.lang.String toString()
toString
in class java.lang.Object