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 void
add(JsonValue item)
Adds JSONValue item to array.void
add(JsonValueBase item)
Adds JSONValueBase item to array.void
clear()
Clears all array items and brings count to 0.boolean
contains(JsonValue item)
Checks if a JSONValue item exists in array.boolean
contains(JsonValueBase item)
Checks if a JsonValueBase item exists in array.void
copyTo(JsonValueBase[] array, int arrayIndex)
Copies items from provided array starting from a particular array index.boolean
equals(java.lang.Object obj)
Checks if an obj is equal to this instance of JSONArray.int
getCount()
Gets the number of items in the JsonArray.JsonValueBase
getItem(int index)
Gets the item at the specified index for the JSON Arary.java.util.Iterator<JsonValueBase>
getIterator()
Returns theIterator
that iterates through JSONArray items.java.lang.Object
getValue()
Gets the JsonArray instance.java.util.Iterator<JsonValueBase>
iterator()
Returns an iterator over elements of typeT
.boolean
remove(JsonValue item)
Removes JSONValue item from array.boolean
remove(JsonValueBase item)
Removes JsonValueBase item from array.void
setItem(int index, JsonValueBase value)
Sets the value at the specified index of the JsonArray.java.lang.String
toString()
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:
iterator
in interfacejava.lang.Iterable<JsonValueBase>
- Returns:
- An Iterator.
-
setItem
public void setItem(int index, JsonValueBase value) throws OperationFailedException
Sets 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:
getValue
in 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 theIterator
that 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:
equals
in 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:
toString
in classjava.lang.Object
- Returns:
- String representation of the json array.
-
-