public class JsonArray extends JsonObjectArrayBase implements IJsonArray
IJsonArray implementation.| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
JsonArray(IJsonManager jsonManager,
ISpincastUtils spincastUtils)
Constructor
|
JsonArray(List<Object> initialElements,
IJsonManager jsonManager,
ISpincastUtils spincastUtils)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
IJsonArray |
add(BigDecimal value)
Adds a BigDecimal.
|
IJsonArray |
add(Boolean value)
Adds a Boolean.
|
IJsonArray |
add(byte[] value)
Adds a byte[].
|
IJsonArray |
add(Date value)
Adds a Date.
|
IJsonArray |
add(Double value)
Adds a Double.
|
IJsonArray |
add(Float value)
Adds a Float.
|
IJsonArray |
add(IJsonArray value)
Adds a IJsonArray.
|
IJsonArray |
add(IJsonArray array,
boolean clone)
Adds a IJsonArray.
|
IJsonArray |
add(IJsonObject jsonObj)
Adds a IJsonObject.
|
IJsonArray |
add(IJsonObject jsonObj,
boolean clone)
Adds a IJsonObject.
|
IJsonArray |
add(Integer value)
Adds a Integer.
|
IJsonArray |
add(Long value)
Adds a Long.
|
IJsonArray |
add(String value)
Adds a String.
|
protected IJsonArray |
addAsIs(Object value) |
IJsonArray |
addConvert(Object value)
If the object to add is not of a IJsonObject's native type,
then the object will be converted to a IJsonObject or a
IJsonArray before being added.
|
IJsonArray |
addConvert(Object value,
boolean clone)
If the object to add is not of a IJsonObject's native type,
then the object will be converted to a IJsonObject or a
IJsonArray before being added.
|
protected void |
addInitalElements() |
IJsonArray |
clear()
Clears all elements.
|
IJsonArray |
clone()
Deep copy of the
IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa. |
IJsonArray |
clone(boolean mutable)
Deep copy of the
IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa. |
List<Object> |
convertToPlainList()
Converts the
IJsonArray to a plain List<Object>. |
List<String> |
convertToStringList()
Converts the IJsonArray to a
List<String>. |
BigDecimal |
getBigDecimal(int index)
Gets an element as
BigDecimal. |
BigDecimal |
getBigDecimal(int index,
BigDecimal defaultValue)
Gets an element as
BigDecimal. |
Boolean |
getBoolean(int index)
Gets an element as
Boolean. |
Boolean |
getBoolean(int index,
Boolean defaultValue)
Gets an element as
Boolean. |
byte[] |
getBytesFromBase64String(int index)
Gets a byte array, from a base 64 encoded property.
|
byte[] |
getBytesFromBase64String(int index,
byte[] defaultValue)
Gets a byte array, from a base 64 encoded property.
|
Date |
getDate(int index)
Gets a UTC timezoned date from a
ISO 8601 date property. |
Date |
getDate(int index,
Date defaultValue)
Gets a UTC timezoned date from a
ISO 8601 date property. |
Double |
getDouble(int index)
Gets an element as
Double. |
Double |
getDouble(int index,
Double defaultValue)
Gets an element as
Double. |
protected Object |
getElement(int index) |
protected Object |
getElement(String keyPosition,
boolean hasDefaultValue,
Object defaultValue)
Gets the element at this key/position.
|
protected List<Object> |
getElements() |
Float |
getFloat(int index)
Gets an element as
Float. |
Float |
getFloat(int index,
Float defaultValue)
Gets an element as
Float. |
Integer |
getInteger(int index)
Gets an element as
Integer. |
Integer |
getInteger(int index,
Integer defaultValue)
Gets an element as
Integer. |
IJsonArray |
getJsonArray(int index)
Gets an element as
IJsonArray. |
IJsonArray |
getJsonArray(int index,
IJsonArray defaultValue)
Gets an element as
IJsonArray. |
IJsonArray |
getJsonArrayOrEmpty(int index)
Gets an element as
IJsonArray. |
IJsonObject |
getJsonObject(int index)
Gets an element as
IJsonObject. |
IJsonObject |
getJsonObject(int index,
IJsonObject defaultValue)
Gets an element as
IJsonObject. |
IJsonObject |
getJsonObjectOrEmpty(int index)
Gets an element as
IJsonObject. |
Long |
getLong(int index)
Gets an element as
Long. |
Long |
getLong(int index,
Long defaultValue)
Gets an element as
Long. |
String |
getString(int index)
Gets an element as
String. |
String |
getString(int index,
String defaultValue)
Gets an element as
String. |
protected void |
init()
Init
|
Iterator<Object> |
iterator() |
IJsonArray |
remove(int index)
Removes an element at the specified position.
|
int |
size()
The array size.
|
getBigDecimal, getBigDecimal, getBigDecimalValue, getBoolean, getBoolean, getBooleanValue, getBytesFromBase64String, getBytesFromBase64String, getBytesFromBase64StringValue, getDate, getDate, getDateValue, getDouble, getDouble, getDoubleValue, getFloat, getFloat, getFloatValue, getInteger, getInteger, getIntegerValue, getJsonArray, getJsonArray, getJsonArrayOrEmpty, getJsonArrayValue, getJsonManager, getJsonObject, getJsonObject, getJsonObjectOrEmpty, getJSONObjectValue, getLong, getLong, getLongValue, getSpincastUtils, getString, getString, getStringValue, parseDate, toJsonString, toJsonString, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waittoJsonString, toJsonStringforEach, spliteratorpublic JsonArray(IJsonManager jsonManager, ISpincastUtils spincastUtils)
public JsonArray(@Nullable List<Object> initialElements, IJsonManager jsonManager, ISpincastUtils spincastUtils)
@Inject protected void init()
protected void addInitalElements()
protected Object getElement(int index)
public IJsonArray add(String value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Integer value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Long value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Float value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Double value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Boolean value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(BigDecimal value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(byte[] value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray add(Date value)
IJsonArrayadd in interface IJsonArraypublic IJsonArray addConvert(Object value)
IJsonArray
If the element to add is a IJsonObject or
a IJsonArray and is immutable then
it will be cloned.
Doing so, we can make sure a IJsonArray is always
fully mutable or fully immutable.
Those are the types of objects that will be converted to a IJsonArray instead of a IJsonObject :
addConvert in interface IJsonArraypublic IJsonArray addConvert(Object value, boolean clone)
IJsonArrayThose are the types of object that will be converted to a IJsonArray instead of a IJsonObject :
addConvert in interface IJsonArrayclone - if true, and the element to add is a
IJsonObject or IJsonArray, a clone will be made
before being added. If that case, any modification to the
original element won't affect the added one,
and vice-versa. If the element is immutable then it will
always be cloned. Doing so, we can make sure a
IJsonArray is always
fully mutable or fully immutable.public IJsonArray add(IJsonObject jsonObj)
IJsonArrayIJsonObject to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonArray is always
fully mutable or fully immutable.add in interface IJsonArraypublic IJsonArray add(IJsonObject jsonObj, boolean clone)
IJsonArrayadd in interface IJsonArrayclone - if true, a clone of the original
object will be made before being added.
If that case, any modification to the original object
won't affect the added element, and vice-versa.
If the IJsonObject
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonArray is always
fully mutable or fully immutable.public IJsonArray add(IJsonArray value)
IJsonArrayIJsonArray to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonArray is always
fully mutable or fully immutable.add in interface IJsonArraypublic IJsonArray add(IJsonArray array, boolean clone)
IJsonArrayadd in interface IJsonArrayclone - if true, a clone of the original
object will be made before being added.
If that case, any modification to the original IJsonArray
won't affect the added element, and vice-versa.
If the IJsonArray
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonArray is always
fully mutable or fully immutable.protected IJsonArray addAsIs(Object value)
public IJsonArray remove(int index)
IJsonArrayremove in interface IJsonArraypublic IJsonArray clear()
IJsonArrayclear in interface IJsonArraypublic int size()
IJsonArraysize in interface IJsonArraypublic IJsonArray clone()
IJsonArrayIJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.
The resulting IJsonArray is mutable.
clone in interface IJsonArrayclone in class Objectpublic IJsonArray clone(boolean mutable)
IJsonArrayIJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.clone in interface IJsonArraymutable - if false, the resulting
IJsonArray and all its children
will be immutable.public List<String> convertToStringList()
IJsonArrayList<String>.
The toString() method will be called on any non null
elements.
This list is always a new instance and is always mutable.
convertToStringList in interface IJsonArraypublic IJsonObject getJsonObject(int index)
IJsonArrayIJsonObject.getJsonObject in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonObject getJsonObject(int index, IJsonObject defaultValue)
IJsonArrayIJsonObject.getJsonObject in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonObject getJsonObjectOrEmpty(int index)
IJsonArrayIJsonObject.getJsonObjectOrEmpty in interface IJsonArrayIJsonObject if not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonArray getJsonArray(int index)
IJsonArrayIJsonArray.getJsonArray in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonArray getJsonArray(int index, IJsonArray defaultValue)
IJsonArrayIJsonArray.getJsonArray in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public IJsonArray getJsonArrayOrEmpty(int index)
IJsonArrayIJsonArray.getJsonArrayOrEmpty in interface IJsonArrayIJsonArray if not found.
Throws an exception if an existing element can't be converted to the
required type.public String getString(int index)
IJsonArrayString.getString in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public String getString(int index, String defaultValue)
IJsonArrayString.getString in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Integer getInteger(int index)
IJsonArrayInteger.getInteger in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Integer getInteger(int index, Integer defaultValue)
IJsonArrayInteger.getInteger in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Long getLong(int index)
IJsonArrayLong.getLong in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Long getLong(int index, Long defaultValue)
IJsonArrayLong.getLong in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Double getDouble(int index)
IJsonArrayDouble.getDouble in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Double getDouble(int index, Double defaultValue)
IJsonArrayDouble.getDouble in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Float getFloat(int index)
IJsonArrayFloat.getFloat in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Float getFloat(int index, Float defaultValue)
IJsonArrayFloat.getFloat in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Boolean getBoolean(int index)
IJsonArrayBoolean.getBoolean in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Boolean getBoolean(int index, Boolean defaultValue)
IJsonArrayBoolean.getBoolean in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public BigDecimal getBigDecimal(int index)
IJsonArrayBigDecimal.getBigDecimal in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public BigDecimal getBigDecimal(int index, BigDecimal defaultValue)
IJsonArrayBigDecimal.getBigDecimal in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public byte[] getBytesFromBase64String(int index)
IJsonArraygetBytesFromBase64String in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public byte[] getBytesFromBase64String(int index,
byte[] defaultValue)
IJsonArraygetBytesFromBase64String in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.public Date getDate(int index)
IJsonArrayISO 8601 date property.getDate in interface IJsonArraynull if not found.
Throws an exception if an existing element can't be converted to the
required type.public Date getDate(int index, Date defaultValue)
IJsonArrayISO 8601 date property.getDate in interface IJsonArraydefaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.protected Object getElement(String keyPosition, boolean hasDefaultValue, Object defaultValue)
JsonObjectArrayBasegetElement in class JsonObjectArrayBasepublic List<Object> convertToPlainList()
IJsonArrayIJsonArray to a plain List<Object>.
All IJsonObject elements will be converted to
Maps and all IJsonArray elements will be converted to
Lists.
This list is always a new instance and is always mutable.
convertToPlainList in interface IJsonArrayCopyright © 2016. All rights reserved.