Example usage for com.google.gwt.json.client JSONBoolean booleanValue

List of usage examples for com.google.gwt.json.client JSONBoolean booleanValue

Introduction

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

Prototype

public boolean booleanValue() 

Source Link

Document

Returns true if this is the instance representing "true", false otherwise.

Usage

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

License:Open Source License

protected Boolean getBoolean(String key) {
    JSONValue value = get(key);/*from w ww  .j a  v  a 2  s.co  m*/
    if (value == null) {
        return null;
    }
    JSONBoolean str = value.isBoolean();
    return str == null ? null : str.booleanValue();
}

From source file:com.data2semantics.yasgui.client.tab.results.input.JsonResults.java

License:Open Source License

private void storeBooleanResult(JSONObject queryResult) {
    JSONBoolean jsonBoolean = queryResult.get("boolean").isBoolean();
    if (jsonBoolean == null) {
        throw new SparqlParseException("Cannot format value as boolean");
    }/*from   ww w.  ja  v a 2s.co  m*/
    booleanResult = jsonBoolean.booleanValue();
}

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

License:Open Source License

private void parseOtherProperties(JSONObject oProp) {

    // External services visibility
    JSONObject extServices = oProp.get("externalservices").isObject();
    // portal user service
    JSONObject pus = extServices.get("portalusersservice").isObject();
    JSONBoolean pusVisible = pus.get("visible").isBoolean();
    portalUsersServiceVisible = pusVisible.booleanValue();
    // comments service
    JSONObject cs = extServices.get("commentsservice").isObject();
    JSONBoolean csVisible = cs.get("visible").isBoolean();
    commentsServiceVisible = csVisible.booleanValue();
    // nodes repository
    JSONObject nr = extServices.get("noderepository").isObject();
    JSONBoolean nrVisible = nr.get("visible").isBoolean();
    nodeRepositoryVisible = nrVisible.booleanValue();

    // Normal login
    JSONBoolean disableLoginProperty = oProp.get("disableLogin").isBoolean();
    disableLogin = disableLoginProperty.booleanValue();
}

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//from w  w  w  .j  ava 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.mcherm.zithiacharsheet.client.model.JSONDeserializer.java

License:Apache License

protected void updateFromField(JSONObject parent, String fieldName, SettableBooleanValue settableBooleanValue) {
    JSONValue valueValue = notNull(parent.get(fieldName));
    JSONBoolean valueBool = notNull(valueValue.isBoolean());
    settableBooleanValue.setValue(valueBool.booleanValue());
}

From source file:com.pathf.gwt.util.json.client.JSONWrapper.java

License:Apache License

/**
* Return the boolean value of the wrapped <code>JSONValue</code>.
*
* @return A <code>Boolean</code> object if the wrapped value is a <code>JSONBoolean</code>,
* <code>null</code> otherwise.
*//*from  ww  w  . j  a  v  a 2 s  . c o m*/
public Boolean booleanValue() {
    if (value == null) {
        return null;
    }
    JSONBoolean b = value.isBoolean();
    if (b == null) {
        return null;
    }
    return b.booleanValue(); // autoboxing
}

From source file:edu.nrao.dss.client.widget.explorers.PeriodExplorer.java

License:Open Source License

private void setScores(JSONObject json) {
    // ex: {"scores":[{"pid":8902, "score":5.7115545, "hscore" : {"Just":0},"moc":{"Nothing":null}}, ...]}
    int id, idInt;
    Float idFlt;//from   ww w  . j ava  2s  .  c o m
    String idStr;
    double cscore, sscore;
    BaseModelData bmd;
    JSONObject jsonScore = new JSONObject();

    JSONArray scores = new JSONArray();
    scores = json.get("scores").isArray();
    JSONBoolean jsonFresh = json.get("fresh").isBoolean();
    JSONString jsonForecast = json.get("forecast").isString();

    for (int i = 0; i < scores.size(); i++) {
        jsonScore = scores.get(i).isObject();
        // we need the id to know which row to update
        id = (int) jsonScore.get("pid").isNumber().doubleValue();
        // we'll always be update the current score
        cscore = jsonScore.get("score").isNumber().doubleValue();
        // go through each row in the Explorer until we find the period
        /// we want to update
        for (BaseModelData m : store.getModels()) {
            idStr = m.get("id").toString();
            idFlt = Float.parseFloat(idStr);
            idInt = idFlt.intValue();
            if (id == idInt) {
                // this is the period we wish to update            
                m.set("cscore", cscore);
                // now, see if we need to update the historical score
                if (jsonScore.get("hscore").isObject().containsKey("Just")) {
                    sscore = jsonScore.get("hscore").isObject().get("Just").isNumber().doubleValue();
                    //GWT.log("Setting sscore: " + Integer.toString(id) + " to " + Double.toString(sscore));
                    m.set("sscore", sscore);
                }
                // this finally gets the new values to appear for the user
                store.update(m);
            }
        }
    }

    sc.setPeriodExplorerHeading(jsonFresh.booleanValue(), jsonForecast.stringValue());
}

From source file:edu.ucsb.eucalyptus.admin.client.extensions.store.JSONUtil.java

License:Open Source License

static boolean asBoolean(JSONValue value, boolean defaultResult) {
    if (value != null) {
        JSONBoolean bool = value.isBoolean();
        if (bool != null) {
            return bool.booleanValue();
        }/*from w w  w  .  j  a  v a 2s  .  c  om*/
    }
    return defaultResult;
}

From source file:es.deusto.weblab.client.comm.CommonSerializerJSON.java

License:Open Source License

private JSONValue parseResult(String response) throws SerializationException, WebLabServerException {
    final JSONValue value;
    try {/*from  w  w w . jav  a2 s  .  com*/
        value = JSONParser.parseStrict(response);
    } catch (final IllegalArgumentException e) {
        throw new SerializationException("Invalid response: " + e.getMessage(), e);
    } catch (final JSONException e) {
        throw new SerializationException("Invalid response: " + e.getMessage(), e);
    }
    final JSONObject responseObject = value.isObject();
    if (responseObject == null)
        throw new SerializationException("Expecting an object as a response; found: " + response);

    final JSONValue isException = responseObject.get("is_exception");
    final JSONBoolean isExceptionB = isException.isBoolean();
    if (isExceptionB.booleanValue())
        this.throwException(responseObject);

    final JSONValue result = responseObject.get("result");
    if (result == null)
        throw new SerializationException("Expecting 'result'; not found");
    return result;
}

From source file:es.deusto.weblab.client.comm.CommonSerializerJSON.java

License:Open Source License

protected boolean json2boolean(JSONValue value) throws SerializationException {
    if (value == null)
        throw new SerializationException("Boolean expected, found null");
    final JSONBoolean jsonstring = value.isBoolean();
    if (jsonstring == null)
        throw new SerializationException("Boolean expected, found: " + value);
    return jsonstring.booleanValue();
}