Package android.os
Class BaseBundle
- java.lang.Object
-
- android.os.BaseBundle
-
- Direct Known Subclasses:
Bundle,PersistableBundle
public class BaseBundle extends Object
A mapping from String values to various types.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all elements from the mapping of this Bundle.booleancontainsKey(String key)Returns true if the given key is contained in the mapping of this Bundle.Objectget(String key)Returns the entry with the given key as an object.doublegetDouble(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.doublegetDouble(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.double[]getDoubleArray(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.intgetInt(String key)Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.intgetInt(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.int[]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.longgetLong(String key)Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.longgetLong(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.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.StringgetPairValue()TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization.StringgetString(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.StringgetString(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 or if a null value is explicitly associated with the given key.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.booleanisEmpty()Returns true if the mapping of this Bundle is empty, false otherwise.booleanisParcelled()Set<String>keySet()Returns a Set containing the Strings used as keys in this Bundle.voidputAll(PersistableBundle bundle)Inserts all mappings from the given PersistableBundle into this BaseBundle.voidputDouble(String key, double value)Inserts a double value into the mapping of this Bundle, replacing any existing value for the given key.voidputDoubleArray(String key, double[] value)Inserts a double array value into the mapping of this Bundle, replacing any existing value for the given key.voidputInt(String key, int value)Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.voidputIntArray(String key, int[] value)Inserts an int array value into the mapping of this Bundle, replacing any existing value for the given key.voidputLong(String key, long value)Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.voidputLongArray(String key, long[] value)Inserts a long array value into the mapping of this Bundle, replacing any existing value for the given key.voidputString(String key, String value)Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key.voidputStringArray(String key, String[] value)Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key.voidremove(String key)Removes any entry with the given key from the mapping of this Bundle.intsize()Returns the number of mappings contained in this Bundle.
-
-
-
Method Detail
-
getPairValue
public String getPairValue()
TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization. Note: value in single-pair Bundle may be null.
-
isParcelled
public boolean isParcelled()
-
size
public int size()
Returns the number of mappings contained in this Bundle.- Returns:
- the number of mappings as an int.
-
isEmpty
public boolean isEmpty()
Returns true if the mapping of this Bundle is empty, false otherwise.
-
clear
public void clear()
Removes all elements from the mapping of this Bundle.
-
containsKey
public boolean containsKey(String key)
Returns true if the given key is contained in the mapping of this Bundle.- Parameters:
key- a String key- Returns:
- true if the key is part of the mapping, false otherwise
-
get
public Object get(String key)
Returns the entry with the given key as an object.- Parameters:
key- a String key- Returns:
- an Object, or null
-
remove
public void remove(String key)
Removes any entry with the given key from the mapping of this Bundle.- Parameters:
key- a String key
-
putAll
public void putAll(PersistableBundle bundle)
Inserts all mappings from the given PersistableBundle into this BaseBundle.- Parameters:
bundle- a PersistableBundle
-
keySet
public Set<String> keySet()
Returns a Set containing the Strings used as keys in this Bundle.- Returns:
- a Set of String keys
-
putInt
public void putInt(String key, int value)
Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.- Parameters:
key- a String, or nullvalue- an int
-
putLong
public void putLong(String key, long value)
Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.- Parameters:
key- a String, or nullvalue- a long
-
putDouble
public void putDouble(String key, double value)
Inserts a double value into the mapping of this Bundle, replacing any existing value for the given key.- Parameters:
key- a String, or nullvalue- a double
-
putString
public void putString(String key, String value)
Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- a String, or null
-
putIntArray
public void putIntArray(String key, int[] value)
Inserts an int array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- an int array object, or null
-
putLongArray
public void putLongArray(String key, long[] value)
Inserts a long array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- a long array object, or null
-
putDoubleArray
public void putDoubleArray(String key, double[] value)
Inserts a double array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- a double array object, or null
-
putStringArray
public void putStringArray(String key, String[] value)
Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.- Parameters:
key- a String, or nullvalue- a String array object, or null
-
getInt
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
-
getInt
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 StringdefaultValue- Value to return if key does not exist- Returns:
- an int value
-
getLong
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
-
getLong
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 StringdefaultValue- Value to return if key does not exist- Returns:
- a long value
-
getDouble
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
-
getDouble
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 StringdefaultValue- Value to return if key does not exist- Returns:
- a double value
-
getString
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
-
getString
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 or if a null value is explicitly associated with the given key.- Parameters:
key- a String, or nulldefaultValue- Value to return if key does not exist or if a null value is associated with the given key.- Returns:
- the String value associated with the given key, or defaultValue if no valid String object is currently mapped to that key.
-
getIntArray
public int[] 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, or null- Returns:
- an int[] value, or null
-
getLongArray
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
-
getDoubleArray
public double[] getDoubleArray(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 double[] value, or null
-
getStringArray
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
-
-