public class JsonObject extends Object implements IJsonObject
IJsonObject implementation.IJsonObject.KeyNotFoundException| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
JsonObject(IJsonManager jsonManager) |
| Modifier and Type | Method and Description |
|---|---|
Object |
get(String key)
Gets a property.
|
Object |
get(String key,
Object defaultValue)
Gets a property.
|
BigDecimal |
getBigDecimal(String key)
Gets a property as
BigDecimal. |
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
Gets a property as
BigDecimal. |
protected BigDecimal |
getBigDecimalValue(String key,
boolean hasDefaultValue,
BigDecimal defaultValue) |
Boolean |
getBoolean(String key)
Gets a property as
Boolean. |
Boolean |
getBoolean(String key,
Boolean defaultValue)
Gets a property as
Boolean. |
protected Boolean |
getBooleanValue(String key,
boolean hasDefaultValue,
Boolean defaultValue) |
byte[] |
getBytesFromBase64String(String key)
Gets a byte array, from a base 64 encoded property.
|
byte[] |
getBytesFromBase64String(String key,
byte[] defaultValue)
Gets a byte array, from a base 64 encoded property.
|
protected byte[] |
getBytesFromBase64StringValue(String key,
boolean hasDefaultValue,
byte[] defaultValue) |
Date |
getDate(String key)
Gets a UTC timezoned date from a
ISO 8601 date property. |
Date |
getDate(String key,
Date defaultValue)
Gets a UTC timezoned date from a
ISO 8601 date property. |
protected Date |
getDateValue(String key,
boolean hasDefaultValue,
Date defaultValue) |
Double |
getDouble(String key)
Gets a property as
Double. |
Double |
getDouble(String key,
Double defaultValue)
Gets a property as
Double. |
protected Double |
getDoubleValue(String key,
boolean hasDefaultValue,
Double defaultValue) |
Float |
getFloat(String key)
Gets a property as
Float. |
Float |
getFloat(String key,
Float defaultValue)
Gets a property as
Float. |
protected Float |
getFloatValue(String key,
boolean hasDefaultValue,
Float defaultValue) |
Integer |
getInteger(String key)
Gets a property as
Integer. |
Integer |
getInteger(String key,
Integer defaultValue)
Gets a property as
Integer. |
protected Integer |
getIntegerValue(String key,
boolean hasDefaultValue,
Integer defaultValue) |
IJsonArray |
getJsonArray(String key)
Gets a property as
IJsonArray. |
IJsonArray |
getJsonArray(String key,
IJsonArray defaultValue)
Gets a property as
IJsonArray. |
protected IJsonArray |
getJsonArrayValue(String key,
boolean hasDefaultValue,
IJsonArray defaultValue) |
protected IJsonManager |
getJsonManager() |
IJsonObject |
getJsonObject(String key)
Gets a property as
IJsonObject. |
IJsonObject |
getJsonObject(String key,
IJsonObject defaultValue)
Gets a property as
IJsonObject. |
protected IJsonObject |
getJSONObjectValue(String key,
boolean hasDefaultValue,
IJsonObject defaultValue) |
Long |
getLong(String key)
Gets a property as
Long. |
Long |
getLong(String key,
Long defaultValue)
Gets a property as
Long. |
protected Long |
getLongValue(String key,
boolean hasDefaultValue,
Long defaultValue) |
String |
getString(String key)
Gets a property as
String. |
String |
getString(String key,
String defaultValue)
Gets a property as
String. |
protected String |
getStringValue(String key,
boolean hasDefaultValue,
String defaultValue) |
Map<String,Object> |
getUnderlyingMap()
The underlying map.
|
protected Object |
getValue(String key,
boolean hasDefaultValue,
Object defaultValue) |
protected <T> T |
getValueDyn(String key,
boolean hasDefaultValue,
T defaultValue,
Class<T> clazz,
com.google.common.base.Function<Object,T> converter) |
boolean |
isKeyExists(String key)
Does the object contain the specified key?
|
Iterator<Map.Entry<String,Object>> |
iterator() |
protected Date |
parseDate(String str) |
void |
put(String key,
Object value)
Adds a property to the object.
|
void |
remove(String key)
Removes a property from the object.
|
void |
removeAll()
Removes all properties from the object.
|
String |
toJsonString()
Gets the
Json String representation of the object. |
String |
toJsonString(boolean pretty)
Gets the
Json String representation of the object. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic JsonObject(IJsonManager jsonManager)
protected IJsonManager getJsonManager()
public Map<String,Object> getUnderlyingMap()
IJsonObjectgetUnderlyingMap in interface IJsonObjectpublic void put(String key, Object value)
IJsonObjectput in interface IJsonObjectpublic void remove(String key)
IJsonObjectremove in interface IJsonObjectpublic void removeAll()
IJsonObjectremoveAll in interface IJsonObjectpublic boolean isKeyExists(String key)
IJsonObjectisKeyExists in interface IJsonObjectpublic Object get(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectget in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Object get(String key, Object defaultValue)
IJsonObjectget in interface IJsonObjectdefaultValue if not found.public IJsonObject getJsonObject(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectIJsonObject.getJsonObject in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic IJsonObject getJsonObject(String key, IJsonObject defaultValue)
IJsonObjectIJsonObject.getJsonObject in interface IJsonObjectdefaultValue if not found.protected IJsonObject getJSONObjectValue(String key, boolean hasDefaultValue, IJsonObject defaultValue)
public IJsonArray getJsonArray(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectIJsonArray.getJsonArray in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic IJsonArray getJsonArray(String key, IJsonArray defaultValue)
IJsonObjectIJsonArray.getJsonArray in interface IJsonObjectdefaultValue if not found.protected IJsonArray getJsonArrayValue(String key, boolean hasDefaultValue, IJsonArray defaultValue)
public String getString(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectString.getString in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic String getString(String key, String defaultValue)
IJsonObjectString.getString in interface IJsonObjectdefaultValue if not found.protected String getStringValue(String key, boolean hasDefaultValue, String defaultValue)
public Integer getInteger(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectInteger.getInteger in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Integer getInteger(String key, Integer defaultValue)
IJsonObjectInteger.getInteger in interface IJsonObjectdefaultValue if not found.protected Integer getIntegerValue(String key, boolean hasDefaultValue, Integer defaultValue)
public Long getLong(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectLong.getLong in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Long getLong(String key, Long defaultValue)
IJsonObjectLong.getLong in interface IJsonObjectdefaultValue if not found.public Float getFloat(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectFloat.getFloat in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Float getFloat(String key, Float defaultValue)
IJsonObjectFloat.getFloat in interface IJsonObjectdefaultValue if not found.protected Float getFloatValue(String key, boolean hasDefaultValue, Float defaultValue)
public Double getDouble(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectDouble.getDouble in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Double getDouble(String key, Double defaultValue)
IJsonObjectDouble.getDouble in interface IJsonObjectdefaultValue if not found.protected Double getDoubleValue(String key, boolean hasDefaultValue, Double defaultValue)
public Boolean getBoolean(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectBoolean.getBoolean in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Boolean getBoolean(String key, Boolean defaultValue)
IJsonObjectBoolean.getBoolean in interface IJsonObjectdefaultValue if not found.protected Boolean getBooleanValue(String key, boolean hasDefaultValue, Boolean defaultValue)
public BigDecimal getBigDecimal(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectBigDecimal.getBigDecimal in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
IJsonObjectBigDecimal.getBigDecimal in interface IJsonObjectdefaultValue if not found.protected BigDecimal getBigDecimalValue(String key, boolean hasDefaultValue, BigDecimal defaultValue)
public byte[] getBytesFromBase64String(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectgetBytesFromBase64String in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic byte[] getBytesFromBase64String(String key, byte[] defaultValue)
IJsonObjectgetBytesFromBase64String in interface IJsonObjectdefaultValue if not found.protected byte[] getBytesFromBase64StringValue(String key, boolean hasDefaultValue, byte[] defaultValue)
public Date getDate(String key) throws IJsonObject.KeyNotFoundException
IJsonObjectISO 8601 date property.getDate in interface IJsonObjectnull if not found.IJsonObject.KeyNotFoundExceptionpublic Date getDate(String key, Date defaultValue)
IJsonObjectISO 8601 date property.getDate in interface IJsonObjectdefaultValue if not found.protected <T> T getValueDyn(String key, boolean hasDefaultValue, T defaultValue, Class<T> clazz, com.google.common.base.Function<Object,T> converter)
public String toJsonString()
IJsonObjectJson String representation of the object.toJsonString in interface IJsonObjectpublic String toJsonString(boolean pretty)
IJsonObjectJson String representation of the object.toJsonString in interface IJsonObjectpretty - ff true, the generated String will be formatted.Copyright © 2016. All rights reserved.