public abstract class ListBasedJSONArray extends java.lang.Object implements JSONArray
| Constructor and Description |
|---|
ListBasedJSONArray(java.util.List<java.lang.Object> backingList) |
| Modifier and Type | Method and Description |
|---|---|
<A extends JSONArray,O extends JSONObject> |
clone(JSONBuilder<A,O> builder) |
boolean |
equals(java.lang.Object obj) |
boolean |
equalsList(java.util.List<java.lang.Object> list) |
java.lang.Object |
get(int index)
Get the object value associated with an index.
|
protected java.util.List<java.lang.Object> |
getBackingList() |
boolean |
getBoolean(int index)
Get the boolean value associated with an index.
|
double |
getDouble(int index)
Get the double value associated with an index.
|
int |
getInt(int index)
Get the int value associated with an index.
|
ListBasedJSONArray |
getJSONArray(int index)
Get the JSONArray associated with an index.
|
MapBasedJSONObject |
getJSONObject(int index)
Get the JSONObject associated with an index.
|
long |
getLong(int index)
Get the long value associated with an index.
|
java.lang.String |
getString(int index)
Get the string associated with an index.
|
int |
hashCode() |
int |
indexOf(java.lang.Object value) |
boolean |
isNull(int index)
Determine if the value is null.
|
java.util.Iterator<java.lang.Object> |
iterator() |
int |
length()
Get the number of elements in the JSONArray, included nulls.
|
java.lang.Object |
opt(int index)
Get the optional object value associated with an index.
|
boolean |
optBoolean(int index)
Get the optional boolean value associated with an index.
|
boolean |
optBoolean(int index,
boolean defaultValue)
Get the optional boolean value associated with an index.
|
double |
optDouble(int index)
Get the optional double value associated with an index.
|
double |
optDouble(int index,
double defaultValue)
Get the optional double value associated with an index.
|
int |
optInt(int index)
Get the optional int value associated with an index.
|
int |
optInt(int index,
int defaultValue)
Get the optional int value associated with an index.
|
ListBasedJSONArray |
optJSONArray(int index)
Get the optional JSONArray associated with an index.
|
JSONObject |
optJSONObject(int index)
Get the optional JSONObject associated with an index.
|
long |
optLong(int index)
Get the optional long value associated with an index.
|
long |
optLong(int index,
long defaultValue)
Get the optional long value associated with an index.
|
java.lang.String |
optString(int index)
Get the optional string value associated with an index.
|
java.lang.String |
optString(int index,
java.lang.String defaultValue)
Get the optional string associated with an index.
|
ListBasedJSONArray |
put(boolean value)
Append a boolean value.
|
ListBasedJSONArray |
put(double value)
Append a double value.
|
ListBasedJSONArray |
put(int value)
Append an int value.
|
ListBasedJSONArray |
put(int index,
boolean value)
Put or replace a boolean value in the JSONArray.
|
ListBasedJSONArray |
put(int index,
double value)
Put or replace a double value.
|
ListBasedJSONArray |
put(int index,
int value)
Put or replace an int value.
|
ListBasedJSONArray |
put(int index,
long value)
Put or replace a long value.
|
ListBasedJSONArray |
put(int index,
java.lang.Object value)
Put or replace an object value in the JSONArray.
|
ListBasedJSONArray |
put(long value)
Append an long value.
|
ListBasedJSONArray |
put(java.lang.Object value)
Append an object value.
|
java.lang.Object |
remove(int index)
Remove an index and close the hole.
|
boolean |
remove(java.lang.Object object)
Remove the first instance of an Object from the array.
|
java.lang.String |
toString()
Make a JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor,
int indent)
Make a prettyprinted JSON text of this JSONArray.
|
java.lang.Appendable |
write(java.lang.Appendable writer)
Write the contents of the JSONArray as JSON text to a writer.
|
public ListBasedJSONArray(java.util.List<java.lang.Object> backingList)
protected java.util.List<java.lang.Object> getBackingList()
public java.lang.Object get(int index)
public boolean getBoolean(int index)
throws JSONException
getBoolean in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If there is no value for the index or if the value is not convertible to boolean.public double getDouble(int index)
throws JSONException
getDouble in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted to a number.public int getInt(int index)
throws JSONException
getInt in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value is not a number.public ListBasedJSONArray getJSONArray(int index) throws JSONException
getJSONArray in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If there is no value for the index. or if the value is not a JSONArraypublic MapBasedJSONObject getJSONObject(int index) throws JSONException
getJSONObject in interface JSONArrayindex - subscriptJSONException - If there is no value for the index or if the value is not a JSONObjectpublic long getLong(int index)
throws JSONException
getLong in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted to a number.public java.lang.String getString(int index)
throws JSONException
getString in interface JSONArrayindex - The index must be between 0 and length() - 1.JSONException - If there is no value for the index.public boolean isNull(int index)
public int length()
public java.lang.Object opt(int index)
public boolean optBoolean(int index)
optBoolean in interface JSONArrayindex - The index must be between 0 and length() - 1.public boolean optBoolean(int index,
boolean defaultValue)
optBoolean in interface JSONArrayindex - The index must be between 0 and length() - 1.defaultValue - A boolean default.public double optDouble(int index)
public double optDouble(int index,
double defaultValue)
public int optInt(int index)
public int optInt(int index,
int defaultValue)
public ListBasedJSONArray optJSONArray(int index)
optJSONArray in interface JSONArrayindex - subscriptpublic JSONObject optJSONObject(int index)
optJSONObject in interface JSONArrayindex - The index must be between 0 and length() - 1.public long optLong(int index)
public long optLong(int index,
long defaultValue)
public java.lang.String optString(int index)
public java.lang.String optString(int index,
java.lang.String defaultValue)
public ListBasedJSONArray put(boolean value)
public ListBasedJSONArray put(double value) throws JSONException
put in interface JSONArrayvalue - A double value.JSONException - if the value is not finite.public ListBasedJSONArray put(int value)
public ListBasedJSONArray put(long value)
public ListBasedJSONArray put(java.lang.Object value)
public ListBasedJSONArray put(int index, boolean value) throws JSONException
put in interface JSONArrayindex - The subscript.value - A boolean value.JSONException - If the index is negative.public ListBasedJSONArray put(int index, double value) throws JSONException
put in interface JSONArrayindex - The subscript.value - A double value.JSONException - If the index is negative or if the value is not finite.public ListBasedJSONArray put(int index, int value) throws JSONException
put in interface JSONArrayindex - The subscript.value - An int value.JSONException - If the index is negative.public ListBasedJSONArray put(int index, long value) throws JSONException
put in interface JSONArrayindex - The subscript.value - A long value.JSONException - If the index is negative.public ListBasedJSONArray put(int index, java.lang.Object value) throws JSONException
put in interface JSONArrayindex - The subscript.value - The value to put into the array. The value should be a Boolean, Double, Integer,
JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.JSONException - If the index is negative or if the the value is an invalid number.public java.lang.Object remove(int index)
public boolean remove(java.lang.Object object)
JSONArraypublic java.lang.String toString()
Warning: This method assumes that the data structure is acyclical.
toString in interface JSONComponenttoString in class java.lang.Objectpublic java.lang.String toString(int indentFactor)
toString in interface JSONComponentindentFactor - The number of spaces to add to each level of indentation.[ (left bracket) and ending with ]
(right bracket).public final java.lang.String toString(int indentFactor,
int indent)
toString in interface JSONComponentindentFactor - The number of spaces to add to each level of indentation.indent - The indention of the top level.public java.lang.Appendable write(java.lang.Appendable writer)
throws java.io.IOException
Warning: This method assumes that the data structure is acyclical.
write in interface JSONComponentjava.io.IOExceptionpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equalsList(java.util.List<java.lang.Object> list)
equalsList in interface JSONArraypublic java.util.Iterator<java.lang.Object> iterator()
public <A extends JSONArray,O extends JSONObject> A clone(JSONBuilder<A,O> builder) throws JSONException
clone in interface JSONArrayJSONException