public int getIntValue(String key) {
Object value = this.get(key);
return value == null ? 0 : TypeUtils.castToInt(value);
}
public Object get(Object key) {
return this.map.get(key);
}
public static final Integer castToInt(Object value) {
if (value == null) {
return null;
} else if (value instanceof Integer) {
return (Integer)value;
} else if (value instanceof Number) {
return ((Number)value).intValue();
} else if (value instanceof String) {
String strVal = (String)value;
if (strVal.length() == 0) {
return null;
} else if ("null".equals(strVal)) {
return null;
} else {
return !"null".equals(strVal) && !"NULL".equals(strVal) ? Integer.parseInt(strVal) : null;
}
} else {
throw new JSONException("can not cast to int, value : " + value);
}
}