Java Code Examples for com.google.gwt.core.client.JsonUtils#safeEval()

The following examples show how to use com.google.gwt.core.client.JsonUtils#safeEval() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gwtbootstrap3-extras   File: SliderBase.java    License: Apache License 2.0 6 votes vote down vote up
private List<Double> getNumberArrayAttribute(SliderOption option, List<Double> defaultValue) {

        // Get array attribute
        JsArrayNumber array = null;
        if (isAttached()) {
            array = getNumberArrayAttribute(getElement(), option.getName());
        } else {
            String value = attributeMixin.getAttribute(option.getDataAttribute());
            if (value != null && !value.isEmpty()) {
                array = JsonUtils.safeEval(value);
            }
        }

        // Attribute not set
        if (array == null) {
            return defaultValue;
        }

        // Put array to list
        List<Double> list = new ArrayList<Double>(array.length());
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
        return list;
    }
 
Example 2
Source Project: gwtbootstrap3-extras   File: SliderBase.java    License: Apache License 2.0 6 votes vote down vote up
private List<String> getStringArrayAttribute(SliderOption option, List<String> defaultValue) {

        // Get array attribute
        JsArrayString array = null;
        if (isAttached()) {
            array = getStringArrayAttribute(getElement(), option.getName());
        } else {
            String value = attributeMixin.getAttribute(option.getDataAttribute());
            if (value != null && !value.isEmpty()) {
                array = JsonUtils.safeEval(value);
            }
        }

        // Attribute not set
        if (array == null) {
            return defaultValue;
        }

        // Put array to list
        List<String> list = new ArrayList<String>(array.length());
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
        return list;
    }
 
Example 3
Source Project: swellrt   File: WebModelFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object parseJsonObject(String json) {
  if (json != null)
    return JsonUtils.<JavaScriptObject> safeEval(json);

  return null;
}
 
Example 4
@Override
protected OperationError parseServiceError(String json) {
  return (OperationError) JsonUtils.safeEval(json);
}
 
Example 5
Source Project: requestor   File: OverlaySerdes.java    License: Apache License 2.0 4 votes vote down vote up
protected <T extends JavaScriptObject> T eval(String response) {
    return USE_SAFE_EVAL ? JsonUtils.<T>safeEval(response) : JsonUtils.<T>unsafeEval(response);
}
 
Example 6
Source Project: gwtbootstrap3-extras   File: Range.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Converts the given string to a range instance.<br>
 * <br>
 * Useful when using UiBinder.
 *
 * @param value
 * @return
 */
public static Range fromString(String value) {
    if (value == null || value.isEmpty())
        return null;
    JsArrayNumber array = JsonUtils.safeEval(value);
    return new Range(array);
}
 
Example 7
Source Project: requestor   File: JsonObjectSerdes.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Performs evaluation of serialized response obeying the #useSafeEval configuration.
 * <p/>
 *
 * If #useSafeEval is {@code true} then the eval is performed using {@link JsonUtils#safeEval},
 * otherwise then content will be loosely evaluated by {@link JsonUtils#unsafeEval}.
 *
 * @param response The serialized content
 *
 * @return The converted JavaScriptObject
 */
protected JavaScriptObject eval(String response) {
    return useSafeEval() ? JsonUtils.safeEval(response) : JsonUtils.unsafeEval(response);
}