|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<java.lang.Object>
org.pfsw.text.json.JsonArray
public class JsonArray
The Java internal representation of a JSON array.
| Field Summary |
|---|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Fields inherited from interface org.pfsw.bif.text.IJSONConvertible |
|---|
JSON_ARRAY_END, JSON_ARRAY_START, JSON_ELEMENT_SEPARATOR, JSON_LITERAL_FALSE, JSON_LITERAL_NULL, JSON_LITERAL_TRUE, JSON_OBJECT_END, JSON_OBJECT_START, JSON_PAIR_SEPARATOR, JSON_STRING_DELIMITER, JSON_STRING_ESCAPE |
| Constructor Summary | |
|---|---|
JsonArray(java.util.Collection<? extends java.lang.Object> collection)
|
|
JsonArray(int initialCapacity)
|
|
JsonArray(java.lang.Object... objects)
|
|
| Method Summary | ||
|---|---|---|
boolean |
add(java.lang.Object object)
Adds the given element if it is a valid JSON object type. |
|
void |
addElements(java.lang.Object... elements)
Adds all given elements if they are valid JSON object types, which are: JsonObject JsonArray String Boolean Integer Long BigDecimal null Objects of other types will cause an exception. |
|
void |
appendAsJSONString(java.lang.Appendable output)
|
|
|
asList(java.lang.Class<T> elementType)
Returns a copy of this JsonArray as list of elements with the same type. |
|
java.lang.String |
asString()
Returns the JSON string representation of this object. |
|
java.math.BigDecimal |
getBigDecimal(int index)
Returns the value for the given index as BigDecimal (if it is one). |
|
java.lang.Boolean |
getBoolean(int index)
Returns the value for the given index as Boolean (if it is one). |
|
java.lang.Integer |
getInteger(int index)
Returns the value for the given index as Integer (if it is one). |
|
JsonArray |
getJsonArray(int index)
Returns the value at the given index as JsonArray (if it is one). |
|
JsonObject |
getJsonObject(int index)
Returns the value at the given index as JsonObject (if it is one). |
|
java.lang.Long |
getLong(int index)
Returns the value for the given index as Long (if it is one). |
|
java.lang.Number |
getNumber(int index)
Returns the value for the given index as Number (if it is one). |
|
java.lang.String |
getString(int index)
Returns the value for the given index as String (if it is one). |
|
protected
|
getTypedElement(int index,
java.lang.Class<T> type)
|
|
|
getValueOfType(int index,
java.lang.Class<T> type)
Returns the value for the given index as type of the given class. |
|
boolean |
isArray()
Returns true because this is a JSON array representation (in Java). |
|
boolean |
isObject()
Returns false because this is no JSON object representation (in Java). |
|
java.lang.String |
toJSON()
|
|
| Methods inherited from class java.util.ArrayList |
|---|
add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
| Constructor Detail |
|---|
public JsonArray(java.lang.Object... objects)
public JsonArray(java.util.Collection<? extends java.lang.Object> collection)
public JsonArray(int initialCapacity)
| Method Detail |
|---|
public JsonObject getJsonObject(int index)
index - The index of the object to look for.
java.lang.ClassCastException - If the object at the given index is no JsonObject.public JsonArray getJsonArray(int index)
index - The index of the array to look for.
java.lang.ClassCastException - If the object at the given index is no JsonArray.public java.lang.String getString(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no String.public java.lang.Boolean getBoolean(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no Boolean.public java.lang.Number getNumber(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no Number.public java.lang.Integer getInteger(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no Integer.public java.lang.Long getLong(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no Long.public java.math.BigDecimal getBigDecimal(int index)
index - The index of the value to look for.
java.lang.ClassCastException - If the object at the given index is no BigDecimal.
public <T> T getValueOfType(int index,
java.lang.Class<T> type)
index - The index of the value to look for.
java.lang.IllegalArgumentException - If the specified type is no valid JSON type.
java.lang.ClassCastException - If the object at the given index is not of the specified type.public boolean isObject()
isObject in interface JsonTypepublic boolean isArray()
isArray in interface JsonTypepublic boolean add(java.lang.Object object)
Valid types are:
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>java.lang.IllegalArgumentException - If the given object is not of a valid JSON type.public void addElements(java.lang.Object... elements)
java.lang.IllegalArgumentException - If a given element is not of a valid JSON type.public <T> java.util.List<T> asList(java.lang.Class<T> elementType)
elementType - The type all elements must have (must not be null).
java.lang.ClassCastException - If any of the elements in this JsonArray is not of the specified type.public java.lang.String asString()
asString in interface org.pfsw.bif.text.IStringRepresentationpublic void appendAsJSONString(java.lang.Appendable output)
appendAsJSONString in interface org.pfsw.bif.text.IJSONConvertiblepublic java.lang.String toJSON()
toJSON in interface org.pfsw.bif.text.IJSONConvertible
protected <T> T getTypedElement(int index,
java.lang.Class<T> type)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||