Example usage for com.google.gwt.json.client JSONNumber JSONNumber

List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONNumber JSONNumber.

Prototype

public JSONNumber(double value) 

Source Link

Document

Creates a new JSONNumber from the double value.

Usage

From source file:amdb.client.slider.RangeSlider.java

License:Apache License

/**
 * A convenient way to create an options JSONObject for the RangeSlider.
 * @param min - default minimum of the slider
 * @param max - default maximum of the slider
 * @param defaultMin - the default value of the lowest anchor
 * @param defaultMax - the default value of the highest anchor
 * @return a JSONObject of RangeSlider options
 *//*from   w w  w .j av  a2s  .  c  o m*/
public static JSONObject getOptions(int min, int max, int defaultMin, int defaultMax) {
    JSONObject options = Slider.getOptions(min, max, new int[] { defaultMin, defaultMax });
    options.put(SliderOption.RANGE.toString(), JSONBoolean.getInstance(true));
    options.put(SliderOption.STEP.toString(), new JSONNumber(1));
    return options;
}

From source file:amdb.client.slider.Slider.java

License:Apache License

/**
 * A convenient way to create an options JSONObject.  Use SliderOption for keys.
 * @param min - default minimum of the slider
 * @param max - default maximum of the slider
 * @param defaultValues - default points of each anchor
 * @return a JSONObject of Slider options
 *//*from   w w w .ja  va2  s  . c o m*/
public static JSONObject getOptions(int min, int max, int[] defaultValues) {
    JSONObject options = new JSONObject();
    options.put(SliderOption.MIN.toString(), new JSONNumber(min));
    options.put(SliderOption.MAX.toString(), new JSONNumber(max));
    JSONArray vals = intArrayToJSONArray(defaultValues);
    options.put(SliderOption.VALUES.toString(), vals);
    return options;
}

From source file:amdb.client.slider.Slider.java

License:Apache License

private static JSONArray intArrayToJSONArray(int[] values) {
    JSONArray vals = new JSONArray();
    for (int i = 0, len = values.length; i < len; i++) {
        vals.set(i, new JSONNumber(values[i]));
    }//from ww  w  . j  a v a 2 s  . c om
    return vals;
}

From source file:annis.gui.widgets.gwt.client.ui.JITConf.java

License:Apache License

public void setProperty(String key, Integer value) {
    this.put(key, new JSONNumber(value));
}

From source file:br.com.pegasus.solutions.smartgwt.lib.client.view.impl.advanced.bar.infra.ExportUtil.java

License:Apache License

public static String getDataAsJson(ListGrid listGrid) {
    JSONObject jsonObj = new JSONObject();

    ListGridRecord[] records = listGrid.getRecords();
    for (int i = 0; i < records.length; i++) {
        ListGridRecord listGridRecord = records[i];
        ListGridField[] listGridFields = listGrid.getFields();
        JSONObject json = new JSONObject();

        for (int j = 0; j < listGridFields.length; j++) {
            ListGridField listGridField = listGridFields[j];
            String name = listGridField.getName();
            if (name.contains(FIELD_NAME_CLASS_SEPARATOR)) {
                name = name.split(FIELD_NAME_CLASS_SEPARATOR)[0];
            }//w  ww .  ja v  a 2  s  .  c  o  m

            String value = listGridRecord.getAttribute(listGridField.getName());
            if (value != null) {
                try {
                    BigInteger number = new BigInteger(value);
                    json.put(name, new JSONNumber(number.intValue()));
                } catch (Exception e) {
                    try {
                        BigDecimal decimal = new BigDecimal(value);
                        decimal.setScale(2, RoundingMode.HALF_UP);
                        json.put(name, new JSONNumber(decimal.doubleValue()));
                    } catch (Exception e2) {
                        json.put(name, new JSONString(value));
                    }
                }
            } else {
                json.put(name, new JSONString(""));
            }
        }

        jsonObj.put("jsonRecord" + (i + 1), json);
    }

    return jsonObj.toString();
}

From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java

License:Open Source License

protected void set(int index, Number value) {
    JSONValue val = JSONNull.getInstance();
    if (value != null) {
        val = new JSONNumber(value.doubleValue());
    }//from w ww. j ava2  s. c  o m
    set(index, val);
}

From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java

License:Open Source License

protected void push(Number value) {
    JSONValue val = JSONNull.getInstance();
    if (value != null) {
        val = new JSONNumber(value.doubleValue());
    }/*w w  w  . ja v a  2 s. co  m*/
    set(++currentIndex, val);
}

From source file:ca.nanometrics.gflot.client.util.JSONObjectWrapper.java

License:Open Source License

protected void put(String key, Number value) {
    JSONValue val = JSONNull.getInstance();
    if (value != null) {
        val = new JSONNumber(value.doubleValue());
    }//from  ww w.  j a v  a  2s. c  o m
    jsonObj.put(key, val);
}

From source file:ca.upei.ic.timetable.client.Service.java

License:Apache License

public void askCourseDetail(int courseId, RequestCallback callback) {
    JSONObject object = new JSONObject();
    object.put("id", new JSONNumber(courseId));
    currentCourseDetailRequest_ = remote_.post("get_course_detail", "application/json", object.toString(),
            callback);//from ww w . j a v a  2s.c om
}

From source file:ccc.client.gwt.core.GWTJson.java

License:Open Source License

/** {@inheritDoc} */
@Override//w w  w.  j  a  v  a 2 s.  c o m
public void set(final String key, final Date date) {
    _delegate.put(key, (null == date) ? JSONNull.getInstance() : new JSONNumber(date.getTime()));
}