FileDocCategorySizeDatePackage
BaseBundle.javaAPI DocAndroid 5.1 API40770Thu Mar 12 22:22:10 GMT 2015android.os

BaseBundle

public class BaseBundle extends Object
A mapping from String values to various types.

Fields Summary
private static final String
TAG
static final boolean
DEBUG
static final int
BUNDLE_MAGIC
static final Parcel
EMPTY_PARCEL
android.util.ArrayMap
mMap
Parcel
mParcelledData
private ClassLoader
mClassLoader
The ClassLoader used when unparcelling data from mParcelledData.
Constructors Summary
BaseBundle(ClassLoader loader, int capacity)
Constructs a new, empty Bundle that uses a specific ClassLoader for instantiating Parcelable and Serializable objects.

param
loader An explicit ClassLoader to use when instantiating objects inside of the Bundle.
param
capacity Initial size of the ArrayMap.


                                              
        
        mMap = capacity > 0 ?
                new ArrayMap<String, Object>(capacity) : new ArrayMap<String, Object>();
        mClassLoader = loader == null ? getClass().getClassLoader() : loader;
    
BaseBundle()
Constructs a new, empty Bundle.

        this((ClassLoader) null, 0);
    
BaseBundle(Parcel parcelledData)
Constructs a Bundle whose data is stored as a Parcel. The data will be unparcelled on first contact, using the assigned ClassLoader.

param
parcelledData a Parcel containing a Bundle

        readFromParcelInner(parcelledData);
    
BaseBundle(Parcel parcelledData, int length)

        readFromParcelInner(parcelledData, length);
    
BaseBundle(ClassLoader loader)
Constructs a new, empty Bundle that uses a specific ClassLoader for instantiating Parcelable and Serializable objects.

param
loader An explicit ClassLoader to use when instantiating objects inside of the Bundle.

        this(loader, 0);
    
BaseBundle(int capacity)
Constructs a new, empty Bundle sized to hold the given number of elements. The Bundle will grow as needed.

param
capacity the initial capacity of the Bundle

        this((ClassLoader) null, capacity);
    
BaseBundle(BaseBundle b)
Constructs a Bundle containing a copy of the mappings from the given Bundle.

param
b a Bundle to be copied.

        if (b.mParcelledData != null) {
            if (b.mParcelledData == EMPTY_PARCEL) {
                mParcelledData = EMPTY_PARCEL;
            } else {
                mParcelledData = Parcel.obtain();
                mParcelledData.appendFrom(b.mParcelledData, 0, b.mParcelledData.dataSize());
                mParcelledData.setDataPosition(0);
            }
        } else {
            mParcelledData = null;
        }

        if (b.mMap != null) {
            mMap = new ArrayMap<String, Object>(b.mMap);
        } else {
            mMap = null;
        }

        mClassLoader = b.mClassLoader;
    
Methods Summary
public voidclear()
Removes all elements from the mapping of this Bundle.

        unparcel();
        mMap.clear();
    
public booleancontainsKey(java.lang.String key)
Returns true if the given key is contained in the mapping of this Bundle.

param
key a String key
return
true if the key is part of the mapping, false otherwise

        unparcel();
        return mMap.containsKey(key);
    
public java.lang.Objectget(java.lang.String key)
Returns the entry with the given key as an object.

param
key a String key
return
an Object, or null

        unparcel();
        return mMap.get(key);
    
public booleangetBoolean(java.lang.String key)
Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

param
key a String
return
a boolean value

        unparcel();
        if (DEBUG) Log.d(TAG, "Getting boolean in "
                + Integer.toHexString(System.identityHashCode(this)));
        return getBoolean(key, false);
    
public booleangetBoolean(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
a boolean value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Boolean) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Boolean", defaultValue, e);
            return defaultValue;
        }
    
