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
,java.lang.Iterable<java.lang.String>
public final class MutableDictionary extends Dictionary implements MutableDictionaryInterface
Dictionary provides access to dictionary data.
-
-
Constructor Summary
Constructors Constructor Description MutableDictionary()
Initialize a new empty Dictionary object.MutableDictionary(java.lang.String json)
Creates a new MutableDictionary with content from the passed JSON string.MutableDictionary(java.util.Map<java.lang.String,java.lang.Object> data)
Creates a new MutableDictionary with content from the passed Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableArray
getArray(java.lang.String key)
Get a property's value as a Array, which is a mapping object of an array value.MutableDictionary
getDictionary(java.lang.String key)
Get a property's value as a Dictionary, which is a mapping object of an dictionary value.MutableDictionary
remove(java.lang.String key)
Removes the mapping for a key from this DictionaryMutableDictionary
setArray(java.lang.String key, Array value)
Set an Array object for the given key.MutableDictionary
setBlob(java.lang.String key, Blob value)
Set a Blob object for the given key.MutableDictionary
setBoolean(java.lang.String key, boolean value)
Set a boolean value for the given key.MutableDictionary
setData(java.util.Map<java.lang.String,java.lang.Object> data)
Populate a dictionary with content from a Map.MutableDictionary
setDate(java.lang.String key, java.util.Date value)
Set a Date object for the given key.MutableDictionary
setDictionary(java.lang.String key, Dictionary value)
Set a Dictionary object for the given key.MutableDictionary
setDouble(java.lang.String key, double value)
Set a double value for the given key.MutableDictionary
setFloat(java.lang.String key, float value)
Set a float value for the given key.MutableDictionary
setInt(java.lang.String key, int value)
Set an int value for the given key.MutableDictionary
setJSON(java.lang.String json)
Populate a dictionary with content from a JSON string.MutableDictionary
setLong(java.lang.String key, long value)
Set a long value for the given key.MutableDictionary
setNumber(java.lang.String key, java.lang.Number value)
Set a Number value for the given key.MutableDictionary
setString(java.lang.String key, java.lang.String value)
Set a String value for the given key.MutableDictionary
setValue(java.lang.String key, java.lang.Object value)
Set an object value by key.java.lang.String
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, iterator, toMap, toMutable, toString
-
-
-
-
Constructor Detail
-
MutableDictionary
public MutableDictionary()
Initialize a new empty Dictionary object.
-
MutableDictionary
public MutableDictionary(@NonNull java.util.Map<java.lang.String,java.lang.Object> data)
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
public MutableDictionary(@NonNull java.lang.String json)
Creates a new MutableDictionary with content from the passed JSON string.- Parameters:
json
- the dictionary content as a JSON string.
-
-
Method Detail
-
setData
@NonNull public MutableDictionary setData(@NonNull java.util.Map<java.lang.String,java.lang.Object> data)
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
@NonNull public MutableDictionary setJSON(@NonNull java.lang.String json)
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
@NonNull public MutableDictionary setValue(@NonNull java.lang.String key, @Nullable java.lang.Object value)
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
@NonNull public MutableDictionary setString(@NonNull java.lang.String key, @Nullable java.lang.String value)
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
@NonNull public MutableDictionary setNumber(@NonNull java.lang.String key, @Nullable java.lang.Number value)
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
@NonNull public MutableDictionary setInt(@NonNull java.lang.String key, int value)
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
@NonNull public MutableDictionary setLong(@NonNull java.lang.String key, long value)
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
@NonNull public MutableDictionary setFloat(@NonNull java.lang.String key, float value)
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
@NonNull public MutableDictionary setDouble(@NonNull java.lang.String key, double value)
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
@NonNull public MutableDictionary setBoolean(@NonNull java.lang.String key, boolean value)
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
@NonNull public MutableDictionary setBlob(@NonNull java.lang.String key, @NonNull Blob value)
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
@NonNull public MutableDictionary setDate(@NonNull java.lang.String key, @NonNull java.util.Date value)
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
@NonNull public MutableDictionary setArray(@NonNull java.lang.String key, @NonNull Array value)
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
@NonNull public MutableDictionary setDictionary(@NonNull java.lang.String key, @NonNull Dictionary value)
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
@NonNull public MutableDictionary remove(@NonNull java.lang.String key)
Removes the mapping for a key from this Dictionary- Specified by:
remove
in interfaceMutableDictionaryInterface
- Parameters:
key
- the key.- Returns:
- The self object.
-
getArray
@Nullable public MutableArray getArray(@NonNull java.lang.String key)
Get a property's value as a Array, which is a mapping object of an array value. 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
@Nullable public MutableDictionary getDictionary(@NonNull java.lang.String key)
Get a property's value as a Dictionary, which is a mapping object of an dictionary value. 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
@NonNull public java.lang.String toJSON()
- Specified by:
toJSON
in interfaceDictionaryInterface
- Overrides:
toJSON
in classDictionary
-
-