Class JsonArray
- java.lang.Object
-
- com.alachisoft.ncache.runtime.JSON.JsonValueBase
-
- com.alachisoft.ncache.runtime.JSON.JsonArray
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<JsonValueBase>
public final class JsonArray extends JsonValueBase implements java.io.Serializable, java.lang.Iterable<JsonValueBase>
Class represnts JArray in JSON standards.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(JsonValue item)Adds JSONValue item to array.voidadd(JsonValueBase item)Adds JSONValueBase item to array.voidclear()Clears all array items and brings count to 0.booleancontains(JsonValue item)Checks if a JSONValue item exists in array.booleancontains(JsonValueBase item)Checks if a JsonValueBase item exists in array.voidcopyTo(JsonValueBase[] array, int arrayIndex)Copies items from provided array starting from a particular array index.booleanequals(java.lang.Object obj)Checks if an obj is equal to this instance of JSONArray.intgetCount()Gets the number of items in the JsonArray.JsonValueBasegetItem(int index)Gets the item at the specified index for the JSON Arary.java.util.Iterator<JsonValueBase>getIterator()Returns theIteratorthat iterates through JSONArray items.java.lang.ObjectgetValue()Gets the JsonArray instance.java.util.Iterator<JsonValueBase>iterator()Returns an iterator over elements of typeT.booleanremove(JsonValue item)Removes JSONValue item from array.booleanremove(JsonValueBase item)Removes JsonValueBase item from array.voidsetItem(int index, JsonValueBase value)Sets the value at the specified index of the JsonArray.java.lang.StringtoString()Returns JSONArray in string representation.-
Methods inherited from class com.alachisoft.ncache.runtime.JSON.JsonValueBase
getDataType, parse, toJson
-
-
-
-
Method Detail
-
getItem
public JsonValueBase getItem(int index)
Gets the item at the specified index for the JSON Arary.- Parameters:
index- Zero based index of the JsonArray.- Returns:
- JSON value on that index.
-
iterator
public java.util.Iterator<JsonValueBase> iterator()
Returns an iterator over elements of typeT.- Specified by:
iteratorin interfacejava.lang.Iterable<JsonValueBase>- Returns:
- An Iterator.
-
setItem
public void setItem(int index, JsonValueBase value) throws OperationFailedExceptionSets the value at the specified index of the JsonArray.- Parameters:
index- Zero based index of the JsonArray.value- The value that is to be set at the specified index.- Throws:
OperationFailedException
-
getCount
public int getCount()
Gets the number of items in the JsonArray.- Returns:
- The number of items.
-
getValue
public java.lang.Object getValue()
Gets the JsonArray instance.- Overrides:
getValuein classJsonValueBase- Returns:
- The JsonArray instance.
-
add
public void add(JsonValue item) throws OperationFailedException
Adds JSONValue item to array.- Parameters:
item- JSONValue to be added.- Throws:
OperationFailedException
-
add
public void add(JsonValueBase item) throws OperationFailedException
Adds JSONValueBase item to array.- Parameters:
item- JSONValueBase to be added.- Throws:
OperationFailedException
-
copyTo
public void copyTo(JsonValueBase[] array, int arrayIndex)
Copies items from provided array starting from a particular array index.- Parameters:
array- Array from which the items have to be copied.arrayIndex- Starting index of the array from which to start copying.
-
remove
public boolean remove(JsonValue item) throws OperationFailedException
Removes JSONValue item from array.- Parameters:
item- Item to be removed.- Returns:
- True, if item exists and is removed successfully.
- Throws:
OperationFailedException
-
remove
public boolean remove(JsonValueBase item) throws OperationFailedException
Removes JsonValueBase item from array.- Parameters:
item- Item to be removed.- Returns:
- True, if item exists and is removed successfully.
- Throws:
OperationFailedException
-
contains
public boolean contains(JsonValue item) throws OperationFailedException
Checks if a JSONValue item exists in array.- Parameters:
item- Item to be found.- Returns:
- True, if exists.
- Throws:
OperationFailedException
-
contains
public boolean contains(JsonValueBase item) throws OperationFailedException
Checks if a JsonValueBase item exists in array.- Parameters:
item- Item to be found.- Returns:
- True, if exists.
- Throws:
OperationFailedException
-
clear
public void clear()
Clears all array items and brings count to 0.
-
getIterator
public java.util.Iterator<JsonValueBase> getIterator()
Returns theIteratorthat iterates through JSONArray items.- Returns:
- The iterator instance.
-
equals
public boolean equals(java.lang.Object obj)
Checks if an obj is equal to this instance of JSONArray.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The object that is compared with this object.- Returns:
- True, if the specified object is equal to this object otherwise, false.
-
toString
public java.lang.String toString()
Returns JSONArray in string representation.- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation of the json array.
-
-