public class BaseBundle extends Object
Bundle
or
PersistableBundle
subclass.Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all elements from the mapping of this Bundle.
|
boolean |
containsKey(String key)
Returns true if the given key is contained in the mapping
of this Bundle.
|
Object |
get(String key)
Returns the entry with the given key as an object.
|
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.
|
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[] |
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 |
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.
|
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.
|
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.
|
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.
|
boolean |
isEmpty()
Returns true if the mapping of this Bundle is empty, false otherwise.
|
boolean |
isEmptyParcel() |
boolean |
isParcelled() |
Set<String> |
keySet()
Returns a Set containing the Strings used as keys in this Bundle.
|
void |
putAll(PersistableBundle bundle)
Inserts all mappings from the given PersistableBundle into this BaseBundle.
|
void |
putBoolean(String key,
boolean value)
Inserts a Boolean value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putBooleanArray(String key,
boolean[] value)
Inserts a boolean array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putDouble(String key,
double value)
Inserts a double value into the mapping of this Bundle, replacing
any existing value for the given key.
|
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.
|
void |
putInt(String key,
int value)
Inserts an int value into the mapping of this Bundle, replacing
any existing value for the given key.
|
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.
|
void |
putLong(String key,
long value)
Inserts a long value into the mapping of this Bundle, replacing
any existing value for the given key.
|
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.
|
void |
putString(String key,
String value)
Inserts a String value into the mapping of this Bundle, replacing
any existing value for the given key.
|
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.
|
void |
remove(String key)
Removes any entry with the given key from the mapping of this Bundle.
|
static void |
setShouldDefuse(boolean shouldDefuse)
Set global variable indicating that any Bundles parsed in this process
should be "defused."
|
int |
size()
Returns the number of mappings contained in this Bundle.
|
public static void setShouldDefuse(boolean shouldDefuse)
BadParcelableException
encountered will be suppressed and logged, leaving an empty Bundle
instead of crashing.public String getPairValue()
public boolean isParcelled()
public boolean isEmptyParcel()
public int size()
public boolean isEmpty()
public void clear()
public boolean containsKey(String key)
key
- a String keypublic Object get(String key)
key
- a String keypublic void remove(String key)
key
- a String keypublic void putAll(PersistableBundle bundle)
bundle
- a PersistableBundlepublic Set<String> keySet()
public void putBoolean(String key, boolean value)
key
- a String, or nullvalue
- a booleanpublic void putInt(String key, int value)
key
- a String, or nullvalue
- an intpublic void putLong(String key, long value)
key
- a String, or nullvalue
- a longpublic void putDouble(String key, double value)
key
- a String, or nullvalue
- a doublepublic void putString(String key, String value)
key
- a String, or nullvalue
- a String, or nullpublic void putBooleanArray(String key, boolean[] value)
key
- a String, or nullvalue
- a boolean array object, or nullpublic void putIntArray(String key, int[] value)
key
- a String, or nullvalue
- an int array object, or nullpublic void putLongArray(String key, long[] value)
key
- a String, or nullvalue
- a long array object, or nullpublic void putDoubleArray(String key, double[] value)
key
- a String, or nullvalue
- a double array object, or nullpublic void putStringArray(String key, String[] value)
key
- a String, or nullvalue
- a String array object, or nullpublic boolean getBoolean(String key)
key
- a Stringpublic boolean getBoolean(String key, boolean defaultValue)
key
- a StringdefaultValue
- Value to return if key does not existpublic int getInt(String key)
key
- a Stringpublic int getInt(String key, int defaultValue)
key
- a StringdefaultValue
- Value to return if key does not existpublic long getLong(String key)
key
- a Stringpublic long getLong(String key, long defaultValue)
key
- a StringdefaultValue
- Value to return if key does not existpublic double getDouble(String key)
key
- a Stringpublic double getDouble(String key, double defaultValue)
key
- a StringdefaultValue
- Value to return if key does not existpublic String getString(String key)
key
- a String, or nullpublic String getString(String key, String defaultValue)
key
- a String, or nulldefaultValue
- Value to return if key does not exist or if a null
value is associated with the given key.public boolean[] getBooleanArray(String key)
key
- a String, or nullpublic int[] getIntArray(String key)
key
- a String, or nullpublic long[] getLongArray(String key)
key
- a String, or nullpublic double[] getDoubleArray(String key)
key
- a String, or null