Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonArray()
      Default constructor.
      JsonArray​(java.lang.String json)
      Overloaded constructor.
    • 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 JSONArray
      int 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 the Iterator 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 type T.
      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 java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • JsonArray

        public JsonArray()
        Default constructor.
      • JsonArray

        public JsonArray​(java.lang.String json)
        Overloaded constructor.
        Parameters:
        json - JSONArray object in string format.
    • 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 type T.
        Specified by:
        iterator in interface java.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 class JsonValueBase
        Returns:
        The json array instance.
      • getSize

        protected int getSize()
        Gets the size occupiied by json array.
        Overrides:
        getSize in class JsonValueBase
        Returns:
        The size of json array.
      • getInMemorySize

        protected int getInMemorySize()
        Gets the In-Memory size of the json array.
        Overrides:
        getInMemorySize in class JsonValueBase
        Returns:
        The In-Memory size of the json array.
      • 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.
      • clear

        public void clear()
        Clears all array items and brings count to 0.
      • getIterator

        public java.util.Iterator<JsonValueBase> getIterator()
        Returns the Iterator 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 class java.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 class java.lang.Object
        Returns:
        String representation of the json array.