Package com.couchbase.lite
Class MutableArray
java.lang.Object
com.couchbase.lite.Array
com.couchbase.lite.MutableArray
- All Implemented Interfaces:
ArrayInterface
,com.couchbase.lite.internal.fleece.FLEncodable
,Iterable<Object>
Mutable access to array data.
-
Field Summary
Fields inherited from class com.couchbase.lite.Array
internalArray, lock
-
Constructor Summary
ConstructorDescriptionConstruct a new empty Array object.MutableArray
(String json) Creates a new MutableArray with content from the passed JSON string.MutableArray
(List<Object> data) Creates a new MutableArray with content from the passed List. -
Method Summary
Modifier and TypeMethodDescriptionAdds an Array object to the end of the array.Adds a Blob object to the end of the array.addBoolean
(boolean value) Adds a boolean value to the end of the array.Adds a Date object to the end of the array.addDictionary
(Dictionary value) Adds a Dictionary object to the end of the array.addDouble
(double value) Adds a double value to the end of the array.addFloat
(float value) Adds a float value to the end of the array.addInt
(int value) Adds an integer value to the end of the array.addLong
(long value) Adds a long value to the end of the array.Adds a Number object to the end of the array.Adds a String object to the end of the array.Adds an object to the end of the array.getArray
(int index) Gets a Array at the given index.getDictionary
(int index) Gets a Dictionary at the given index.insertArray
(int index, Array value) Inserts an Array object at the given index.insertBlob
(int index, Blob value) Inserts a Blob object at the given index.insertBoolean
(int index, boolean value) Inserts a boolean value at the given index.insertDate
(int index, Date value) Inserts a Date object at the given index.insertDictionary
(int index, Dictionary value) Inserts a Dictionary object at the given index.insertDouble
(int index, double value) Inserts a double value at the given index.insertFloat
(int index, float value) Inserts a float value at the given index.insertInt
(int index, int value) Inserts an integer value at the given index.insertLong
(int index, long value) Inserts a long value at the given index.insertNumber
(int index, Number value) Inserts a Number object at the given index.insertString
(int index, String value) Inserts a String object at the given index.insertValue
(int index, Object value) Inserts an object at the given index.remove
(int index) Removes the object at the given index.Sets a Array object at the given index.Sets a Blob object at the given index.setBoolean
(int index, boolean value) Sets a boolean value at the given index.Populate an array with content from a Map.Sets a Date object at the given index.setDictionary
(int index, Dictionary value) Sets a Dictionary object at the given index.setDouble
(int index, double value) Sets a double value at the given index.setFloat
(int index, float value) Sets a float value at the given index.setInt
(int index, int value) Sets an integer value at the given index.Populate an array with content from a JSON string.setLong
(int index, long value) Sets an integer value at the given index.Sets an NSNumber object at the given index.Sets an String object at the given index.Set an object at the given index.toJSON()
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, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.couchbase.lite.ArrayInterface
count, getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getLong, getNumber, getString, getValue, toList
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MutableArray
public MutableArray()Construct a new empty Array object. -
MutableArray
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 array content list
-
MutableArray
Creates a new MutableArray with content from the passed JSON string.- Parameters:
json
- the array content as a JSON string.
-
-
Method Details
-
setData
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Adds an object to the end of the array.- Parameters:
value
- the object- Returns:
- The self object
-
addString
Adds a String object to the end of the array.- Parameters:
value
- the String object- Returns:
- The self object
-
addNumber
Adds a Number object to the end of the array.- Parameters:
value
- the Number object- Returns:
- The self object
-
addInt
Adds an integer value to the end of the array.- Parameters:
value
- the int value- Returns:
- The self object
-
addLong
Adds a long value to the end of the array.- Parameters:
value
- the long value- Returns:
- The self object
-
addFloat
Adds a float value to the end of the array.- Parameters:
value
- the float value- Returns:
- The self object
-
addDouble
Adds a double value to the end of the array.- Parameters:
value
- the double value- Returns:
- The self object
-
addBoolean
Adds a boolean value to the end of the array.- Parameters:
value
- the boolean value- Returns:
- The self object
-
addBlob
Adds a Blob object to the end of the array.- Parameters:
value
- the Blob object- Returns:
- The self object
-
addDate
Adds a Date object to the end of the array.- Parameters:
value
- the Date object- Returns:
- The self object
-
addArray
Adds an Array object to the end of the array.- Parameters:
value
- the Array object- Returns:
- The self object
-
addDictionary
Adds a Dictionary object to the end of the array.- Parameters:
value
- the Dictionary object- Returns:
- The self object
-
insertValue
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
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
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
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
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
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
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
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
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
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
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
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
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
Gets a Array at the given index. Return null if the value is not an array.- Specified by:
getArray
in interfaceArrayInterface
- Overrides:
getArray
in classArray
- Parameters:
index
- the index. This value must not exceed the bounds of the array.- Returns:
- the Array object.
-
getDictionary
Gets a Dictionary at the given index. Return null if the value is not an dictionary.- Specified by:
getDictionary
in interfaceArrayInterface
- Overrides:
getDictionary
in classArray
- Parameters:
index
- the index. This value must not exceed the bounds of the array.- Returns:
- the Dictionary object.
-
toJSON
- Specified by:
toJSON
in interfaceArrayInterface
- Overrides:
toJSON
in classArray
-