Package com.couchbase.lite
Class MutableArray
java.lang.Object
com.couchbase.lite.internal.BaseJFleeceCollection
com.couchbase.lite.AbstractJFleeceCollection<com.couchbase.lite.internal.fleece.MArray>
com.couchbase.lite.Array
com.couchbase.lite.MutableArray
- All Implemented Interfaces:
ArrayInterface
,com.couchbase.lite.internal.fleece.FleeceEncodable
,com.couchbase.lite.internal.fleece.JSONEncodable
,JFleeceCollectionInterface
,MutableArrayInterface
,Iterable<Object>
Mutable access to array data.
-
Field Summary
Fields inherited from class com.couchbase.lite.AbstractJFleeceCollection
contents, lock
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new empty MutableArray.MutableArray
(String json) Creates a new MutableArray with content from the passed JSON string.MutableArray
(List<?> 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()
Encode an Array as a JSON stringMethods inherited from class com.couchbase.lite.Array
equals, getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getLong, getNumber, getString, getValue, getValue, hashCode, iterator, toList, toMutable, toString
Methods inherited from class com.couchbase.lite.AbstractJFleeceCollection
count, encodeTo, isEmpty, toJFleece, willMutate
Methods inherited from class com.couchbase.lite.internal.BaseJFleeceCollection
asArray, asBlob, asBoolean, asDictionary, asNumber, asString, asValue, toBoolean, toDouble, toDouble, toFloat, toFloat, toInteger, toInteger, toJFleeceCollection, toLong, toLong
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.couchbase.lite.ArrayInterface
getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getLong, getNumber, getString, getValue, getValue, toList
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.couchbase.lite.JFleeceCollectionInterface
count, isEmpty
-
Constructor Details
-
MutableArray
public MutableArray()Construct a new empty MutableArray. -
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.- Specified by:
setData
in interfaceMutableArrayInterface
- 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.- Specified by:
setJSON
in interfaceMutableArrayInterface
- Parameters:
json
- the dictionary object.- Returns:
- this Document instance
-
setValue
Set an object at the given index.- Specified by:
setValue
in interfaceMutableArrayInterface
- 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.- Specified by:
setString
in interfaceMutableArrayInterface
- 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.- Specified by:
setNumber
in interfaceMutableArrayInterface
- 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.- Specified by:
setInt
in interfaceMutableArrayInterface
- 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.- Specified by:
setLong
in interfaceMutableArrayInterface
- 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.- Specified by:
setFloat
in interfaceMutableArrayInterface
- 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.- Specified by:
setDouble
in interfaceMutableArrayInterface
- 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.- Specified by:
setBoolean
in interfaceMutableArrayInterface
- 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.- Specified by:
setBlob
in interfaceMutableArrayInterface
- 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.- Specified by:
setDate
in interfaceMutableArrayInterface
- 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.- Specified by:
setArray
in interfaceMutableArrayInterface
- 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.- Specified by:
setDictionary
in interfaceMutableArrayInterface
- 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.- Specified by:
addValue
in interfaceMutableArrayInterface
- Parameters:
value
- the object- Returns:
- The self object
-
addString
Adds a String object to the end of the array.- Specified by:
addString
in interfaceMutableArrayInterface
- Parameters:
value
- the String object- Returns:
- The self object
-
addNumber
Adds a Number object to the end of the array.- Specified by:
addNumber
in interfaceMutableArrayInterface
- Parameters:
value
- the Number object- Returns:
- The self object
-
addInt
Adds an integer value to the end of the array.- Specified by:
addInt
in interfaceMutableArrayInterface
- Parameters:
value
- the int value- Returns:
- The self object
-
addLong
Adds a long value to the end of the array.- Specified by:
addLong
in interfaceMutableArrayInterface
- Parameters:
value
- the long value- Returns:
- The self object
-
addFloat
Adds a float value to the end of the array.- Specified by:
addFloat
in interfaceMutableArrayInterface
- Parameters:
value
- the float value- Returns:
- The self object
-
addDouble
Adds a double value to the end of the array.- Specified by:
addDouble
in interfaceMutableArrayInterface
- Parameters:
value
- the double value- Returns:
- The self object
-
addBoolean
Adds a boolean value to the end of the array.- Specified by:
addBoolean
in interfaceMutableArrayInterface
- Parameters:
value
- the boolean value- Returns:
- The self object
-
addBlob
Adds a Blob object to the end of the array.- Specified by:
addBlob
in interfaceMutableArrayInterface
- Parameters:
value
- the Blob object- Returns:
- The self object
-
addDate
Adds a Date object to the end of the array.- Specified by:
addDate
in interfaceMutableArrayInterface
- Parameters:
value
- the Date object- Returns:
- The self object
-
addArray
Adds an Array object to the end of the array.- Specified by:
addArray
in interfaceMutableArrayInterface
- Parameters:
value
- the Array object- Returns:
- The self object
-
addDictionary
Adds a Dictionary object to the end of the array.- Specified by:
addDictionary
in interfaceMutableArrayInterface
- Parameters:
value
- the Dictionary object- Returns:
- The self object
-
insertValue
Inserts an object at the given index.- Specified by:
insertValue
in interfaceMutableArrayInterface
- 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.- Specified by:
insertString
in interfaceMutableArrayInterface
- 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.- Specified by:
insertNumber
in interfaceMutableArrayInterface
- 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.- Specified by:
insertInt
in interfaceMutableArrayInterface
- 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.- Specified by:
insertLong
in interfaceMutableArrayInterface
- 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.- Specified by:
insertFloat
in interfaceMutableArrayInterface
- 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.- Specified by:
insertDouble
in interfaceMutableArrayInterface
- 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.- Specified by:
insertBoolean
in interfaceMutableArrayInterface
- 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.- Specified by:
insertBlob
in interfaceMutableArrayInterface
- 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.- Specified by:
insertDate
in interfaceMutableArrayInterface
- 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.- Specified by:
insertArray
in interfaceMutableArrayInterface
- 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.- Specified by:
insertDictionary
in interfaceMutableArrayInterface
- 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.- Specified by:
remove
in interfaceMutableArrayInterface
- 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
- Specified by:
getArray
in interfaceMutableArrayInterface
- 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
- Specified by:
getDictionary
in interfaceMutableArrayInterface
- Overrides:
getDictionary
in classArray
- Parameters:
index
- the index. This value must not exceed the bounds of the array.- Returns:
- the Dictionary object.
-
toJSON
Description copied from class:AbstractJFleeceCollection
Encode an Array as a JSON string- Specified by:
toJSON
in interfacecom.couchbase.lite.internal.fleece.JSONEncodable
- Overrides:
toJSON
in classAbstractJFleeceCollection<com.couchbase.lite.internal.fleece.MArray>
- Returns:
- JSON encoded representation of the Array
-