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 exits in array.boolean
contains(JsonValueBase item)
Checks if a JsonValueBase item exits 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 JSONArrayint
getCount()
Gets the number of items in the json array.protected int
getInMemorySize()
Gets the In-Memory size of the json array.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.protected int
getSize()
Gets the size occupiied by json array.java.lang.Object
getValue()
Gets the json array 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 json array.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 json array.- 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 json array.- Parameters:
index
- Zero based index of the json array.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 json array.- Returns:
- The number of items.
-
getValue
public java.lang.Object getValue()
Gets the json array instance.- Overrides:
getValue
in classJsonValueBase
- Returns:
- The json array instance.
-
getSize
protected int getSize()
Gets the size occupiied by json array.- Overrides:
getSize
in classJsonValueBase
- Returns:
- The size of json array.
-
getInMemorySize
protected int getInMemorySize()
Gets the In-Memory size of the json array.- Overrides:
getInMemorySize
in classJsonValueBase
- Returns:
- The In-Memory size of the json array.
-
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 exits in array.- Parameters:
item
- Item to be found.- Returns:
- True if exits.
- Throws:
OperationFailedException
-
contains
public boolean contains(JsonValueBase item) throws OperationFailedException
Checks if a JsonValueBase item exits in array.- Parameters:
item
- Item to be found.- Returns:
- True if exits.
- 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.
-
-