Class AttributeMap
-
- All Implemented Interfaces:
public final class AttributeMap
A map containing the attributes to set on a device.
-
-
Constructor Summary
Constructors Constructor Description AttributeMap(JSONObject jsonAttributes)
Constructs a new map containing the values described in a JSONObject. AttributeMap()
-
Method Summary
Modifier and Type Method Description final Unit
putString(String key, String value)
Inserts a String value into this map, replacing any existing value for the given key. final String
getString(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putBoolean(String key, Boolean value)
Inserts a boolean value into this map, replacing any existing value for the given key. final Boolean
getBoolean(String key, Boolean defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. final Unit
putFloat(String key, Float value)
Inserts a float value into this map, replacing any existing value for the given key. final Float
getFloat(String key, Float defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. final Unit
putInt(String key, Integer value)
Inserts an int value into this map, replacing any existing value for the given key. final Integer
getInt(String key, Integer defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. final Unit
putDate(String key, Date value)
Inserts a Date value into this map, replacing any existing value for the given key. final Date
getDate(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putStringArray(String key, ArrayList<String> array)
Inserts a String array value into this map, replacing any existing value for the given key. final ArrayList<String>
getStringArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putDateArray(String key, ArrayList<Date> array)
Inserts a Date array value into this map, replacing any existing value for the given key. final ArrayList<Date>
getDateArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putIntArray(String key, ArrayList<Integer> array)
Inserts a int array value into this map, replacing any existing value for the given key. final ArrayList<Integer>
getIntArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putFloatArray(String key, ArrayList<Float> array)
Inserts a float array value into this map, replacing any existing value for the given key. final ArrayList<Float>
getFloatArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
putBooleanArray(String key, ArrayList<Boolean> array)
Inserts a boolean array value into this map, replacing any existing value for the given key. final ArrayList<Boolean>
getBooleanArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. final Unit
setMergeRules(MergeRules mergeRule)
Set the merge rules for the attributes in this map when they are saved to the device. final MergeRules
getMergeRules()
Returns the merge rules for this set of attributes. final Unit
clear()
Removes all elements from this map. final Unit
remove(String key)
Removes any entry with the given key from this map. final Boolean
containsKey(String key)
Returns true if the given key is contained in the map. final Object
get(String key)
Returns the entry with the given key as an object. final Boolean
isEmpty()
Test if mapping is empty. final Set<String>
keySet()
Returns a Set containing the Strings used as keys in this map. final Integer
size()
Returns the number of mappings contained in this map. -
-
Constructor Detail
-
AttributeMap
AttributeMap(JSONObject jsonAttributes)
Constructs a new map containing the values described in a JSONObject.- Parameters:
jsonAttributes
- a JSON Object containing attributes to populate the map with
-
AttributeMap
AttributeMap()
-
-
Method Detail
-
putString
final Unit putString(String key, String value)
Inserts a String value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyvalue
- a String
-
getString
final String getString(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a String, or null
-
putBoolean
final Unit putBoolean(String key, Boolean value)
Inserts a boolean value into this map, replacing any existing value for the given key.
- Parameters:
key
- a String keyvalue
- a boolean
-
getBoolean
final Boolean getBoolean(String key, Boolean defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
- Parameters:
key
- a String keydefaultValue
- Value to return if key does not exist- Returns:
a boolean, or defaultValue
-
putFloat
final Unit putFloat(String key, Float value)
Inserts a float value into this map, replacing any existing value for the given key.
- Parameters:
key
- a String keyvalue
- a float
-
getFloat
final Float getFloat(String key, Float defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
- Parameters:
key
- a String keydefaultValue
- Value to return if key does not exist- Returns:
a float value, or defaultValue
-
putInt
final Unit putInt(String key, Integer value)
Inserts an int value into this map, replacing any existing value for the given key.
- Parameters:
key
- a String keyvalue
- an int
-
getInt
final Integer getInt(String key, Integer defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
- Parameters:
key
- a String keydefaultValue
- Value to return if key does not exist- Returns:
an int, or defaultValue
-
putDate
final Unit putDate(String key, Date value)
Inserts a Date value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyvalue
- a Date, or null
-
getDate
final Date getDate(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a Date, or null
-
putStringArray
final Unit putStringArray(String key, ArrayList<String> array)
Inserts a String array value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyarray
- a String ArrayList
-
getStringArray
final ArrayList<String> getStringArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a String ArrayList, or null
-
putDateArray
final Unit putDateArray(String key, ArrayList<Date> array)
Inserts a Date array value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyarray
- a Date ArrayList
-
getDateArray
final ArrayList<Date> getDateArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a Date ArrayList, or null
-
putIntArray
final Unit putIntArray(String key, ArrayList<Integer> array)
Inserts a int array value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyarray
- an integer ArrayList
-
getIntArray
final ArrayList<Integer> getIntArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
an int ArrayList, or null
-
putFloatArray
final Unit putFloatArray(String key, ArrayList<Float> array)
Inserts a float array value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyarray
- a float ArrayList
-
getFloatArray
final ArrayList<Float> getFloatArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a float ArrayList, or null
-
putBooleanArray
final Unit putBooleanArray(String key, ArrayList<Boolean> array)
Inserts a boolean array value into this map, replacing any existing value for the given key. Value may be null.
- Parameters:
key
- a String keyarray
- a boolean ArrayList
-
getBooleanArray
final ArrayList<Boolean> getBooleanArray(String key)
Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.
- Parameters:
key
- a String key- Returns:
a boolean ArrayList, or null
-
setMergeRules
final Unit setMergeRules(MergeRules mergeRule)
Set the merge rules for the attributes in this map when they are saved to the device.
- Parameters:
mergeRule
- MergeRules for the map
-
getMergeRules
final MergeRules getMergeRules()
Returns the merge rules for this set of attributes.
- Returns:
MergeRules for the map
-
remove
final Unit remove(String key)
Removes any entry with the given key from this map.
- Parameters:
key
- a String key
-
containsKey
final Boolean containsKey(String key)
Returns true if the given key is contained in the map.
- Parameters:
key
- a String key- Returns:
true if the key is part of the mapping, false otherwise
-
get
final Object get(String key)
Returns the entry with the given key as an object.
- Parameters:
key
- a String key- Returns:
an Object, or null
-
isEmpty
final Boolean isEmpty()
Test if mapping is empty.
- Returns:
true if the map is empty, false otherwise
-
keySet
final Set<String> keySet()
Returns a Set containing the Strings used as keys in this map.
- Returns:
a Set of String keys
-
-
-
-