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

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

Introduction

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

Prototype

public double doubleValue() 

Source Link

Document

Gets the double value this JSONNumber represents.

Usage

From source file:com.google.debugging.sourcemap.SourceMapObject.java

License:Apache License

private static int getNumber(JSONValue value, int def) {
    if (value == null) {
        return def;
    }//from  www  .j  a  v a  2s.  co m
    JSONNumber number = value.isNumber();
    if (number == null) {
        return def;
    }
    return (int) number.doubleValue();
}

From source file:com.hiramchirino.restygwt.client.AbstractJsonEncoderDecoder.java

License:Apache License

static public double toDouble(JSONValue value) {
    JSONNumber number = value.isNumber();
    if (number == null) {
        throw new DecodingException("Expected a json number, but was given: " + value);
    }//from  w  w  w .  j  a  va  2  s  . co m
    return number.doubleValue();
}

From source file:com.isotrol.impe3.pms.gui.client.util.PmsUtil.java

License:Open Source License

/**
 * @param oProp properties json object//ww w. ja v  a  2 s  . co  m
 */
private void parseFrameColumns(JSONObject oProp) {
    JSONObject frames = oProp.get("frames").isObject();

    JSONArray frameArray = frames.get("frame").isArray();

    columnsTemplates = new ArrayList<List<Integer>>();
    for (int i = 0; i < frameArray.size(); i++) {
        JSONObject frame = frameArray.get(i).isObject();
        JSONArray columns = frame.get("column").isArray();
        List<Integer> widths = new ArrayList<Integer>();
        for (int j = 0; j < columns.size(); j++) {
            JSONObject column = columns.get(j).isObject();
            JSONNumber width = column.get("width").isNumber();
            GWT.log("Anchura columna: " + width.doubleValue());
            widths.add(Integer.valueOf((int) width.doubleValue()));
        }
        if (totalWidthIs100(widths)) {
            columnsTemplates.add(widths);
        } else {
            util.error(pmsMessages.msgErrorColumnsWidth());
            columnsTemplates = null;
            return;
        }
    }

}

From source file:com.jythonui.client.util.ParseJ.java

License:Apache License

private static ListOfRows toS(RowIndex rI, String s) {
    ListOfRows r = new ListOfRows();

    JSONObject jo = (JSONObject) JSONParser.parseStrict(s);
    JSONArray a = (JSONArray) jo.get(IConsts.JSONROWLIST);
    for (int i = 0; i < a.size(); i++) {
        RowContent ro = rI.constructRow();
        JSONObject val = (JSONObject) a.get(i);
        for (FieldItem fi : rI.getColList()) {
            JSONValue v = val.get(fi.getId());
            FieldValue vall = new FieldValue();
            if (v.isNull() == JSONNull.getInstance())
                vall.setValue(fi.getFieldType(), null, fi.getAfterDot());
            else//ww w .  j a va  2  s.  c  om
                switch (fi.getFieldType()) {
                case BOOLEAN:
                    JSONBoolean b = (JSONBoolean) v;
                    vall.setValue(b.booleanValue());
                    break;
                case DATE:
                    break;
                case BIGDECIMAL:
                    JSONNumber jn = (JSONNumber) v;
                    vall.setValue(new BigDecimal(jn.doubleValue()), fi.getAfterDot());
                    break;
                case INT:
                    JSONNumber ji = (JSONNumber) v;
                    vall.setValue(new Double(ji.doubleValue()).intValue());
                    break;
                case LONG:
                    JSONNumber jl = (JSONNumber) v;
                    vall.setValue(new Double(jl.doubleValue()).longValue());
                    break;
                default:
                    JSONString js = (JSONString) v;
                    vall.setValue(js.stringValue());
                    break;
                }
            rI.setRowField(ro, fi.getId(), vall);
        }
        r.addRow(ro);
    }

    return r;
}

From source file:com.kafecho.stweetmap.client.StweetMap.java

License:Apache License

private void updateLatLong(StatusMessage statusMessage, JSONObject json) {
    Set<String> keys = json.keySet();
    for (String key : keys) {
        JSONObject entry = (JSONObject) json.get(key);
        JSONObject geometry = (JSONObject) entry.get("geometry");
        JSONObject location = (JSONObject) geometry.get("location");
        String[] locationInfo = new String[2];
        locationInfo = location.keySet().toArray(locationInfo);
        for (String s : locationInfo) {
            GWT.log(s);/*from w ww . j  a  va  2s.  c o  m*/
        }

        if (locationInfo.length >= 2) {
            JSONNumber latitude = (JSONNumber) location.get(locationInfo[0]);
            JSONNumber longitude = (JSONNumber) location.get(locationInfo[1]);
            statusMessage.setLatLng(latitude.doubleValue(), longitude.doubleValue());
        }
    }
}

From source file:com.kk_electronic.kkportal.core.rpc.jsonformat.JsonDate.java

License:Open Source License

@Override
public Date fromJson(JSONValue jsonValue, List<Class<?>> subtypes, FrameEncoder<JSONValue> encoder)
        throws UnableToDeserialize {
    if (jsonValue.isNull() != null)
        return null;
    if (jsonValue.isNumber() == null)
        throw new UnableToDeserialize("Expected Json Number");
    JSONNumber o = jsonValue.isNumber();
    return new Date((long) (o.doubleValue()));
}

From source file:com.kk_electronic.kkportal.core.rpc.jsonformat.JsonDouble.java

License:Open Source License

@Override
public Double fromJson(JSONValue jsonValue, List<Class<?>> subtypes, FrameEncoder<JSONValue> encoder)
        throws UnableToDeserialize {
    JSONNumber number = jsonValue.isNumber();
    if (number == null)
        throw new UnableToDeserialize("Expected json number");
    return number.doubleValue();
}

From source file:com.kk_electronic.kkportal.core.rpc.jsonformat.JsonInteger.java

License:Open Source License

@Override
public Integer fromJson(JSONValue jsonValue, List<Class<?>> subtypes, FrameEncoder<JSONValue> encoder)
        throws UnableToDeserialize {
    JSONNumber number = jsonValue.isNumber();
    if (number == null)
        throw new UnableToDeserialize("Expected json number");
    return (int) number.doubleValue();
}

From source file:com.kk_electronic.kkportal.core.rpc.jsonformat.JsonLong.java

License:Open Source License

@Override
public Long fromJson(JSONValue jsonValue, List<Class<?>> subtypes, FrameEncoder<JSONValue> encoder)
        throws UnableToDeserialize {
    JSONNumber number = jsonValue.isNumber();
    if (number == null)
        throw new UnableToDeserialize("Expected json number");
    return (long) number.doubleValue();
}

From source file:com.mcherm.zithiacharsheet.client.model.JSONDeserializer.java

License:Apache License

protected void updateFromField(JSONObject parent, String fieldName, SettableIntValue settableIntValue) {
    JSONValue valueValue = notNull(parent.get(fieldName));
    JSONNumber valueNum = notNull(valueValue.isNumber());
    int valueInt = (int) valueNum.doubleValue();
    settableIntValue.setValue(valueInt);
}