A map of data supported by PutDataMapRequest
and DataMapItem
s.
DataMap may convert to and from Bundles, but will drop any types not explicitly supported by DataMap in the conversion process.
Constant Summary
String | TAG |
Public Constructor Summary
DataMap()
|
Public Method Summary
static ArrayList<DataMap> |
arrayListFromBundleArrayList(ArrayList<Bundle>
bundleArrayList)
Returns an ArrayList of DataMaps from an ArrayList of Bundles.
|
void |
clear()
Removes all elements from the mapping of this DataMap.
|
boolean | |
boolean | |
static DataMap | |
static DataMap |
fromByteArray(byte[] bytes)
Returns a DataMap from a byte[].
|
<T> T | |
Asset | |
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.
|
boolean |
getBoolean(String key)
Returns the value associated with the given key, or false if no mapping of the
desired type exists for the given key.
|
byte | |
byte | |
byte[] |
getByteArray(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.
|
DataMap |
getDataMap(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.
|
ArrayList<DataMap> |
getDataMapArrayList(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.
|
double | |
double | |
float | |
float | |
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.
|
int | |
int | |
ArrayList<Integer> |
getIntegerArrayList(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.
|
long | |
long | |
long[] |
getLongArray(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.
|
String | |
String | |
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.
|
ArrayList<String> |
getStringArrayList(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.
|
int |
hashCode()
|
boolean |
isEmpty()
Returns true if the mapping of this DataMap is empty, false otherwise.
|
Set<String> |
keySet()
Returns a Set containing the Strings used as keys in this DataMap.
|
void | |
void | |
void |
putBoolean(String key, boolean
value)
Inserts a boolean value into the mapping of this DataMap, replacing any
existing value for the given key.
|
void | |
void |
putByteArray(String key, byte[]
value)
Inserts a byte array value into the mapping of this dataMap, replacing any
existing value for the given key.
|
void |
putDataMap(String key,
DataMap
value)
Inserts a DataMap into the mapping of this DataMap, replacing any existing
DataMap for the given key.
|
void |
putDataMapArrayList(String key,
ArrayList<DataMap>
value)
Inserts an ArrayList value into the mapping of this DataMap, replacing any
existing value for the given key.
|
void | |
void | |
void |
putFloatArray(String key, float[]
value)
Inserts a float array value into the mapping of this dataMap, replacing any
existing value for the given key.
|
void | |
void |
putIntegerArrayList(String key,
ArrayList<Integer>
value)
Inserts an ArrayList value into the mapping of this dataMap, replacing any
existing value for the given key.
|
void | |
void |
putLongArray(String key, long[]
value)
Inserts a long array value into the mapping of this dataMap, replacing any
existing value for the given key.
|
void | |
void |
putStringArray(String key,
String[]
value)
Inserts a String array value into the mapping of this dataMap, replacing any
existing value for the given key.
|
void |
putStringArrayList(String key,
ArrayList<String>
value)
Inserts an ArrayList value into the mapping of this dataMap, replacing any
existing value for the given key.
|
Object | |
int |
size()
Returns the number of key-value pairs in this map.
|
Bundle |
toBundle()
Returns a Bundle containing all the elements on this DataMap.
|
byte[] |
toByteArray()
Returns a serialized
byte[] representing this DataMap.
|
String |
toString()
|
Inherited Method Summary
Constants
public static final String TAG
Public Constructors
public DataMap ()
Public Methods
public static ArrayList<DataMap> arrayListFromBundleArrayList (ArrayList<Bundle> bundleArrayList)
Returns an ArrayList of DataMaps from an ArrayList of Bundles. Any elements in the Bundles not supported by DataMap will be dropped.
Returns
- an ArrayList of DataMaps
public void clear ()
Removes all elements from the mapping of this DataMap.
public boolean containsKey (String key)
Returns true if the given key is contained in the mapping of this DataMap.
Parameters
key | a String key |
---|
Returns
- true if the key is part of the mapping, false otherwise
public boolean equals (Object o)
Returns true if the given Object is a DataMap equivalent to this one.
public static DataMap fromBundle (Bundle bundle)
Returns a DataMap from a Bundle. The input Bundle is expected to contain only elements supported by DataMap. Any elements in the Bundle not supported by DataMap will be dropped.
Returns
- a DataMap from a Bundle object
public static DataMap fromByteArray (byte[] bytes)
Returns a DataMap from a byte[].
Parameters
bytes | the bytes of the DataMap to convert |
---|
Returns
- a new DataMap out of the input bytes
public T get (String key)
Returns the entry with the given key as an object.
Parameters
key | a String key |
---|
Returns
- an Object, or null
public Asset getAsset (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, or null |
---|
Returns
- an Asset, or null
public 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- a boolean value
public boolean getBoolean (String key)
Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- a boolean value
public byte getByte (String key)
Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- a byte value
public byte getByte (String key, byte 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- a byte value
public byte[] getByteArray (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, or null |
---|
Returns
- a byte[] value, or null
public DataMap getDataMap (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, or null |
---|
Returns
- a DataMap, or null
public ArrayList<DataMap> getDataMapArrayList (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, or null |
---|
Returns
- an ArrayList value, or null
public double getDouble (String key, double 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- a double value
public double getDouble (String key)
Returns the value associated with the given key, or 0.0 if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- a double value
public 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- a float value
public float getFloat (String key)
Returns the value associated with the given key, or 0.0f if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- a float value
public 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, or null |
---|
Returns
- a float[] value, or null
public int getInt (String key, int 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- an int value
public int getInt (String key)
Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- an int value
public ArrayList<Integer> getIntegerArrayList (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, or null |
---|
Returns
- an ArrayList value, or null
public long getLong (String key, long 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 |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- a long value
public long getLong (String key)
Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.
Parameters
key | a String |
---|
Returns
- a long value
public long[] getLongArray (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, or null |
---|
Returns
- a long[] value, or null
public 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, or null |
---|
Returns
- a String value, or null
public String getString (String key, String 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, or null |
---|---|
defaultValue | Value to return if key does not exist |
Returns
- the String value associated with the given key, or defaultValue if no valid String object is currently mapped to that key.
public 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, or null |
---|
Returns
- a String[] value, or null
public ArrayList<String> getStringArrayList (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, or null |
---|
Returns
- an ArrayList value, or null
public int hashCode ()
public boolean isEmpty ()
Returns true if the mapping of this DataMap is empty, false otherwise.
public Set<String> keySet ()
Returns a Set containing the Strings used as keys in this DataMap.
Returns
- a Set of String keys
public void putAll (DataMap dataMap)
Inserts all mappings from the given DataMap into this DataMap.
Parameters
dataMap | a DataMap |
---|
public void putAsset (String key, Asset value)
Inserts an Asset into the mapping of this DataMap, replacing any existing Asset for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | an Asset, or null |
public void putBoolean (String key, boolean value)
Inserts a boolean value into the mapping of this DataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | a boolean |
public void putByte (String key, byte value)
Inserts a byte value into the mapping of this DataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | a byte |
public void putByteArray (String key, byte[] value)
Inserts a byte array value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a byte array object, or null |
public void putDataMap (String key, DataMap value)
Inserts a DataMap into the mapping of this DataMap, replacing any existing DataMap for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a DataMap, or null |
public void putDataMapArrayList (String key, ArrayList<DataMap> value)
Inserts an ArrayList value into the mapping of this DataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | an ArrayList object, or null |
public void putDouble (String key, double value)
Inserts a double value into the mapping of this DataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | a double |
public void putFloat (String key, float value)
Inserts a float value into the mapping of this dataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | a float |
public void putFloatArray (String key, float[] value)
Inserts a float array value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a float array object, or null |
public void putInt (String key, int value)
Inserts an int value into the mapping of this DataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | an int |
public void putIntegerArrayList (String key, ArrayList<Integer> value)
Inserts an ArrayList value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | an ArrayList object, or null |
public void putLong (String key, long value)
Inserts a long value into the mapping of this DataMap, replacing any existing value for the given key.
Parameters
key | a String, or null |
---|---|
value | a long |
public void putLongArray (String key, long[] value)
Inserts a long array value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a long array object, or null |
public void putString (String key, String value)
Inserts a String value into the mapping of this DataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a String, or null |
public void putStringArray (String key, String[] value)
Inserts a String array value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | a String array object, or null |
public void putStringArrayList (String key, ArrayList<String> value)
Inserts an ArrayList value into the mapping of this dataMap, replacing any existing value for the given key. Either key or value may be null.
Parameters
key | a String, or null |
---|---|
value | an ArrayList object, or null |
public Object remove (String key)
Removes any entry with the given key from the mapping of this dataMap.
Parameters
key | a String key |
---|
public int size ()
Returns the number of key-value pairs in this map.
public Bundle toBundle ()
Returns a Bundle containing all the elements on this DataMap. A data map converted
in this way should only be read after converting it with
fromBundle(Bundle)
.
Returns
- a Bundle containing all supported elements on this DataMap.
public byte[] toByteArray ()
Returns a serialized byte[]
representing this DataMap.