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 BufferPool
bufferPool
private java.util.List<JsonValue>
valueList
-
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 JsonValue
get(int index)
boolean
getBoolean(int index)
Returns the boolean value at the specified position.boolean
getBoolean(int index, boolean defaultValue)
Returns the boolean value at the specified position.int
getInt(int index)
A convenience method forgetJsonNumber(index).intValue()
.int
getInt(int index, int defaultValue)
Returns the int value of theJsonNumber
at the specified position.JsonArray
getJsonArray(int index)
Returns the array value at the specified position in this array.JsonNumber
getJsonNumber(int index)
Returns the number value at the specified position in this array.JsonObject
getJsonObject(int index)
Returns the object value at the specified position in this array.JsonString
getJsonString(int index)
Returns the string value at ths specified position in this array.java.lang.String
getString(int index)
A convenience method forgetJsonString(index).getString()
.java.lang.String
getString(int index, java.lang.String defaultValue)
Returns theString
value ofJsonString
at the specified position in this JSON array values.<T extends JsonValue>
java.util.List<T>getValuesAs(java.lang.Class<T> clazz)
Returns a list a view of the specified type for the array.JsonValue.ValueType
getValueType()
Returns the value type of this JSON value.boolean
isNull(int index)
Returnstrue
if the value at the specified location in this array isJsonValue.NULL
.int
size()
java.lang.String
toString()
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
-
-
-
-
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:JsonArray
Returns the object value at the specified position in this array. This is a convenience method for(JsonObject)get(index)
.- Specified by:
getJsonObject
in 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:JsonArray
Returns the array value at the specified position in this array. This is a convenience method for(JsonArray)get(index)
.- Specified by:
getJsonArray
in 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:JsonArray
Returns the number value at the specified position in this array. This is a convenience method for(JsonNumber)get(index)
.- Specified by:
getJsonNumber
in 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:JsonArray
Returns the string value at ths specified position in this array. This is a convenience method for(JsonString)get(index)
.- Specified by:
getJsonString
in 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:JsonArray
Returns a list a 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:
getValuesAs
in interfaceJsonArray
- 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:JsonArray
A convenience method forgetJsonString(index).getString()
.
-
getString
public java.lang.String getString(int index, java.lang.String defaultValue)
Description copied from interface:JsonArray
Returns theString
value ofJsonString
at the specified position in this JSON array values. IfJsonString
is found, itsJsonString.getString()
is returned. Otherwise, the specified default value is returned.
-
getInt
public int getInt(int index)
Description copied from interface:JsonArray
A convenience method forgetJsonNumber(index).intValue()
.
-
getInt
public int getInt(int index, int defaultValue)
Description copied from interface:JsonArray
Returns the int value of theJsonNumber
at 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:JsonArray
Returns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUE
this method returnstrue
. If the value at the specified position isJsonValue.FALSE
this method returnsfalse
.- Specified by:
getBoolean
in 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:JsonArray
Returns the boolean value at the specified position. If the value at the specified position isJsonValue.TRUE
this method returnstrue
. If the value at the specified position isJsonValue.FALSE
this method returnsfalse
. Otherwise this method returns the specified default value.- Specified by:
getBoolean
in interfaceJsonArray
- Parameters:
index
- index of the JSON boolean value- Returns:
- the boolean value at the specified position, or the specified default value
-
isNull
public boolean isNull(int index)
Description copied from interface:JsonArray
Returnstrue
if the value at the specified location in this array isJsonValue.NULL
.
-
getValueType
public JsonValue.ValueType getValueType()
Description copied from interface:JsonValue
Returns the value type of this JSON value.- Specified by:
getValueType
in interfaceJsonValue
- Returns:
- JSON value type
-
get
public JsonValue get(int index)
-
-