public class JSONArray
extends java.util.ArrayList<java.lang.Object>
Constructor and Description |
---|
JSONArray()
Construct a default JSONArray.
|
JSONArray(java.util.Collection<java.lang.Object> collection)
Construct a JSONArray and fill it with object from a collection.
|
JSONArray(int size)
Construct a JSONArray with an initial size
|
Modifier and Type | Method and Description |
---|---|
void |
add(int idx,
java.lang.Object o)
Inserts the specified element at the specified position in this
list.
|
boolean |
add(java.lang.Object o)
Appends the specified element to the end of this list.
|
boolean |
addAll(java.util.Collection<? extends java.lang.Object> collection)
Appends all of the elements in the specified collection to the
end of this list, in the order that they are returned by the
specified collection's Iterator.
|
boolean |
addAll(int idx,
java.util.Collection<? extends java.lang.Object> collection)
Inserts all of the elements in the specified collection into
this list, starting at the specified position.
|
java.lang.Object |
set(int idx,
java.lang.Object o)
Replaces the element at the specified position in this list
with the specified element.
|
clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
public JSONArray()
public JSONArray(java.util.Collection<java.lang.Object> collection)
collection
- the collection of objects to fill the arrayjava.lang.ClassCastException
- if one of the array members is not a
suitable JSON objectpublic JSONArray(int size)
size
- the initial capacity of the arraypublic boolean add(java.lang.Object o) throws java.lang.ClassCastException
add
in interface java.util.Collection<java.lang.Object>
add
in interface java.util.List<java.lang.Object>
add
in class java.util.ArrayList<java.lang.Object>
o
- element to be appended to this listtrue
(as specified by Collection.add(E)
)java.lang.ClassCastException
- if the passed in Object is not a
suitable JSON objectpublic void add(int idx, java.lang.Object o) throws java.lang.IndexOutOfBoundsException, java.lang.ClassCastException
add
in interface java.util.List<java.lang.Object>
add
in class java.util.ArrayList<java.lang.Object>
idx
- element to be insertedo
- element to be insertedjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
java.lang.ClassCastException
- if the passed in Object is not a
suitable JSON objectpublic boolean addAll(java.util.Collection<? extends java.lang.Object> collection) throws java.lang.ClassCastException
addAll
in interface java.util.Collection<java.lang.Object>
addAll
in interface java.util.List<java.lang.Object>
addAll
in class java.util.ArrayList<java.lang.Object>
collection
- collection containing elements to be added to
this listtrue
if the list changed as a result of the calljava.lang.NullPointerException
- If the collection is null
java.lang.ClassCastException
- if the passed in Object is not a
suitable JSON objectpublic boolean addAll(int idx, java.util.Collection<? extends java.lang.Object> collection) throws java.lang.IndexOutOfBoundsException, java.lang.ClassCastException
addAll
in interface java.util.List<java.lang.Object>
addAll
in class java.util.ArrayList<java.lang.Object>
idx
- index at which to insert the first element from the
specified collectioncollection
- collection containing elements to be added to
this listtrue
if the list changed as a result of the calljava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
java.lang.NullPointerException
- If the collection is null
java.lang.ClassCastException
- if any of the members of the
collection is not a suitable JSON objectpublic java.lang.Object set(int idx, java.lang.Object o) throws java.lang.IndexOutOfBoundsException, java.lang.ClassCastException
set
in interface java.util.List<java.lang.Object>
set
in class java.util.ArrayList<java.lang.Object>
idx
- index of the element to replaceo
- element to be stored at the specified positionjava.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
java.lang.ClassCastException
- if any members of the collection is
not a suitable JSON object