Ejemplo n.º 1
0
  /**
   * 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;
    }
  }
Ejemplo n.º 2
0
  /**
   * 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;
    }
  }
Ejemplo n.º 3
0
 /**
  * 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;
   }
 }
Ejemplo n.º 4
0
  /**
   * 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;
    }
  }
Ejemplo n.º 5
0
  /**
   * 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;
    }
  }
Ejemplo n.º 6
0
  /**
   * 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;
    }
  }
Ejemplo n.º 7
0
  /**
   * 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;
    }
  }
Ejemplo n.º 8
0
  /**
   * 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;
    }
  }
Ejemplo n.º 9
0
  /**
   * 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;
    }
  }
Ejemplo n.º 10
0
  /**
   * 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;
    }
  }
Ejemplo n.º 11
0
  /**
   * 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;
    }
  }
Ejemplo n.º 12
0
  /**
   * 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;
    }
  }
Ejemplo n.º 13
0
  /**
   * 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;
    }
  }
Ejemplo n.º 14
0
  /**
   * 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;
    }
  }
Ejemplo n.º 15
0
  /**
   * 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;
    }
  }
Ejemplo n.º 16
0
 void typeWarning(String key, Object value, String className, ClassCastException e) {
   typeWarning(key, value, className, "<null>", e);
 }