- java.lang.Object
-
- com.github.wnameless.json.base.GsonJsonArray
-
- All Implemented Interfaces:
Jsonable,JsonArrayBase<GsonJsonValue>,JsonArrayCore<GsonJsonValue>,JsonSource,JsonValueBase<GsonJsonValue>,JsonValueCore<GsonJsonValue>,Iterable<GsonJsonValue>
public final class GsonJsonArray extends Object implements JsonArrayCore<GsonJsonValue>
The GSON implementation ofJsonArrayCore.- Author:
- Wei-Ming Wu
-
-
Constructor Summary
Constructors Constructor Description GsonJsonArray(com.google.gson.JsonArray jsonArray)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(JsonSource jsonValue)Sets an element by givenJsonSource.GsonJsonArrayasArray()Converts this to a JSON array wrapper.BigDecimalasBigDecimal()Converts this to a JavaBigDecimal.BigIntegerasBigInteger()Converts this to a JavaBigInteger.booleanasBoolean()Converts this to a Java boolean.doubleasDouble()Converts this to a Java double.intasInt()Converts this to a Java int.longasLong()Converts this to a Java long.GsonJsonObjectasObject()Converts this to a JSON object wrapper.StringasString()Converts this to a JavaString.GsonJsonValueasValue()Converts this to a JSON value wrapper.booleanequals(Object o)GsonJsonValueget(int index)Returns a JSON value wrapper by given index.ObjectgetSource()Returns a JSON elementary object.inthashCode()booleanisArray()Checks if this is represented as a JSON array.booleanisBoolean()Checks if this is represented as a JSON boolean.booleanisNull()Checks if this is represented as a JSON null.booleanisNumber()Checks if this is represented as a JSON number.booleanisObject()Checks if this is represented as a JSON object.booleanisString()Checks if this is represented as a JSON string.Iterator<GsonJsonValue>iterator()booleanremove(int index)Removes an element by given index.voidset(int index, JsonSource jsonValue)Sets an element by given index andJsonSource.intsize()Returns the size of this JSON array.StringtoJson()Returns a JSON string which represents this object.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.github.wnameless.json.base.JsonArrayBase
isEmpty, toList
-
Methods inherited from interface com.github.wnameless.json.base.JsonValueBase
asNull, asNumber
-
-
-
-
Method Detail
-
get
public GsonJsonValue get(int index)
Description copied from interface:JsonArrayBaseReturns a JSON value wrapper by given index.- Specified by:
getin interfaceJsonArrayBase<GsonJsonValue>- Parameters:
index- a position in this JSON array- Returns:
- a JSON value wrapper
-
iterator
public Iterator<GsonJsonValue> iterator()
- Specified by:
iteratorin interfaceIterable<GsonJsonValue>
-
toJson
public String toJson()
Description copied from interface:JsonableReturns a JSON string which represents this object.
-
add
public void add(JsonSource jsonValue)
Description copied from interface:JsonArrayCoreSets an element by givenJsonSource.- Specified by:
addin interfaceJsonArrayCore<GsonJsonValue>- Parameters:
jsonValue- aJsonSource
-
set
public void set(int index, JsonSource jsonValue)Description copied from interface:JsonArrayCoreSets an element by given index andJsonSource.- Specified by:
setin interfaceJsonArrayCore<GsonJsonValue>- Parameters:
index- a position in this JSON arrayjsonValue- aJsonSource
-
remove
public boolean remove(int index)
Description copied from interface:JsonArrayCoreRemoves an element by given index.- Specified by:
removein interfaceJsonArrayCore<GsonJsonValue>- Parameters:
index- a position in this JSON array- Returns:
- true if an element removed, false otherwise
-
isObject
public boolean isObject()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON object.- Specified by:
isObjectin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON object, false otherwise
-
isArray
public boolean isArray()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON array.- Specified by:
isArrayin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON array, false otherwise
-
isString
public boolean isString()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON string.- Specified by:
isStringin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON string, false otherwise
-
isBoolean
public boolean isBoolean()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON boolean.- Specified by:
isBooleanin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON boolean, false otherwise
-
isNumber
public boolean isNumber()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON number.- Specified by:
isNumberin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON number, false otherwise
-
isNull
public boolean isNull()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON null.- Specified by:
isNullin interfaceJsonValueBase<GsonJsonValue>- Returns:
- true if this is represented as a JSON null, false otherwise
-
asObject
public GsonJsonObject asObject()
Description copied from interface:JsonValueBaseConverts this to a JSON object wrapper.- Specified by:
asObjectin interfaceJsonValueBase<GsonJsonValue>- Specified by:
asObjectin interfaceJsonValueCore<GsonJsonValue>- Returns:
- a JSON object wrapper
-
asArray
public GsonJsonArray asArray()
Description copied from interface:JsonValueBaseConverts this to a JSON array wrapper.- Specified by:
asArrayin interfaceJsonValueBase<GsonJsonValue>- Specified by:
asArrayin interfaceJsonValueCore<GsonJsonValue>- Returns:
- a JSON array wrapper
-
asValue
public GsonJsonValue asValue()
Description copied from interface:JsonValueBaseConverts this to a JSON value wrapper.- Specified by:
asValuein interfaceJsonValueBase<GsonJsonValue>- Specified by:
asValuein interfaceJsonValueCore<GsonJsonValue>- Returns:
- a JSON value wrapper
-
asString
public String asString()
Description copied from interface:JsonValueBaseConverts this to a JavaString.- Specified by:
asStringin interfaceJsonValueBase<GsonJsonValue>- Returns:
- a
String
-
asBoolean
public boolean asBoolean()
Description copied from interface:JsonValueBaseConverts this to a Java boolean.- Specified by:
asBooleanin interfaceJsonValueBase<GsonJsonValue>- Returns:
- a boolean
-
asInt
public int asInt()
Description copied from interface:JsonValueBaseConverts this to a Java int.- Specified by:
asIntin interfaceJsonValueBase<GsonJsonValue>- Returns:
- an int
-
asLong
public long asLong()
Description copied from interface:JsonValueBaseConverts this to a Java long.- Specified by:
asLongin interfaceJsonValueBase<GsonJsonValue>- Returns:
- a long
-
asBigInteger
public BigInteger asBigInteger()
Description copied from interface:JsonValueBaseConverts this to a JavaBigInteger.- Specified by:
asBigIntegerin interfaceJsonValueBase<GsonJsonValue>- Returns:
- a
BigInteger
-
asDouble
public double asDouble()
Description copied from interface:JsonValueBaseConverts this to a Java double.- Specified by:
asDoublein interfaceJsonValueBase<GsonJsonValue>- Returns:
- a double
-
asBigDecimal
public BigDecimal asBigDecimal()
Description copied from interface:JsonValueBaseConverts this to a JavaBigDecimal.- Specified by:
asBigDecimalin interfaceJsonValueBase<GsonJsonValue>- Returns:
- a
BigDecimal
-
getSource
public Object getSource()
Description copied from interface:JsonSourceReturns a JSON elementary object.- Specified by:
getSourcein interfaceJsonSource- Returns:
- a JSON elementary object
-
size
public int size()
Description copied from interface:JsonArrayBaseReturns the size of this JSON array.- Specified by:
sizein interfaceJsonArrayBase<GsonJsonValue>- Returns:
- an int
-
-