Package org.glassfish.json
Class JsonArrayBuilderImpl.JsonArrayImpl
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<JsonValue>
-
- org.glassfish.json.JsonArrayBuilderImpl.JsonArrayImpl
-
- All Implemented Interfaces:
java.lang.Iterable<JsonValue>,java.util.Collection<JsonValue>,java.util.List<JsonValue>,JsonArray,JsonStructure,JsonValue
- Enclosing class:
- JsonArrayBuilderImpl
private static final class JsonArrayBuilderImpl.JsonArrayImpl extends java.util.AbstractList<JsonValue> implements JsonArray
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.json.JsonValue
JsonValue.ValueType
-
-
Field Summary
Fields Modifier and Type Field Description private BufferPoolbufferPoolprivate java.util.List<JsonValue>valueList-
Fields inherited from interface javax.json.JsonValue
EMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE
-
-
Constructor Summary
Constructors Constructor Description JsonArrayImpl(java.util.List<JsonValue> valueList, BufferPool bufferPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArrayasJsonArray()Return the JsonValue as a JsonArrayJsonValueget(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.JsonArraygetJsonArray(int index)Returns the array value at the specified position in this array.JsonNumbergetJsonNumber(int index)Returns the number value at the specified position in this array.JsonObjectgetJsonObject(int index)Returns the object value at the specified position in this array.JsonStringgetJsonString(int index)Returns the string value at ths specified position in this array.java.lang.StringgetString(int index)A convenience method forgetJsonString(index).getString().java.lang.StringgetString(int index, java.lang.String defaultValue)Returns theStringvalue ofJsonStringat the specified position in this JSON array values.<T extends JsonValue>
java.util.List<T>getValuesAs(java.lang.Class<T> clazz)Returns a list view of the specified type for the array.JsonValue.ValueTypegetValueType()Returns the value type of this JSON value.booleanisNull(int index)Returnstrueif the value at the specified location in this array isJsonValue.NULL.intsize()java.lang.StringtoString()Returns JSON text for this JSON value.-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.json.JsonArray
getValuesAs
-
Methods inherited from interface javax.json.JsonStructure
getValue
-
Methods inherited from interface javax.json.JsonValue
asJsonObject
-
-
-
-
Field Detail
-
valueList
private final java.util.List<JsonValue> valueList
-
bufferPool
private final BufferPool bufferPool
-
-
Constructor Detail
-
JsonArrayImpl
JsonArrayImpl(java.util.List<JsonValue> valueList, BufferPool bufferPool)
-
-
Method Detail
-
size
public int size()
-
getJsonObject
public JsonObject getJsonObject(int index)
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
public JsonArray getJsonArray(int index)
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
public JsonNumber getJsonNumber(int index)
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
public JsonString getJsonString(int index)
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
public <T extends JsonValue> java.util.List<T> getValuesAs(java.lang.Class<T> clazz)
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
public java.lang.String getString(int index)
Description copied from interface:JsonArrayA convenience method forgetJsonString(index).getString().
-
getString
public java.lang.String getString(int index, java.lang.String defaultValue)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
public int getInt(int index)
Description copied from interface:JsonArrayA convenience method forgetJsonNumber(index).intValue().
-
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
public JsonValue.ValueType getValueType()
Description copied from interface:JsonValueReturns the value type of this JSON value.- Specified by:
getValueTypein interfaceJsonValue- Returns:
- JSON value type
-
get
public JsonValue get(int index)
-
toString
public java.lang.String toString()
Description copied from interface:JsonValueReturns JSON text for this JSON value.
-
asJsonArray
public JsonArray asJsonArray()
Description copied from interface:JsonValueReturn the JsonValue as a JsonArray- Specified by:
asJsonArrayin interfaceJsonValue- Returns:
- the JsonValue as a JsonArray
-
-