Class MutableArray

  • All Implemented Interfaces:
    com.couchbase.lite.internal.fleece.FLEncodable, java.lang.Iterable<java.lang.Object>

    public final class MutableArray
    extends Array
    MutableArray provides access to array data. This class and its constructor are referenced by name, from native code.
    • Constructor Detail

      • MutableArray

        public MutableArray()
        Constructs a new empty Array object.
      • MutableArray

        public MutableArray​(@NonNull
                            java.util.List<java.lang.Object> data)
        Creates a new MutableArray with content from the passed List. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types.
        Parameters:
        data - the document content list
      • MutableArray

        public MutableArray​(@NonNull
                            java.lang.String json)
        Creates a new MutableArray with content from the passed JSON string.
        Parameters:
        json - the array content as a JSON string.
    • Method Detail

      • setData

        @NonNull
        public MutableArray setData​(@NonNull
                                    java.util.List<java.lang.Object> data)
        Populate an array with content from a Map. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. Setting the array content will replace the current data including any existing Array and Dictionary objects.
        Parameters:
        data - the array
        Returns:
        The self object
      • setJSON

        @NonNull
        public MutableArray setJSON​(@NonNull
                                    java.lang.String json)
        Populate an array with content from a JSON string. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. Setting the array content will replace the current data including any existing Array and Dictionary objects.
        Parameters:
        json - the dictionary object.
        Returns:
        this Document instance
      • setValue

        @NonNull
        public MutableArray setValue​(int index,
                                     @Nullable
                                     java.lang.Object value)
        Set an object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the object
        Returns:
        The self object
      • setString

        @NonNull
        public MutableArray setString​(int index,
                                      @Nullable
                                      java.lang.String value)
        Sets an String object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the String object
        Returns:
        The self object
      • setNumber

        @NonNull
        public MutableArray setNumber​(int index,
                                      @Nullable
                                      java.lang.Number value)
        Sets an NSNumber object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Number object
        Returns:
        The self object
      • setInt

        @NonNull
        public MutableArray setInt​(int index,
                                   int value)
        Sets an integer value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the int value
        Returns:
        The self object
      • setLong

        @NonNull
        public MutableArray setLong​(int index,
                                    long value)
        Sets an integer value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the long value
        Returns:
        The self object
      • setFloat

        @NonNull
        public MutableArray setFloat​(int index,
                                     float value)
        Sets a float value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the float value
        Returns:
        The self object
      • setDouble

        @NonNull
        public MutableArray setDouble​(int index,
                                      double value)
        Sets a double value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the double value
        Returns:
        The self object
      • setBoolean

        @NonNull
        public MutableArray setBoolean​(int index,
                                       boolean value)
        Sets a boolean value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the boolean value
        Returns:
        The self object
      • setBlob

        @NonNull
        public MutableArray setBlob​(int index,
                                    @Nullable
                                    Blob value)
        Sets a Blob object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Blob object
        Returns:
        The self object
      • setDate

        @NonNull
        public MutableArray setDate​(int index,
                                    @Nullable
                                    java.util.Date value)
        Sets a Date object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Date object
        Returns:
        The self object
      • setArray

        @NonNull
        public MutableArray setArray​(int index,
                                     @Nullable
                                     Array value)
        Sets a Array object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Array object
        Returns:
        The self object
      • setDictionary

        @NonNull
        public MutableArray setDictionary​(int index,
                                          @Nullable
                                          Dictionary value)
        Sets a Dictionary object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Dictionary object
        Returns:
        The self object
      • addValue

        @NonNull
        public MutableArray addValue​(@Nullable
                                     java.lang.Object value)
        Adds an object to the end of the array.
        Parameters:
        value - the object
        Returns:
        The self object
      • addString

        @NonNull
        public MutableArray addString​(@Nullable
                                      java.lang.String value)
        Adds a String object to the end of the array.
        Parameters:
        value - the String object
        Returns:
        The self object
      • addNumber

        @NonNull
        public MutableArray addNumber​(@Nullable
                                      java.lang.Number value)
        Adds a Number object to the end of the array.
        Parameters:
        value - the Number object
        Returns:
        The self object
      • addInt

        @NonNull
        public MutableArray addInt​(int value)
        Adds an integer value to the end of the array.
        Parameters:
        value - the int value
        Returns:
        The self object
      • addLong

        @NonNull
        public MutableArray addLong​(long value)
        Adds a long value to the end of the array.
        Parameters:
        value - the long value
        Returns:
        The self object
      • addFloat

        @NonNull
        public MutableArray addFloat​(float value)
        Adds a float value to the end of the array.
        Parameters:
        value - the float value
        Returns:
        The self object
      • addDouble

        @NonNull
        public MutableArray addDouble​(double value)
        Adds a double value to the end of the array.
        Parameters:
        value - the double value
        Returns:
        The self object
      • addBoolean

        @NonNull
        public MutableArray addBoolean​(boolean value)
        Adds a boolean value to the end of the array.
        Parameters:
        value - the boolean value
        Returns:
        The self object
      • addBlob

        @NonNull
        public MutableArray addBlob​(@Nullable
                                    Blob value)
        Adds a Blob object to the end of the array.
        Parameters:
        value - the Blob object
        Returns:
        The self object
      • addDate

        @NonNull
        public MutableArray addDate​(@Nullable
                                    java.util.Date value)
        Adds a Date object to the end of the array.
        Parameters:
        value - the Date object
        Returns:
        The self object
      • addArray

        @NonNull
        public MutableArray addArray​(@Nullable
                                     Array value)
        Adds an Array object to the end of the array.
        Parameters:
        value - the Array object
        Returns:
        The self object
      • addDictionary

        @NonNull
        public MutableArray addDictionary​(@Nullable
                                          Dictionary value)
        Adds a Dictionary object to the end of the array.
        Parameters:
        value - the Dictionary object
        Returns:
        The self object
      • insertValue

        @NonNull
        public MutableArray insertValue​(int index,
                                        @Nullable
                                        java.lang.Object value)
        Inserts an object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the object
        Returns:
        The self object
      • insertString

        @NonNull
        public MutableArray insertString​(int index,
                                         @Nullable
                                         java.lang.String value)
        Inserts a String object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the String object
        Returns:
        The self object
      • insertNumber

        @NonNull
        public MutableArray insertNumber​(int index,
                                         @Nullable
                                         java.lang.Number value)
        Inserts a Number object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Number object
        Returns:
        The self object
      • insertInt

        @NonNull
        public MutableArray insertInt​(int index,
                                      int value)
        Inserts an integer value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the int value
        Returns:
        The self object
      • insertLong

        @NonNull
        public MutableArray insertLong​(int index,
                                       long value)
        Inserts a long value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the long value
        Returns:
        The self object
      • insertFloat

        @NonNull
        public MutableArray insertFloat​(int index,
                                        float value)
        Inserts a float value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the float value
        Returns:
        The self object
      • insertDouble

        @NonNull
        public MutableArray insertDouble​(int index,
                                         double value)
        Inserts a double value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the double value
        Returns:
        The self object
      • insertBoolean

        @NonNull
        public MutableArray insertBoolean​(int index,
                                          boolean value)
        Inserts a boolean value at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the boolean value
        Returns:
        The self object
      • insertBlob

        @NonNull
        public MutableArray insertBlob​(int index,
                                       @Nullable
                                       Blob value)
        Inserts a Blob object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Blob object
        Returns:
        The self object
      • insertDate

        @NonNull
        public MutableArray insertDate​(int index,
                                       @Nullable
                                       java.util.Date value)
        Inserts a Date object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Date object
        Returns:
        The self object
      • insertArray

        @NonNull
        public MutableArray insertArray​(int index,
                                        @Nullable
                                        Array value)
        Inserts an Array object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Array object
        Returns:
        The self object
      • insertDictionary

        @NonNull
        public MutableArray insertDictionary​(int index,
                                             @Nullable
                                             Dictionary value)
        Inserts a Dictionary object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        value - the Dictionary object
        Returns:
        The self object
      • remove

        @NonNull
        public MutableArray remove​(int index)
        Removes the object at the given index.
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        Returns:
        The self object
      • getArray

        @Nullable
        public MutableArray getArray​(int index)
        Gets a Array at the given index. Return null if the value is not an array.
        Overrides:
        getArray in class Array
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        Returns:
        the Array object.
      • toJSON

        @NonNull
        public java.lang.String toJSON()
        Overrides:
        toJSON in class Array
      • getDictionary

        @Nullable
        public MutableDictionary getDictionary​(int index)
        Gets a Dictionary at the given index. Return null if the value is not an dictionary.
        Overrides:
        getDictionary in class Array
        Parameters:
        index - the index. This value must not exceed the bounds of the array.
        Returns:
        the Dictionary object.
      • count

        public abstract int count()
      • getInt

        public abstract int getInt​(int index)
      • getLong

        public abstract long getLong​(int index)
      • getFloat

        public abstract float getFloat​(int index)
      • getDouble

        public abstract double getDouble​(int index)
      • getBoolean

        public abstract boolean getBoolean​(int index)
      • getNumber

        @Nullable
        public abstract java.lang.Number getNumber​(int index)
      • getString

        @Nullable
        public abstract java.lang.String getString​(int index)
      • getDate

        @Nullable
        public abstract java.util.Date getDate​(int index)
      • getBlob

        @Nullable
        public abstract Blob getBlob​(int index)
      • getValue

        @Nullable
        public abstract java.lang.Object getValue​(int index)
      • toList

        @NonNull
        public abstract java.util.List<java.lang.Object> toList()