public boolean[]getBooleanArray(java.lang.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.

param
key a String, or null
return
a boolean[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (boolean[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "byte[]", e);
            return null;
        }
    
bytegetByte(java.lang.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.

param
key a String
return
a byte value

        unparcel();
        return getByte(key, (byte) 0);
    
java.lang.BytegetByte(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
a byte value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Byte) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Byte", defaultValue, e);
            return defaultValue;
        }
    
byte[]getByteArray(java.lang.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.

param
key a String, or null
return
a byte[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (byte[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "byte[]", e);
            return null;
        }
    
chargetChar(java.lang.String key)
Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key.

param
key a String
return
a char value

        unparcel();
        return getChar(key, (char) 0);
    
chargetChar(java.lang.String key, char defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

param
key a String
param
defaultValue Value to return if key does not exist
return
a char value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Character) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Character", defaultValue, e);
            return defaultValue;
        }
    
char[]getCharArray(java.lang.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.

param
key a String, or null
return
a char[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (char[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "char[]", e);
            return null;
        }
    
java.lang.CharSequencegetCharSequence(java.lang.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.

param
key a String, or null
return
a CharSequence value, or null

        unparcel();
        final Object o = mMap.get(key);
        try {
            return (CharSequence) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "CharSequence", e);
            return null;
        }
    
java.lang.CharSequencegetCharSequence(java.lang.String key, java.lang.CharSequence 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.

param
key a String, or null
param
defaultValue Value to return if key does not exist or if a null value is associated with the given key.
return
the CharSequence value associated with the given key, or defaultValue if no valid CharSequence object is currently mapped to that key.

        final CharSequence cs = getCharSequence(key);
        return (cs == null) ? defaultValue : cs;
    
java.lang.CharSequence[]getCharSequenceArray(java.lang.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.

param
key a String, or null
return
a CharSequence[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (CharSequence[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "CharSequence[]", e);
            return null;
        }
    
java.util.ArrayListgetCharSequenceArrayList(java.lang.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.

param
key a String, or null
return
an ArrayList value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (ArrayList<CharSequence>) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "ArrayList<CharSequence>", e);
            return null;
        }
    
java.lang.ClassLoadergetClassLoader()
Return the ClassLoader currently associated with this Bundle.

        return mClassLoader;
    
public doublegetDouble(java.lang.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.

param
key a String
return
a double value

        unparcel();
        return getDouble(key, 0.0);
    
public doublegetDouble(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
a double value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Double) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Double", defaultValue, e);
            return defaultValue;
        }
    
public double[]getDoubleArray(java.lang.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.

param
key a String, or null
return
a double[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (double[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "double[]", e);
            return null;
        }
    
floatgetFloat(java.lang.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.

param
key a String
return
a float value

        unparcel();
        return getFloat(key, 0.0f);
    
floatgetFloat(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
a float value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Float) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Float", defaultValue, e);
            return defaultValue;
        }
    
float[]getFloatArray(java.lang.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.

param
key a String, or null
return
a float[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (float[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "float[]", e);
            return null;
        }
    
public intgetInt(java.lang.String key)
Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.

param
key a String
return
an int value

        unparcel();
        return getInt(key, 0);
    
public intgetInt(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
an int value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Integer) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Integer", defaultValue, e);
            return defaultValue;
        }
    
public int[]getIntArray(java.lang.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.

param
key a String, or null
return
an int[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (int[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "int[]", e);
            return null;
        }
    
java.util.ArrayListgetIntegerArrayList(java.lang.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.

param
key a String, or null
return
an ArrayList value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (ArrayList<Integer>) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "ArrayList<Integer>", e);
            return null;
        }
    
public longgetLong(java.lang.String key)
Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

param
key a String
return
a long value

        unparcel();
        return getLong(key, 0L);
    
public longgetLong(java.lang.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.

param
key a String
param
defaultValue Value to return if key does not exist
return
a long value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Long) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Long", defaultValue, e);
            return defaultValue;
        }
    
public long[]getLongArray(java.lang.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.

param
key a String, or null
return
a long[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (long[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "long[]", e);
            return null;
        }
    
public java.lang.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. Note: value in single-pair Bundle may be null.

hide

        unparcel();
        int size = mMap.size();
        if (size > 1) {
            Log.w(TAG, "getPairValue() used on Bundle with multiple pairs.");
        }
        if (size == 0) {
            return null;
        }
        Object o = mMap.valueAt(0);
        try {
            return (String) o;
        } catch (ClassCastException e) {
            typeWarning("getPairValue()", o, "String", e);
            return null;
        }
    
java.io.SerializablegetSerializable(java.lang.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.

param
key a String, or null
return
a Serializable value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (Serializable) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Serializable", e);
            return null;
        }
    
shortgetShort(java.lang.String key)
Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key.

param
key a String
return
a short value

        unparcel();
        return getShort(key, (short) 0);
    
shortgetShort(java.lang.String key, short defaultValue)
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

param
key a String
param
defaultValue Value to return if key does not exist
return
a short value

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return defaultValue;
        }
        try {
            return (Short) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "Short", defaultValue, e);
            return defaultValue;
        }
    
short[]getShortArray(java.lang.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.

param
key a String, or null
return
a short[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (short[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "short[]", e);
            return null;
        }
    
public java.lang.StringgetString(java.lang.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.

param
key a String, or null
return
a String value, or null

        unparcel();
        final Object o = mMap.get(key);
        try {
            return (String) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "String", e);
            return null;
        }
    
public java.lang.StringgetString(java.lang.String key, java.lang.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.

param
key a String, or null
param
defaultValue Value to return if key does not exist or if a null value is associated with the given key.
return
the String value associated with the given key, or defaultValue if no valid String object is currently mapped to that key.

        final String s = getString(key);
        return (s == null) ? defaultValue : s;
    
public java.lang.String[]getStringArray(java.lang.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.

param
key a String, or null
return
a String[] value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (String[]) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "String[]", e);
            return null;
        }
    
java.util.ArrayListgetStringArrayList(java.lang.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.

param
key a String, or null
return
an ArrayList value, or null

        unparcel();
        Object o = mMap.get(key);
        if (o == null) {
            return null;
        }
        try {
            return (ArrayList<String>) o;
        } catch (ClassCastException e) {
            typeWarning(key, o, "ArrayList<String>", e);
            return null;
        }
    
public booleanisEmpty()
Returns true if the mapping of this Bundle is empty, false otherwise.

        unparcel();
        return mMap.isEmpty();
    
public booleanisParcelled()

hide

        return mParcelledData != null;
    
public java.util.SetkeySet()
Returns a Set containing the Strings used as keys in this Bundle.

return
a Set of String keys

        unparcel();
        return mMap.keySet();
    
public voidputAll(PersistableBundle bundle)
Inserts all mappings from the given PersistableBundle into this BaseBundle.

param
bundle a PersistableBundle

        unparcel();
        bundle.unparcel();
        mMap.putAll(bundle.mMap);
    
voidputAll(java.util.Map map)
Inserts all mappings from the given Map into this BaseBundle.

param
map a Map

        unparcel();
        mMap.putAll(map);
    
public voidputBoolean(java.lang.String key, boolean value)
Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a Boolean, or null

        unparcel();
        mMap.put(key, value);
    
public voidputBooleanArray(java.lang.String key, boolean[] value)
Inserts a boolean array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a boolean array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputByte(java.lang.String key, byte value)
Inserts a byte value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a byte

        unparcel();
        mMap.put(key, value);
    
voidputByteArray(java.lang.String key, byte[] value)
Inserts a byte array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a byte array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputChar(java.lang.String key, char value)
Inserts a char value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a char, or null

        unparcel();
        mMap.put(key, value);
    
voidputCharArray(java.lang.String key, char[] value)
Inserts a char array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a char array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputCharSequence(java.lang.String key, java.lang.CharSequence value)
Inserts a CharSequence value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a CharSequence, or null

        unparcel();
        mMap.put(key, value);
    
voidputCharSequenceArray(java.lang.String key, java.lang.CharSequence[] value)
Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a CharSequence array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputCharSequenceArrayList(java.lang.String key, java.util.ArrayList value)
Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value an ArrayList object, or null

        unparcel();
        mMap.put(key, value);
    
public voidputDouble(java.lang.String key, double value)
Inserts a double value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a double

        unparcel();
        mMap.put(key, value);
    
public voidputDoubleArray(java.lang.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.

param
key a String, or null
param
value a double array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputFloat(java.lang.String key, float value)
Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a float

        unparcel();
        mMap.put(key, value);
    
voidputFloatArray(java.lang.String key, float[] value)
Inserts a float array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a float array object, or null

        unparcel();
        mMap.put(key, value);
    
public voidputInt(java.lang.String key, int value)
Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value an int, or null

        unparcel();
        mMap.put(key, value);
    
public voidputIntArray(java.lang.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.

param
key a String, or null
param
value an int array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputIntegerArrayList(java.lang.String key, java.util.ArrayList value)
Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value an ArrayList object, or null

        unparcel();
        mMap.put(key, value);
    
public voidputLong(java.lang.String key, long value)
Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a long

        unparcel();
        mMap.put(key, value);
    
public voidputLongArray(java.lang.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.

param
key a String, or null
param
value a long array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputSerializable(java.lang.String key, java.io.Serializable value)
Inserts a Serializable value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a Serializable object, or null

        unparcel();
        mMap.put(key, value);
    
voidputShort(java.lang.String key, short value)
Inserts a short value into the mapping of this Bundle, replacing any existing value for the given key.

param
key a String, or null
param
value a short

        unparcel();
        mMap.put(key, value);
    
voidputShortArray(java.lang.String key, short[] value)
Inserts a short array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value a short array object, or null

        unparcel();
        mMap.put(key, value);
    
public voidputString(java.lang.String key, java.lang.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.

param
key a String, or null
param
value a String, or null

        unparcel();
        mMap.put(key, value);
    
public voidputStringArray(java.lang.String key, java.lang.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.

param
key a String, or null
param
value a String array object, or null

        unparcel();
        mMap.put(key, value);
    
voidputStringArrayList(java.lang.String key, java.util.ArrayList value)
Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.

param
key a String, or null
param
value an ArrayList object, or null

        unparcel();
        mMap.put(key, value);
    
voidreadFromParcelInner(Parcel parcel)
Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection.

param
parcel The parcel to overwrite this bundle from.

        int length = parcel.readInt();
        if (length < 0) {
            throw new RuntimeException("Bad length in parcel: " + length);
        }
        readFromParcelInner(parcel, length);
    
private voidreadFromParcelInner(Parcel parcel, int length)

        if (length == 0) {
            // Empty Bundle or end of data.
            mParcelledData = EMPTY_PARCEL;
            return;
        }
        int magic = parcel.readInt();
        if (magic != BUNDLE_MAGIC) {
            //noinspection ThrowableInstanceNeverThrown
            throw new IllegalStateException("Bad magic number for Bundle: 0x"
                    + Integer.toHexString(magic));
        }

        // Advance within this Parcel
        int offset = parcel.dataPosition();
        parcel.setDataPosition(offset + length);

        Parcel p = Parcel.obtain();
        p.setDataPosition(0);
        p.appendFrom(parcel, offset, length);
        if (DEBUG) Log.d(TAG, "Retrieving "  + Integer.toHexString(System.identityHashCode(this))
                + ": " + length + " bundle bytes starting at " + offset);
        p.setDataPosition(0);

        mParcelledData = p;
    
public voidremove(java.lang.String key)
Removes any entry with the given key from the mapping of this Bundle.

param
key a String key

        unparcel();
        mMap.remove(key);
    
voidsetClassLoader(java.lang.ClassLoader loader)
Changes the ClassLoader this Bundle uses when instantiating objects.

param
loader An explicit ClassLoader to use when instantiating objects inside of the Bundle.

        mClassLoader = loader;
    
public intsize()
Returns the number of mappings contained in this Bundle.

return
the number of mappings as an int.

        unparcel();
        return mMap.size();
    
voidtypeWarning(java.lang.String key, java.lang.Object value, java.lang.String className, java.lang.Object defaultValue, java.lang.ClassCastException e)

        StringBuilder sb = new StringBuilder();
        sb.append("Key ");
        sb.append(key);
        sb.append(" expected ");
        sb.append(className);
        sb.append(" but value was a ");
        sb.append(value.getClass().getName());
        sb.append(".  The default value ");
        sb.append(defaultValue);
        sb.append(" was returned.");
        Log.w(TAG, sb.toString());
        Log.w(TAG, "Attempt to cast generated internal exception:", e);
    
voidtypeWarning(java.lang.String key, java.lang.Object value, java.lang.String className, java.lang.ClassCastException e)

        typeWarning(key, value, className, "<null>", e);
    
synchronized voidunparcel()
If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.

        if (mParcelledData == null) {
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                    + ": no parcelled data");
            return;
        }

        if (mParcelledData == EMPTY_PARCEL) {
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                    + ": empty");
            if (mMap == null) {
                mMap = new ArrayMap<String, Object>(1);
            } else {
                mMap.erase();
            }
            mParcelledData = null;
            return;
        }

        int N = mParcelledData.readInt();
        if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                + ": reading " + N + " maps");
        if (N < 0) {
            return;
        }
        if (mMap == null) {
            mMap = new ArrayMap<String, Object>(N);
        } else {
            mMap.erase();
            mMap.ensureCapacity(N);
        }
        mParcelledData.readArrayMapInternal(mMap, N, mClassLoader);
        mParcelledData.recycle();
        mParcelledData = null;
        if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                + " final map: " + mMap);
    
voidwriteToParcelInner(Parcel parcel, int flags)
Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.

param
parcel The parcel to copy this bundle to.

        if (mParcelledData != null) {
            if (mParcelledData == EMPTY_PARCEL) {
                parcel.writeInt(0);
            } else {
                int length = mParcelledData.dataSize();
                parcel.writeInt(length);
                parcel.writeInt(BUNDLE_MAGIC);
                parcel.appendFrom(mParcelledData, 0, length);
            }
        } else {
            // Special case for empty bundles.
            if (mMap == null || mMap.size() <= 0) {
                parcel.writeInt(0);
                return;
            }
            int lengthPos = parcel.dataPosition();
            parcel.writeInt(-1); // dummy, will hold length
            parcel.writeInt(BUNDLE_MAGIC);

            int startPos = parcel.dataPosition();
            parcel.writeArrayMapInternal(mMap);
            int endPos = parcel.dataPosition();

            // Backpatch length
            parcel.setDataPosition(lengthPos);
            int length = endPos - startPos;
            parcel.writeInt(length);
            parcel.setDataPosition(endPos);
        }