Class JsonArrayBuilderImpl.JsonArrayImpl
- All Implemented Interfaces:
Iterable<JsonValue>, Collection<JsonValue>, List<JsonValue>, SequencedCollection<JsonValue>, JsonArray, JsonStructure, JsonValue
- Enclosing class:
JsonArrayBuilderImpl
private static final class JsonArrayBuilderImpl.JsonArrayImpl
extends AbstractList<JsonValue>
implements JsonArray
-
Nested Class Summary
Nested classes/interfaces inherited from interface JsonValue
JsonValue.ValueType -
Field Summary
FieldsFields inherited from class AbstractList
modCountFields inherited from interface JsonValue
EMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the JsonValue as a JsonArrayget(int index) booleangetBoolean(int index) Returns the boolean value at the specified position.booleangetBoolean(int index, boolean defaultValue) Returns the boolean value at the specified position.intgetInt(int index) A convenience method forgetJsonNumber(index).intValue().intgetInt(int index, int defaultValue) Returns the int value of theJsonNumberat the specified position.getJsonArray(int index) Returns the array value at the specified position in this array.getJsonNumber(int index) Returns the number value at the specified position in this array.getJsonObject(int index) Returns the object value at the specified position in this array.getJsonString(int index) Returns the string value at ths specified position in this array.getString(int index) A convenience method forgetJsonString(index).getString().Returns theStringvalue ofJsonStringat the specified position in this JSON array values.getValuesAs(Class<T> clazz) Returns a list view of the specified type for the array.Returns the value type of this JSON value.booleanisNull(int index) Returnstrueif the value at the specified location in this array isJsonValue.NULL.intsize()toString()Returns JSON text for this JSON value.Methods inherited from class AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface JsonArray
getValuesAsMethods inherited from interface JsonStructure
getValueMethods inherited from interface JsonValue
asJsonObjectMethods inherited from interface List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, sort, spliterator, subList, toArray, toArray
-
Field Details
-
valueList
-
bufferPool
-
-
Constructor Details
-
JsonArrayImpl
JsonArrayImpl(List<JsonValue> valueList, BufferPool bufferPool)
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<JsonValue>- Specified by:
sizein interfaceList<JsonValue>- Specified by:
sizein classAbstractCollection<JsonValue>
-
getJsonObject
Description copied from interface:JsonArrayReturns the object value at the specified position in this array. This is a convenience method for(JsonObject)get(index).- Specified by:
getJsonObjectin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonArray
Description copied from interface:JsonArrayReturns the array value at the specified position in this array. This is a convenience method for(JsonArray)get(index).- Specified by:
getJsonArrayin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonNumber
Description copied from interface:JsonArrayReturns the number value at the specified position in this array. This is a convenience method for(JsonNumber)get(index).- Specified by:
getJsonNumberin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getJsonString
Description copied from interface:JsonArrayReturns the string value at ths specified position in this array. This is a convenience method for(JsonString)get(index).- Specified by:
getJsonStringin interfaceJsonArray- Parameters:
index- index of the value to be returned- Returns:
- the value at the specified position in this array
-
getValuesAs
Description copied from interface:JsonArrayReturns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with aClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.- Specified by:
getValuesAsin interfaceJsonArray- Type Parameters:
T- The type of the List for the array- Parameters:
clazz- a JsonValue type- Returns:
- a list view of the specified type
-
getString
-
getString
Description copied from interface:JsonArrayReturns theStringvalue ofJsonStringat the specified position in this JSON array values. IfJsonStringis found, itsJsonString.getString()is returned. Otherwise, the specified default value is returned. -
getInt
-
getInt
public int getInt(int index, int defaultValue) Description copied from interface:JsonArrayReturns the int value of theJsonNumberat the specified position. If the value at that position is aJsonNumber, this method returnsJsonNumber.intValue(). Otherwise this method returns the specified default value. -
getBoolean
public boolean getBoolean(int index) Description copied from interface:JsonArrayReturns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUEthis method returnstrue. If the value at the specified position isJsonValue.FALSEthis method returnsfalse.- Specified by:
getBooleanin interfaceJsonArray- Parameters:
index- index of the JSON boolean value- Returns:
- the boolean value at the specified position
-
getBoolean
public boolean getBoolean(int index, boolean defaultValue) Description copied from interface:JsonArrayReturns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUEthis method returnstrue. If the value at the specified position isJsonValue.FALSEthis method returnsfalse. Otherwise this method returns the specified default value.- Specified by:
getBooleanin interfaceJsonArray- Parameters:
index- index of the JSON boolean valuedefaultValue- the boolean value to return if theJsonValueat the specified position is neither TRUE nor FALSE- Returns:
- the boolean value at the specified position, or the specified default value
-
isNull
public boolean isNull(int index) Description copied from interface:JsonArrayReturnstrueif the value at the specified location in this array isJsonValue.NULL. -
getValueType
Description copied from interface:JsonValueReturns the value type of this JSON value.- Specified by:
getValueTypein interfaceJsonValue- Returns:
- JSON value type
-
get
-
toString
-
asJsonArray
Description copied from interface:JsonValueReturn the JsonValue as a JsonArray- Specified by:
asJsonArrayin interfaceJsonValue- Returns:
- the JsonValue as a JsonArray
-