List of usage examples for com.google.gwt.json.client JSONValue isString
public JSONString isString()
From source file:ca.nanometrics.gflot.client.options.GridOptions.java
License:Open Source License
/** * @return the background color inside the grid area. The array can contains one color or two colors if it's a * gradient/*from w ww.j a v a 2s. c om*/ */ public String[] getBackgroundColor() { JSONValue value = get(BACKGROUND_COLOR_KEY); if (value == null) { return null; } JSONString str = value.isString(); if (null != str) { return new String[] { str.stringValue() }; } JSONObject obj = value.isObject(); if (null != obj) { JSONValue colors = obj.get(BACKGROUND_COLORS_KEY); JSONArray array = colors.isArray(); if (null != array) { return new String[] { array.get(0).isString().stringValue(), array.get(1).isString().stringValue() }; } } return null; }
From source file:ca.nanometrics.gflot.client.Series.java
License:Open Source License
/** * @return the color/*from w w w. j a v a2 s . c om*/ */ public String getColor() { JSONValue value = get(COLOR_KEY); if (value == null) { return null; } JSONString str = value.isString(); if (str != null) { return str.stringValue(); } return null; }
From source file:ca.nanometrics.gflot.client.Series.java
License:Open Source License
/** * @return the auto-generated color to select *//*from www. j a v a 2 s .com*/ public Integer getAutoGeneratedColor() { JSONValue value = get(COLOR_KEY); if (value == null) { return null; } JSONString str = value.isString(); if (str != null) { return null; } JSONNumber number = value.isNumber(); if (number != null) { return new Integer((int) number.doubleValue()); } return null; }
From source file:ca.nanometrics.gflot.client.Series.java
License:Open Source License
/** * Provides the identifier of another series which is used to fill the area * between these two series. If this identifier was given as a number that * doesn't appear as an id in the series, it is interpreted as the index in * the array instead (so fillBetween: 0 can also mean the first series). * Only for the fillbetween plugin!/*ww w . j ava2s .c o m*/ * * @return an identifier of another series (a string, integer or null). */ public Object getFillBetween() { JSONValue value = get(FILL_BETWEEN_KEY); if (value == null) { return null; } JSONString str = value.isString(); if (str != null) { return str.stringValue(); } JSONNumber number = value.isNumber(); if (number != null) { return new Integer((int) number.doubleValue()); } return null; }
From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java
License:Open Source License
protected String getString(int index) { JSONValue value = get(index); if (value == null) { return null; }//from w w w . jav a 2 s . c om JSONString str = value.isString(); return str == null ? null : str.stringValue(); }
From source file:ca.nanometrics.gflot.client.util.JSONObjectWrapper.java
License:Open Source License
protected String getString(String key) { JSONValue value = get(key); if (value == null) { return null; }// www. j a v a 2 s. c o m JSONString str = value.isString(); return str == null ? null : str.stringValue(); }
From source file:cc.kune.core.client.sitebar.search.MultivalueSuggestBox.java
License:GNU Affero Public License
/** * Retrieve Options (name-value pairs) that are suggested from the REST * endpoint/*from www. j a v a2 s.c o m*/ * * @param query * - the String search term * @param from * - the 0-based begin index int * @param to * - the end index inclusive int * @param callback * - the OptionQueryCallback to handle the response */ private void queryOptions(final String query, final int from, final int to, final OptionQueryCallback callback) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(mrestEndpointUrl + "?" + SearcherConstants.QUERY_PARAM + "=" + query + "&" + SearcherConstants.START_PARAM + "=" + from + "&" + SearcherConstants.LIMIT_PARAM + "=" + PAGE_SIZE)); // Set our headers builder.setHeader("Accept", "application/json; charset=utf-8"); // Fails on chrome // builder.setHeader("Accept-Charset", "UTF-8"); builder.setCallback(new RequestCallback() { @Override public void onError(final com.google.gwt.http.client.Request request, final Throwable exception) { callback.error(exception); } @Override public void onResponseReceived(final com.google.gwt.http.client.Request request, final Response response) { final JSONValue val = JSONParser.parse(response.getText()); final JSONObject obj = val.isObject(); final int totSize = (int) obj.get(OptionResultSet.TOTAL_SIZE).isNumber().doubleValue(); final OptionResultSet options = new OptionResultSet(totSize); final JSONArray optionsArray = obj.get(OptionResultSet.OPTIONS).isArray(); if (options.getTotalSize() > 0 && optionsArray != null) { for (int i = 0; i < optionsArray.size(); i++) { if (optionsArray.get(i) == null) { /* * This happens when a JSON array has an invalid trailing comma */ continue; } final JSONObject jsonOpt = optionsArray.get(i).isObject(); final Option option = new Option(); final String longName = jsonOpt.get(OptionResultSet.DISPLAY_NAME).isString().stringValue(); final String shortName = jsonOpt.get(OptionResultSet.VALUE).isString().stringValue(); final JSONValue groupTypeJsonValue = jsonOpt.get("groupType"); final String prefix = groupTypeJsonValue.isString() == null ? "" : GroupType.PERSONAL.name().equals(groupTypeJsonValue.isString().stringValue()) ? I18n.t("User") + ": " : I18n.t("Group") + ": "; option.setName(prefix + (!longName.equals(shortName) ? longName + " (" + shortName + ")" : shortName)); option.setValue(jsonOpt.get(OptionResultSet.VALUE).isString().stringValue()); options.addOption(option); } } callback.success(options); } }); try { if (lastQuery != null && lastQuery.isPending()) { lastQuery.cancel(); } lastQuery = builder.send(); } catch (final RequestException e) { updateFormFeedback(FormFeedback.ERROR, "Error: " + e.getMessage()); } }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from www . j av a 2s . co m*/ 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//from w ww . jav a 2 s . c om 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// w ww . ja va 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(); }