/** * 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 */ public CharSequence getCharSequence(String key) { final Object o = mMap.get(key); try { return (CharSequence) o; } catch (ClassCastException e) { typeWarning(key, o, "CharSequence", e); return null; } }
/** * 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 */ public String getString(String key) { final Object o = mMap.get(key); try { return (String) o; } catch (ClassCastException e) { typeWarning(key, o, "String", e); return null; } }
/** * 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<String> value, or null */ public ArrayList<Integer> getIntegerArrayList(String key) { 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; } }
/** * 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 */ public long[] getLongArray(String key) { Object o = mMap.get(key); if (o == null) { return null; } try { return (long[]) o; } catch (ClassCastException e) { typeWarning(key, o, "long[]", e); return null; } }
/** * 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 */ public boolean[] getBooleanArray(String key) { Object o = mMap.get(key); if (o == null) { return null; } try { return (boolean[]) o; } catch (ClassCastException e) { typeWarning(key, o, "byte[]", e); return null; } }
/** * 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<CharSequence> value, or null */ public ArrayList<CharSequence> getCharSequenceArrayList(String key) { 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; } }
/** * 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 */ public double getDouble(String key, double defaultValue) { 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; } }
/** * 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 */ public long getLong(String key, long defaultValue) { 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; } }
/** * 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 */ public float getFloat(String key, float defaultValue) { 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; } }
/** * 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 */ public short getShort(String key, short defaultValue) { 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; } }
/** * 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 */ public int getInt(String key, int defaultValue) { 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; } }
/** * 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 */ public char getChar(String key, char defaultValue) { 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; } }
/** * 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 */ public Byte getByte(String key, byte defaultValue) { 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; } }
/** * 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 */ public boolean getBoolean(String key, boolean defaultValue) { 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; } }
/** * 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 */ public CharSequence[] getCharSequenceArray(String key) { Object o = mMap.get(key); if (o == null) { return null; } try { return (CharSequence[]) o; } catch (ClassCastException e) { typeWarning(key, o, "CharSequence[]", e); return null; } }
void typeWarning(String key, Object value, String className, ClassCastException e) { typeWarning(key, value, className, "<null>", e); }