Package com.couchbase.lite
Class MutableDictionary
java.lang.Object
com.couchbase.lite.Dictionary
com.couchbase.lite.MutableDictionary
- All Implemented Interfaces:
DictionaryInterface
,com.couchbase.lite.internal.fleece.FLEncodable
,MutableDictionaryInterface
,Iterable<String>
Mutable access to dictionary data.
-
Field Summary
Fields inherited from class com.couchbase.lite.Dictionary
internalDict, lock
-
Constructor Summary
ConstructorDescriptionConstruct a new empty Dictionary object.MutableDictionary
(String json) Creates a new MutableDictionary with content from the passed JSON string.MutableDictionary
(Map<String, Object> data) Creates a new MutableDictionary with content from the passed Map. -
Method Summary
Modifier and TypeMethodDescriptionGet a property's value as a Array.getDictionary
(String key) Get a property's value as a Dictionary.Removes the mapping for a key from this DictionarySet an Array object for the given key.Set a Blob object for the given key.setBoolean
(String key, boolean value) Set a boolean value for the given key.Populate a dictionary with content from a Map.Set a Date object for the given key.setDictionary
(String key, Dictionary value) Set a Dictionary object for the given key.Set a double value for the given key.Set a float value for the given key.Set an int value for the given key.Populate a dictionary with content from a JSON string.Set a long value for the given key.Set a Number value for the given key.Set a String value for the given key.Set an object value by key.toJSON()
Methods inherited from class com.couchbase.lite.Dictionary
contains, count, encodeTo, equals, getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getKeys, getLong, getNumber, getString, getValue, hashCode, isEmpty, iterator, toMap, toMutable, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.couchbase.lite.DictionaryInterface
contains, count, getBlob, getBoolean, getDate, getDouble, getFloat, getInt, getKeys, getLong, getNumber, getString, getValue, toMap
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MutableDictionary
public MutableDictionary()Construct a new empty Dictionary object. -
MutableDictionary
Creates a new MutableDictionary with content from the passed 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.- Parameters:
data
- the dictionary content map.
-
MutableDictionary
Creates a new MutableDictionary with content from the passed JSON string.- Parameters:
json
- the dictionary content as a JSON string.
-
-
Method Details
-
setData
Populate a dictionary 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 dictionary content will replace the current data including any existing Array and Dictionary objects.- Specified by:
setData
in interfaceMutableDictionaryInterface
- Parameters:
data
- the dictionary object.- Returns:
- The self object.
-
setJSON
Populate a dictionary with content from a JSON string. Setting the dictionary content will replace the current data including any existing Array and Dictionary objects.- Specified by:
setJSON
in interfaceMutableDictionaryInterface
- Parameters:
json
- the dictionary object.- Returns:
- this Document instance
-
setValue
Set an object value by key. 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.- Specified by:
setValue
in interfaceMutableDictionaryInterface
- Parameters:
key
- the key.value
- the object value.- Returns:
- The self object.
-
setString
Set a String value for the given key.- Specified by:
setString
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The String value.- Returns:
- The self object.
-
setNumber
Set a Number value for the given key.- Specified by:
setNumber
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The number value.- Returns:
- The self object.
-
setInt
Set an int value for the given key.- Specified by:
setInt
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The int value.- Returns:
- The self object.
-
setLong
Set a long value for the given key.- Specified by:
setLong
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The long value.- Returns:
- The self object.
-
setFloat
Set a float value for the given key.- Specified by:
setFloat
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The float value.- Returns:
- The self object.
-
setDouble
Set a double value for the given key.- Specified by:
setDouble
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The double value.- Returns:
- The self object.
-
setBoolean
Set a boolean value for the given key.- Specified by:
setBoolean
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The boolean value.- Returns:
- The self object.
-
setBlob
Set a Blob object for the given key.- Specified by:
setBlob
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The Blob object.- Returns:
- The self object.
-
setDate
Set a Date object for the given key.- Specified by:
setDate
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The Date object.- Returns:
- The self object.
-
setArray
Set an Array object for the given key.- Specified by:
setArray
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The Array object.- Returns:
- The self object.
-
setDictionary
Set a Dictionary object for the given key.- Specified by:
setDictionary
in interfaceMutableDictionaryInterface
- Parameters:
key
- The keyvalue
- The Dictionary object.- Returns:
- The self object.
-
remove
Removes the mapping for a key from this Dictionary- Specified by:
remove
in interfaceMutableDictionaryInterface
- Parameters:
key
- the key.- Returns:
- The self object.
-
getArray
Get a property's value as a Array. Returns null if the property doesn't exists, or its value is not an array.- Specified by:
getArray
in interfaceDictionaryInterface
- Specified by:
getArray
in interfaceMutableDictionaryInterface
- Overrides:
getArray
in classDictionary
- Parameters:
key
- the key.- Returns:
- the Array object.
-
getDictionary
Get a property's value as a Dictionary. Returns null if the property doesn't exists, or its value is not an dictionary.- Specified by:
getDictionary
in interfaceDictionaryInterface
- Specified by:
getDictionary
in interfaceMutableDictionaryInterface
- Overrides:
getDictionary
in classDictionary
- Parameters:
key
- the key.- Returns:
- the Dictionary object or null if the key doesn't exist.
-
toJSON
- Specified by:
toJSON
in interfaceDictionaryInterface
- Overrides:
toJSON
in classDictionary
-