Package com.couchbase.lite
Class MutableArray
- java.lang.Object
-
- com.couchbase.lite.Array
-
- com.couchbase.lite.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 Summary
Constructors Constructor Description MutableArray()Constructs a new empty Array object.MutableArray(java.lang.String json)Creates a new MutableArray with content from the passed JSON string.MutableArray(java.util.List<java.lang.Object> data)Creates a new MutableArray with content from the passed List.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MutableArrayaddArray(Array value)Adds an Array object to the end of the array.MutableArrayaddBlob(Blob value)Adds a Blob object to the end of the array.MutableArrayaddBoolean(boolean value)Adds a boolean value to the end of the array.MutableArrayaddDate(java.util.Date value)Adds a Date object to the end of the array.MutableArrayaddDictionary(Dictionary value)Adds a Dictionary object to the end of the array.MutableArrayaddDouble(double value)Adds a double value to the end of the array.MutableArrayaddFloat(float value)Adds a float value to the end of the array.MutableArrayaddInt(int value)Adds an integer value to the end of the array.MutableArrayaddLong(long value)Adds a long value to the end of the array.MutableArrayaddNumber(java.lang.Number value)Adds a Number object to the end of the array.MutableArrayaddString(java.lang.String value)Adds a String object to the end of the array.MutableArrayaddValue(java.lang.Object value)Adds an object to the end of the array.intcount()MutableArraygetArray(int index)Gets a Array at the given index.BlobgetBlob(int index)booleangetBoolean(int index)java.util.DategetDate(int index)MutableDictionarygetDictionary(int index)Gets a Dictionary at the given index.doublegetDouble(int index)floatgetFloat(int index)intgetInt(int index)longgetLong(int index)java.lang.NumbergetNumber(int index)java.lang.StringgetString(int index)java.lang.ObjectgetValue(int index)MutableArrayinsertArray(int index, Array value)Inserts an Array object at the given index.MutableArrayinsertBlob(int index, Blob value)Inserts a Blob object at the given index.MutableArrayinsertBoolean(int index, boolean value)Inserts a boolean value at the given index.MutableArrayinsertDate(int index, java.util.Date value)Inserts a Date object at the given index.MutableArrayinsertDictionary(int index, Dictionary value)Inserts a Dictionary object at the given index.MutableArrayinsertDouble(int index, double value)Inserts a double value at the given index.MutableArrayinsertFloat(int index, float value)Inserts a float value at the given index.MutableArrayinsertInt(int index, int value)Inserts an integer value at the given index.MutableArrayinsertLong(int index, long value)Inserts a long value at the given index.MutableArrayinsertNumber(int index, java.lang.Number value)Inserts a Number object at the given index.MutableArrayinsertString(int index, java.lang.String value)Inserts a String object at the given index.MutableArrayinsertValue(int index, java.lang.Object value)Inserts an object at the given index.MutableArrayremove(int index)Removes the object at the given index.MutableArraysetArray(int index, Array value)Sets a Array object at the given index.MutableArraysetBlob(int index, Blob value)Sets a Blob object at the given index.MutableArraysetBoolean(int index, boolean value)Sets a boolean value at the given index.MutableArraysetData(java.util.List<java.lang.Object> data)Populate an array with content from a Map.MutableArraysetDate(int index, java.util.Date value)Sets a Date object at the given index.MutableArraysetDictionary(int index, Dictionary value)Sets a Dictionary object at the given index.MutableArraysetDouble(int index, double value)Sets a double value at the given index.MutableArraysetFloat(int index, float value)Sets a float value at the given index.MutableArraysetInt(int index, int value)Sets an integer value at the given index.MutableArraysetJSON(java.lang.String json)Populate an array with content from a JSON string.MutableArraysetLong(int index, long value)Sets an integer value at the given index.MutableArraysetNumber(int index, java.lang.Number value)Sets an NSNumber object at the given index.MutableArraysetString(int index, java.lang.String value)Sets an String object at the given index.MutableArraysetValue(int index, java.lang.Object value)Set an object at the given index.java.lang.StringtoJSON()java.util.List<java.lang.Object>toList()-
Methods inherited from class com.couchbase.lite.Array
count, encodeTo, equals, getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getLong, getNumber, getString, getValue, hashCode, iterator, toList, toMutable
-
-
-
-
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.
-
getDictionary
@Nullable public MutableDictionary getDictionary(int index)
Gets a Dictionary at the given index. Return null if the value is not an dictionary.- Overrides:
getDictionaryin classArray- 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()
-
-