| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gson.JsonElement
com.google.gson.JsonArray
public final class JsonArray
A class representing an array type in Json. An array is a list of JsonElements each of
 which can be of a different type. This is an ordered list, meaning that the order in which
 elements are added is preserved.
| Constructor Summary | |
|---|---|
| JsonArray()Creates an empty JsonArray. | |
| Method Summary | |
|---|---|
|  void | add(JsonElement element)Adds the specified element to self. | 
|  void | addAll(JsonArray array)Adds all the elements of the specified array to self. | 
|  boolean | contains(JsonElement element)Returns true if this array contains the specified element. | 
|  boolean | equals(Object o) | 
|  JsonElement | get(int i)Returns the ith element of the array. | 
|  BigDecimal | getAsBigDecimal()convenience method to get this array as a BigDecimalif it contains a single element. | 
|  BigInteger | getAsBigInteger()convenience method to get this array as a BigIntegerif it contains a single element. | 
|  boolean | getAsBoolean()convenience method to get this array as a boolean if it contains a single element. | 
|  byte | getAsByte()convenience method to get this element as a primitive byte value. | 
|  char | getAsCharacter()convenience method to get this element as a primitive character value. | 
|  double | getAsDouble()convenience method to get this array as a double if it contains a single element. | 
|  float | getAsFloat()convenience method to get this array as a float if it contains a single element. | 
|  int | getAsInt()convenience method to get this array as an integer if it contains a single element. | 
|  long | getAsLong()convenience method to get this array as a long if it contains a single element. | 
|  Number | getAsNumber()convenience method to get this array as a Numberif it contains a single element. | 
|  short | getAsShort()convenience method to get this array as a primitive short if it contains a single element. | 
|  String | getAsString()convenience method to get this array as a Stringif it contains a single element. | 
|  int | hashCode() | 
|  Iterator<JsonElement> | iterator()Returns an iterator to navigate the elemetns of the array. | 
|  JsonElement | remove(int index)Removes the element at the specified position in this array. | 
|  boolean | remove(JsonElement element)Removes the first occurrence of the specified element from this array, if it is present. | 
|  JsonElement | set(int index,
    JsonElement element)Replaces the element at the specified position in this array with the specified element. | 
|  int | size()Returns the number of elements in the array. | 
| Methods inherited from class com.google.gson.JsonElement | 
|---|
| getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public JsonArray()
| Method Detail | 
|---|
public void add(JsonElement element)
element - the element that needs to be added to the array.public void addAll(JsonArray array)
array - the array whose elements need to be added to the array.
public JsonElement set(int index,
                       JsonElement element)
index - index of the element to replaceelement - element to be stored at the specified position
IndexOutOfBoundsException - if the specified index is outside the array boundspublic boolean remove(JsonElement element)
element - element to be removed from this array, if present
public JsonElement remove(int index)
index - index the index of the element to be removed
IndexOutOfBoundsException - if the specified index is outside the array boundspublic boolean contains(JsonElement element)
element - whose presence in this array is to be tested
public int size()
public Iterator<JsonElement> iterator()
iterator in interface Iterable<JsonElement>public JsonElement get(int i)
i - the index of the element that is being sought.
IndexOutOfBoundsException - if i is negative or greater than or equal to the
 size() of the array.public Number getAsNumber()
Number if it contains a single element.
getAsNumber in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid Number.
IllegalStateException - if the array has more than one element.public String getAsString()
String if it contains a single element.
getAsString in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid String.
IllegalStateException - if the array has more than one element.public double getAsDouble()
getAsDouble in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid double.
IllegalStateException - if the array has more than one element.public BigDecimal getAsBigDecimal()
BigDecimal if it contains a single element.
getAsBigDecimal in class JsonElementBigDecimal if it is single element array.
ClassCastException - if the element in the array is of not a JsonPrimitive.
NumberFormatException - if the element at index 0 is not a valid BigDecimal.
IllegalStateException - if the array has more than one element.public BigInteger getAsBigInteger()
BigInteger if it contains a single element.
getAsBigInteger in class JsonElementBigInteger if it is single element array.
ClassCastException - if the element in the array is of not a JsonPrimitive.
NumberFormatException - if the element at index 0 is not a valid BigInteger.
IllegalStateException - if the array has more than one element.public float getAsFloat()
getAsFloat in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid float.
IllegalStateException - if the array has more than one element.public long getAsLong()
getAsLong in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid long.
IllegalStateException - if the array has more than one element.public int getAsInt()
getAsInt in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid integer.
IllegalStateException - if the array has more than one element.public byte getAsByte()
JsonElement
getAsByte in class JsonElementpublic char getAsCharacter()
JsonElement
getAsCharacter in class JsonElementpublic short getAsShort()
getAsShort in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid short.
IllegalStateException - if the array has more than one element.public boolean getAsBoolean()
getAsBoolean in class JsonElementClassCastException - if the element in the array is of not a JsonPrimitive and
 is not a valid boolean.
IllegalStateException - if the array has more than one element.public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||