public class ZSONArray extends Object
This class encapsulates a JSON array based on the standard JSON data structure. In addition to data read and write, this class provides basic processing capabilities for the arrays, for example, traversing, querying, modifying, and deleting array elements.
| 构造器 | 说明 |
|---|---|
ZSONArray() |
Default constructor used to create a
ZSONArray instance. |
ZSONArray(int initialCapacity) |
A constructor used to create a
ZSONArray instance with a specified capacity. |
ZSONArray(List<Object> list) |
A constructor used to create a
ZSONArray instance using a specified list. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
add(int index,
Object element) |
Adds an
Element object to the specified index in this ZSONArray. |
boolean |
add(Object obj) |
Adds a specified
obj object to this ZSONArray. |
boolean |
addAll(int index,
Collection<?> c) |
Adds the entire
c object to this ZSONArray at the specified index. |
boolean |
addAll(Collection<?> c) |
Adds the entire
c object to this ZSONArray. |
void |
clear() |
Clears this
ZSONArray. |
Object |
clone() |
Clones this
ZSONArray object. |
boolean |
contains(Object obj) |
Checks whether this
ZSONArray contains an obj object. |
boolean |
containsAll(Collection<?> c) |
Checks whether this
ZSONArray contains a c object. |
Object |
get(int index) |
Obtains the object at the specified index in this
ZSONArray. |
BigDecimal |
getBigDecimal(int index) |
Obtains the
BigDecimal object at the specified index of this ZSONArray. |
BigInteger |
getBigInteger(int index) |
Obtains the
BigInteger object at the specified index of this ZSONArray. |
Boolean |
getBoolean(int index) |
Obtains the
boolean value at the specified index of this ZSONArray and automatically converts
the value into a Boolean object. |
boolean |
getBooleanValue(int index) |
Obtains the
boolean value at the specified index of this ZSONArray. |
Byte |
getByte(int index) |
Obtains the
byte value at specified index of this ZSONArray and automatically converts
the value into a Byte object. |
byte |
getByteValue(int index) |
Obtains the
byte value at the specified index of this ZSONArray. |
Date |
getDate(int index) |
Obtains the
Date object at the specified index of this ZSONArray. |
Double |
getDouble(int index) |
Obtains the
double value at the specified index of this ZSONArray and automatically converts
the value into a Double object. |
double |
getDoubleValue(int index) |
Obtains the
double value at the specified index of this ZSONArray. |
Float |
getFloat(int index) |
Obtains the
float value at the specified index of this ZSONArray and automatically converts
the value into a Float object. |
float |
getFloatValue(int index) |
Obtains the
float value at the specified index of this ZSONArray. |
Integer |
getInteger(int index) |
Obtains the
int value at the specified index of this ZSONArray and automatically converts the
value into an Integer object. |
int |
getIntValue(int index) |
Obtains the
int value at the specified index of this ZSONArray. |
Long |
getLong(int index) |
Obtains the
long value at the specified index of this ZSONArray and automatically converts
the value into a Long object. |
long |
getLongValue(int index) |
Obtains the
long value at the specified index of this ZSONArray. |
<T> T |
getObject(int index,
Class<T> clazz) |
Obtains the object at the specified index of this
ZSONArray and converts it into a class object
specified by clazz. |
Short |
getShort(int index) |
Obtains the
short value at the specified index of this ZSONArray and automatically converts
the value into a Short object. |
short |
getShortValue(int index) |
Obtains the
short value at the specified index of this ZSONArray. |
String |
getString(int index) |
Obtains the
String object at the specified index of this ZSONArray. |
ZSONArray |
getZSONArray(int index) |
Obtains the
ZSONArray object at the specified index of this ZSONArray. |
ZSONObject |
getZSONObject(int index) |
Obtains the
ZSONObject at the specified index in this ZSONArray. |
int |
indexOf(Object obj) |
Obtains the first index of the specified
obj object in this ZSONArray. |
boolean |
isEmpty() |
Checks whether this
ZSONArray contains no object. |
Iterator<Object> |
iterator() |
Obtains the
Iterator objects of this ZSONArray. |
int |
lastIndexOf(Object obj) |
Obtains the last index of the specified
obj object in this ZSONArray. |
ListIterator<Object> |
listIterator() |
Obtains the
ListIterator objects of this ZSONArray. |
ListIterator<Object> |
listIterator(int index) |
Obtains the
ListIterator objects of this ZSONArray from the specified index. |
Object |
remove(int index) |
Removes the object at the specified index in this
ZSONArray. |
boolean |
remove(Object obj) |
Removes the specified
obj object from this ZSONArray. |
boolean |
removeAll(Collection<?> c) |
Removes the entire
c object from this ZSONArray. |
boolean |
retainAll(Collection<?> c) |
Retains the entire
c object when removing all other objects from this ZSONArray. |
Object |
set(int index,
Object element) |
Sets the object at the specified index in this
ZSONArray to an Element object. |
int |
size() |
Obtains the size of this
ZSONArray. |
static <T> List<T> |
stringToClassList(String text,
Class<T> clazz) |
Convert the text to a class list.
|
static ZSONArray |
stringToZSONArray(String text) |
Convert the text to a
ZSONArray object. |
List<Object> |
subList(int fromIndex,
int toIndex) |
Obtains the
ListIterator objects of this ZSONArray within the specified index range. |
Object[] |
toArray() |
Converts the objects stored in this
ZSONArray into an array. |
<T> T[] |
toArray(T[] a) |
Converts the objects stored in this
ZSONArray into an array based on the specified template type
a. |
<T> List<T> |
toJavaList(Class<T> clazz) |
Converts a
ZSONArray object into a list based on the specified clazz type. |
String |
toString() |
Obtains the JSON-based string representation of the
ZSONArray object. |
ZSONObject |
toZSONObject(String[] keys) |
Pairs elements in this
ZSONArray instance with the specified keys to form a ZSONObject
object. |
public ZSONArray()
ZSONArray instance.public ZSONArray(List<Object> list)
ZSONArray instance using a specified list.list - Indicates the list used to create the ZSONArray instance.public ZSONArray(int initialCapacity)
ZSONArray instance with a specified capacity.initialCapacity - Indicates the initial capacity of the ZSONArray instance to create. This parameter
is also used to create a ArrayList<E>, and its maximum value is
Integer.MAX_VALUE-8. If you set this parameter to a value larger than Integer.MAX_VALUE-8,
the ZSONArray instance fails to be created.public static final ZSONArray stringToZSONArray(String text)
ZSONArray object.text - The text to be converted.ZSONArray object.ZSONException - Throws this exception if the parser error.public static final <T> List<T> stringToClassList(String text, Class<T> clazz)
T - The class type convert to.text - The text to be converted.clazz - The class convert to.ZSONException - Throws this exception if the parser error.public int size()
ZSONArray.ZSONArray.public boolean isEmpty()
ZSONArray contains no object.true if this ZSONArray contains no object; returns false otherwise.public boolean contains(Object obj)
ZSONArray contains an obj object.obj - Indicates the object to check.true if this ZSONArray contains an obj object; returns false
otherwise.public Iterator<Object> iterator()
Iterator objects of this ZSONArray.Iterator objects.public Object[] toArray()
ZSONArray into an array.public <T> T[] toArray(T[] a)
ZSONArray into an array based on the specified template type
a.a - Indicates the template type used for converting the objects.public boolean add(Object obj)
obj object to this ZSONArray.obj - Indicates the object to add.true if the object is successfully added; returns false otherwise.public boolean remove(Object obj)
obj object from this ZSONArray.obj - Indicates the obj object to remove.true if the object is successfully removed; returns false otherwise.public boolean containsAll(Collection<?> c)
ZSONArray contains a c object.c - Indicates the object to check.true if this ZSONArray contains a c object; returns false
otherwise.public boolean addAll(Collection<?> c)
c object to this ZSONArray.c - Indicates the object to add.true if the object is successfully added; returns false otherwise.public boolean addAll(int index,
Collection<?> c)
c object to this ZSONArray at the specified index.index - Indicates the position to add the c object in this ZSONArray.c - Indicates the object to add.true if the object is successfully added; returns false otherwise.public boolean removeAll(Collection<?> c)
c object from this ZSONArray.c - Indicates the object to remove.true if the object is successfully removed; returns false otherwise.public boolean retainAll(Collection<?> c)
c object when removing all other objects from this ZSONArray.c - Indicates the object to retain.true if the object is successfully retained; returns false otherwise.public void clear()
ZSONArray.public Object set(int index, Object element)
ZSONArray to an Element object.index - Indicates the position of the object to set in this ZSONArray.element - Indicates the Element object to set.public void add(int index,
Object element)
Element object to the specified index in this ZSONArray.index - Indicates the position to add the Element object in this ZSONArray.element - Indicates the Element object to add.public Object remove(int index)
ZSONArray.index - Indicates the position of the object to remove from this ZSONArray.public int indexOf(Object obj)
obj object in this ZSONArray.obj - Indicates the object to query.public int lastIndexOf(Object obj)
obj object in this ZSONArray.obj - Indicates the object to query.public ListIterator<Object> listIterator()
ListIterator objects of this ZSONArray.ListIterator objects.public ListIterator<Object> listIterator(int index)
ListIterator objects of this ZSONArray from the specified index.index - Indicates the position to obtain the ListIterator objects.ListIterator objects.public List<Object> subList(int fromIndex, int toIndex)
ListIterator objects of this ZSONArray within the specified index range.fromIndex - Indicates the start position to obtain the ListIterator objects.toIndex - Indicates the end position to obtain the ListIterator objects.ListIterator objects.public Object get(int index)
ZSONArray.index - Indicates the position to obtain the object.ZSONArray.public ZSONObject getZSONObject(int index)
ZSONObject at the specified index in this ZSONArray.index - Indicates the position to obtain the object.ZSONObject at the specified index in this ZSONArray,
or null when the object is not found.public ZSONArray getZSONArray(int index)
ZSONArray object at the specified index of this ZSONArray.index - Indicates the index of a ZSONArray stored in this ZSONArray.ZSONArray at the specified index, or null when the array is not found.public <T> T getObject(int index,
Class<T> clazz)
ZSONArray and converts it into a class object
specified by clazz.index - Indicates the index of an object stored in this ZSONArray.clazz - Indicates the class type of the object to return. This object is converted from the value stored in
this ZSONArray.public Boolean getBoolean(int index)
boolean value at the specified index of this ZSONArray and automatically converts
the value into a Boolean object.index - Indicates the index of a Boolean object stored in this ZSONArray.Boolean object at the specified index.public boolean getBooleanValue(int index)
boolean value at the specified index of this ZSONArray.index - Indicates the index of a boolean value stored in this ZSONArray.boolean value at the specified index.public Byte getByte(int index)
byte value at specified index of this ZSONArray and automatically converts
the value into a Byte object.index - Indicates the index of a Byte object stored in this ZSONArray.Byte object at the specified index.public byte getByteValue(int index)
byte value at the specified index of this ZSONArray.index - Indicates the index of a byte value stored in this ZSONArray.byte value at the specified index.public Short getShort(int index)
short value at the specified index of this ZSONArray and automatically converts
the value into a Short object.index - Indicates the index of a Short object stored in this ZSONArray.Short object at the specified index.public short getShortValue(int index)
short value at the specified index of this ZSONArray.index - Indicates the index of a short value in this ZSONArray.short value at the specified index.public Integer getInteger(int index)
int value at the specified index of this ZSONArray and automatically converts the
value into an Integer object.index - Indicates the index of a Integer value in this ZSONArray.Integer object at the specified index.public int getIntValue(int index)
int value at the specified index of this ZSONArray.index - Indicates the index of a int value stored in this ZSONArray.int value at the specified index.public Long getLong(int index)
long value at the specified index of this ZSONArray and automatically converts
the value into a Long object.index - Indicates the index of a Long object stored in this ZSONArray.Long object at the specified index.public long getLongValue(int index)
long value at the specified index of this ZSONArray.index - Indicates the index of a Long value stored in this ZSONArray.long value at the specified index.public Float getFloat(int index)
float value at the specified index of this ZSONArray and automatically converts
the value into a Float object.index - Indicates the index of a Float object stored in this ZSONArray.Float object at the specified index.public float getFloatValue(int index)
float value at the specified index of this ZSONArray.index - Indicates the index of a float value stored in this ZSONArray.float value at the specified index.public Double getDouble(int index)
double value at the specified index of this ZSONArray and automatically converts
the value into a Double object.index - Indicates the index of a Double object stored in this ZSONArray.Double object at the specified index.public double getDoubleValue(int index)
double value at the specified index of this ZSONArray.index - Indicates the index of a double value stored in this ZSONArray.double value at the specified index.public BigDecimal getBigDecimal(int index)
BigDecimal object at the specified index of this ZSONArray.index - Indicates the index of a BigDecimal object stored in this ZSONArray.BigDecimal object at the specified index.public BigInteger getBigInteger(int index)
BigInteger object at the specified index of this ZSONArray.index - Indicates the index of a BigInteger object stored in this ZSONArray.BigInteger object at the specified index.public String getString(int index)
String object at the specified index of this ZSONArray.index - Indicates the index of a String object stored in this ZSONArray.String object at the specified index.public Date getDate(int index)
Date object at the specified index of this ZSONArray.index - Indicates the index of a Date object stored in this ZSONArray.Date object at the specified index.public Object clone()
ZSONArray object.public <T> List<T> toJavaList(Class<T> clazz)
ZSONArray object into a list based on the specified clazz type.clazz - Indicates the class type for converting the ZSONArray object.public ZSONObject toZSONObject(String[] keys)
ZSONArray instance with the specified keys to form a ZSONObject
object.
If the length of keys does not match the length of elements in this ZSONArray instance, the
smaller length is used. Elements in the returned object are arranged in accordance with the sequence of
keys.
keys - Indicates the keys used to match the elements in this ZSONArray instance.ZSONObject object.NullPointerException - Throws this exception if keys is null.