List of usage examples for com.google.gwt.json.client JSONValue isBoolean
public JSONBoolean isBoolean()
From source file:fast.servicescreen.client.gui.RuleUtil.java
License:Open Source License
/** * Returns the String value of given JSONValue, or "" if * value was emtpy// www .j av a 2s . c o m * */ public static String getJSONValue_AsString(JSONValue jsonValue) { if (jsonValue != null) { //Define JSON valuetype. Get its sting value String nodeValue = ""; JSONBoolean attrBoolean = jsonValue.isBoolean(); JSONNumber attrNumber = jsonValue.isNumber(); JSONString attrString = jsonValue.isString(); if (attrBoolean != null) { nodeValue = "" + attrBoolean.booleanValue(); } else if (attrNumber != null) { nodeValue = "" + attrNumber.doubleValue(); } else if (attrString != null) { String stringValue = attrString.stringValue(); if (stringValue != null && !"".equals(stringValue.trim())) { nodeValue = "" + stringValue; } else { nodeValue = ""; } } return nodeValue; } return ""; }
From source file:fi.jyu.student.jatahama.onlineinquirytool.shared.Argument.java
License:Open Source License
public void fromJSONObject(JSONObject o) { if (o != null) { JSONValue val = o.get("argument"); JSONString js = null;/* w w w . j a v a 2 s . c om*/ argument = null; if (val != null) { js = val.isString(); if (js != null) { argument = js.stringValue(); } } val = o.get("sourceURL"); sourceURL = null; if (val != null) { js = val.isString(); if (js != null) { sourceURL = js.stringValue(); } } val = o.get("reliability"); reliability = null; if (val != null) { js = val.isString(); if (js != null) { String s = js.stringValue(); setIntReliabilityValue(Integer.parseInt(s)); } } val = o.get("reliabilityRationale"); reliabilityRationale = null; if (val != null) { js = val.isString(); if (js != null) { reliabilityRationale = js.stringValue(); } } val = o.get("counterArgument"); counterArgument = false; if (val != null) { JSONBoolean jb = val.isBoolean(); if (jb != null) { counterArgument = jb.booleanValue(); } } } }
From source file:fr.insalyon.creatis.vip.applicationimporter.client.JSONUtil.java
License:Open Source License
public static boolean getPropertyAsBoolean(JSONObject jo, String property) throws ApplicationImporterException { JSONValue value = jo.get(property); if (value == null) return false; if (value.isBoolean() == null) throw new ApplicationImporterException(value.toString() + " is not a boolean value!"); return value.isBoolean().booleanValue(); }
From source file:org.apache.solr.explorer.client.util.json.JSONUtils.java
License:Apache License
public static Boolean jsonValueToBoolean(JSONValue jsonValue) { JSONBoolean bool = jsonValue.isBoolean(); if (bool != null) { return bool.booleanValue(); }// www .ja v a2 s . com JSONString string = jsonValue.isString(); if (string != null) { return "true".equals(string.stringValue()) || "t".equals(string.stringValue()) || "yes".equals(string.stringValue()) || "y".equals(string.stringValue()); } throw new JSONException("Not a boolean: " + jsonValue); }
From source file:org.bonitasoft.web.toolkit.client.common.json.JSonUnserializerClient.java
License:Open Source License
private AbstractTreeNode<String> unserializeTreeNode(final JSONValue value) { if (value.isArray() != null) { return unserializeTreeNode(value.isArray()); } else if (value.isObject() != null) { return unserializeTreeNode(value.isObject()); } else if (value.isBoolean() != null) { return new TreeLeaf<String>(value.isBoolean().booleanValue() ? "1" : "0"); } else if (value.isNumber() != null) { return new TreeLeaf<String>(value.isNumber().toString()); } else if (value.isString() != null) { return new TreeLeaf<String>(value.isString().stringValue()); }/* w w w . ja v a2 s . c om*/ return null; }
From source file:org.eclipse.che.api.languageserver.util.EitherUtil.java
License:Open Source License
private static boolean matches(JSONValue element, JsonDecision decision) { if (decision == JsonDecision.LIST) { return element.isArray() != null; }//from w w w .j a va 2 s . co m if (decision == JsonDecision.BOOLEAN) { return element.isBoolean() != null; } if (decision == JsonDecision.NUMBER) { return element.isNumber() != null; } if (decision == JsonDecision.STRING) { return element.isString() != null; } return element.isObject() != null; }
From source file:org.eclipse.che.ide.editor.preferences.EditorPreferencesManager.java
License:Open Source License
public Boolean getBooleanValueFor(EditorProperties property) { JSONValue jsonValue = getJsonValueFor(property); if (jsonValue == null) { return null; }/*from w ww . j a v a2 s . com*/ JSONBoolean jsonBoolean = jsonValue.isBoolean(); if (jsonBoolean == null) { return null; } return jsonBoolean.booleanValue(); }
From source file:org.eclipse.che.ide.editor.preferences.editorproperties.property.EditorBooleanPropertyWidget.java
License:Open Source License
@Override public void setValue(JSONValue value) { if (value != null && value.isBoolean() != null) { propertyValueBox.setValue(value.isBoolean().booleanValue()); }/*from w ww .jav a 2 s . co m*/ }
From source file:org.eclipse.che.ide.editor.preferences.editorproperties.property.EditorPropertyWidgetFactory.java
License:Open Source License
/** * Creates one of implementations of {@link EditorPropertyWidget}. * * @return an instance of {@link EditorPropertyWidget} *///from w ww.jav a2s . c o m public EditorPropertyWidget create(@NotNull String propertyName, @NotNull JSONValue value) { if (value.isBoolean() != null) { return new EditorBooleanPropertyWidget(propertyName, value.isBoolean().booleanValue()); } if (value.isNumber() != null) { Double doubleValue = value.isNumber().doubleValue(); return new EditorNumberPropertyWidget(propertyName, doubleValue.intValue()); } return new EditorStringPropertyWidget(propertyName, value.toString()); }
From source file:org.eclipselabs.emfjson.gwt.internal.JSONLoad.java
License:Open Source License
private void setEAttributeValue(EObject obj, EAttribute attribute, JSONValue node) { JSONString string = node.isString(); if (string != null) { setEAttributeStringValue(obj, attribute, string); } else {/*from ww w .java 2 s . c om*/ JSONNumber number = node.isNumber(); if (number != null) { setEAttributeNumberValue(obj, attribute, number); } else { JSONBoolean bool = node.isBoolean(); if (bool != null) { setEAttributeBooleanValue(obj, attribute, bool); } } } }