List of usage examples for com.google.gwt.json.client JSONValue isNull
public JSONNull isNull()
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w ww .j a va 2s . com public Boolean getBool(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } return Boolean.valueOf(value.isBoolean().booleanValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override//w ww . j a va2 s . c o m public Date getDate(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } // TODO: Handle non integers return new Date((long) value.isNumber().doubleValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w.java 2 s .c om public BigDecimal getBigDecimal(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } return new BigDecimal(value.isString().stringValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/* www.jav a 2s . c o m*/ public UUID getId(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } return UUID.fromString(value.isString().stringValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override// ww w . j a va 2 s . c o m public Integer getInt(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } // TODO: Handle non integers; handle values larger than maxInt, etc. return Integer.valueOf((int) value.isNumber().doubleValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/* w w w. j a va 2 s . com*/ public Json getJson(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } return new GWTJson(value.isObject()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/*w ww . j av a 2 s . c o m*/ public String getString(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } return value.isString().stringValue(); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w .j a v a 2s . c om*/ public Collection<String> getStrings(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } final Collection<String> strings = new ArrayList<String>(); final JSONArray array = value.isArray(); for (int i = 0; i < array.size(); i++) { final JSONValue arrayElement = array.get(i); if (null != arrayElement.isNull()) { strings.add(null); } else { strings.add(arrayElement.isString().stringValue()); } } return strings; }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w . j a v a 2 s . c o m*/ public Long getLong(final String key) { final JSONValue value = _delegate.get(key); if (null == value) { throw new S11nException("Missing key: " + key); } else if (null != value.isNull()) { return null; } // TODO: Handle non integers; handle values larger than maxLong, etc. return Long.valueOf((long) value.isNumber().doubleValue()); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override//w w w . ja va 2 s.c o m public Map<String, String> getStringMap(final String key) { final Map<String, String> value = new HashMap<String, String>(); final JSONValue v = _delegate.get(key); if (null == v) { throw new S11nException("Missing key: " + key); } else if (null != v.isNull()) { return null; } final JSONObject o = v.isObject(); for (final String mapKey : o.keySet()) { final JSONValue mapValue = o.get(mapKey); if (null != mapValue.isNull()) { value.put(mapKey, null); } else { value.put(mapKey, mapValue.isString().stringValue()); } } return value; }