Class AttributeMap

  • All Implemented Interfaces:

    
    public final class AttributeMap
    
                        

    A map containing the attributes to set on a device.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      AttributeMap(JSONObject jsonAttributes) Constructs a new map containing the values described in a JSONObject.
      AttributeMap()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 key
        value - 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 key
        value - 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 key
        defaultValue - 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 key
        value - 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 key
        defaultValue - 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 key
        value - 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 key
        defaultValue - 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 key
        value - 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 key
        array - 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 key
        array - 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 key
        array - 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 key
        array - 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 key
        array - 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
      • clear

         final Unit clear()

        Removes all elements from this 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

      • size

         final Integer size()

        Returns the number of mappings contained in this map.

        Returns:

        the number of mappings as an int