Bug 730626 - Implement resetting. r=nalexander, a=blocking-fennec
This commit is contained in:
@@ -131,6 +131,30 @@ public class ExtendedJSONObject {
|
||||
return (String) this.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Integer if the value for this key is an Integer, Long, or String
|
||||
* that can be parsed as a base 10 Integer.
|
||||
* Passes through null.
|
||||
*
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
public Integer getIntegerSafely(String key) throws NumberFormatException {
|
||||
Object val = this.object.get(key);
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
if (val instanceof Integer) {
|
||||
return (Integer) val;
|
||||
}
|
||||
if (val instanceof Long) {
|
||||
return new Integer(((Long) val).intValue());
|
||||
}
|
||||
if (val instanceof String) {
|
||||
return Integer.parseInt((String) val, 10);
|
||||
}
|
||||
throw new NumberFormatException("Expecting Integer, got " + val.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a server timestamp value as milliseconds since epoch.
|
||||
* @param key
|
||||
|
||||
Reference in New Issue
Block a user