public final class DocumentArray extends DocumentElement implements java.lang.Iterable<DocumentElement>
DocumentElement
s 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 and Description |
---|
DocumentArray()
Creates an empty DocumentArray.
|
DocumentArray(int capacity) |
DocumentArray(com.google.gson.JsonArray json) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Boolean bool)
Adds the specified boolean to self.
|
void |
add(java.lang.Character character)
Adds the specified character to self.
|
void |
add(DocumentElement element)
Adds the specified element to self.
|
void |
add(java.lang.Number number)
Adds the specified number to self.
|
void |
add(java.lang.String string)
Adds the specified string to self.
|
void |
addAll(DocumentArray array)
Adds all the elements of the specified array to self.
|
boolean |
contains(DocumentElement element)
Returns true if this array contains the specified element.
|
DocumentArray |
deepCopy()
Creates a deep copy of this element and all its children
|
boolean |
equals(java.lang.Object o) |
DocumentElement |
get(int i)
Returns the ith element of the array.
|
java.math.BigDecimal |
getAsBigDecimal()
convenience method to get this array as a
BigDecimal if it contains a single element. |
java.math.BigInteger |
getAsBigInteger()
convenience method to get this array as a
BigInteger if 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.
|
java.lang.Number |
getAsNumber()
convenience method to get this array as a
Number if it contains a single element. |
short |
getAsShort()
convenience method to get this array as a primitive short if it contains a single element.
|
java.lang.String |
getAsString()
convenience method to get this array as a
String if it contains a single element. |
int |
hashCode() |
java.util.Iterator<DocumentElement> |
iterator()
Returns an iterator to navigate the elements of the array.
|
boolean |
remove(DocumentElement element)
Removes the first occurrence of the specified element from this array, if it is present.
|
DocumentElement |
remove(int index)
Removes the element at the specified position in this array.
|
DocumentElement |
set(int index,
DocumentElement 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.
|
com.google.gson.JsonArray |
toJsonElement() |
fromJson, getAsDocument, getAsDocumentArray, getAsDocumentNull, getAsDocumentPrimitive, isDocument, isDocumentArray, isDocumentNull, isDocumentPrimitive, toString
public DocumentArray()
public DocumentArray(int capacity)
public DocumentArray(com.google.gson.JsonArray json)
public DocumentArray deepCopy()
deepCopy
in class DocumentElement
public com.google.gson.JsonArray toJsonElement()
toJsonElement
in class DocumentElement
public void add(java.lang.Boolean bool)
bool
- the boolean that needs to be added to the array.public void add(java.lang.Character character)
character
- the character that needs to be added to the array.public void add(java.lang.Number number)
number
- the number that needs to be added to the array.public void add(java.lang.String string)
string
- the string that needs to be added to the array.public void add(DocumentElement element)
element
- the element that needs to be added to the array.public void addAll(DocumentArray array)
array
- the array whose elements need to be added to the array.public DocumentElement set(int index, DocumentElement element)
index
- index of the element to replaceelement
- element to be stored at the specified positionjava.lang.IndexOutOfBoundsException
- if the specified index is outside the array boundspublic boolean remove(DocumentElement element)
element
- element to be removed from this array, if presentpublic DocumentElement remove(int index)
index
- index the index of the element to be removedjava.lang.IndexOutOfBoundsException
- if the specified index is outside the array boundspublic boolean contains(DocumentElement element)
element
- whose presence in this array is to be testedpublic int size()
public java.util.Iterator<DocumentElement> iterator()
iterator
in interface java.lang.Iterable<DocumentElement>
public DocumentElement get(int i)
i
- the index of the element that is being sought.java.lang.IndexOutOfBoundsException
- if i is negative or greater than or equal to the size()
of the array.public java.lang.Number getAsNumber()
Number
if it contains a single element.getAsNumber
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid Number.java.lang.IllegalStateException
- if the array has more than one element.public java.lang.String getAsString()
String
if it contains a single element.getAsString
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid String.java.lang.IllegalStateException
- if the array has more than one element.public double getAsDouble()
getAsDouble
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid double.java.lang.IllegalStateException
- if the array has more than one element.public java.math.BigDecimal getAsBigDecimal()
BigDecimal
if it contains a single element.getAsBigDecimal
in class DocumentElement
BigDecimal
if it is single element array.java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
.java.lang.NumberFormatException
- if the element at index 0 is not a valid BigDecimal
.java.lang.IllegalStateException
- if the array has more than one element.public java.math.BigInteger getAsBigInteger()
BigInteger
if it contains a single element.getAsBigInteger
in class DocumentElement
BigInteger
if it is single element array.java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
.java.lang.NumberFormatException
- if the element at index 0 is not a valid BigInteger
.java.lang.IllegalStateException
- if the array has more than one element.public float getAsFloat()
getAsFloat
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid float.java.lang.IllegalStateException
- if the array has more than one element.public long getAsLong()
getAsLong
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid long.java.lang.IllegalStateException
- if the array has more than one element.public int getAsInt()
getAsInt
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid integer.java.lang.IllegalStateException
- if the array has more than one element.public byte getAsByte()
DocumentElement
getAsByte
in class DocumentElement
public char getAsCharacter()
DocumentElement
getAsCharacter
in class DocumentElement
public short getAsShort()
getAsShort
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid short.java.lang.IllegalStateException
- if the array has more than one element.public boolean getAsBoolean()
getAsBoolean
in class DocumentElement
java.lang.ClassCastException
- if the element in the array is of not a DocumentPrimitive
and is not a valid boolean.java.lang.IllegalStateException
- if the array has more than one element.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object