List of usage examples for com.google.gwt.json.client JSONValue isString
public JSONString isString()
From source file:org.eclipselabs.emfjson.gwt.common.ModelUtil.java
License:Open Source License
public static URI getEObjectURI(JSONValue jsonNode, URI uri, Map<String, String> nsMap) { final JSONString string = jsonNode.isString(); final String value = string == null ? "" : string.stringValue(); if (value.startsWith("#//")) { // is fragment return URI.createURI(uri + value); } else if (value.contains("#//") && nsMap.keySet().contains(value.split("#//")[0])) { String[] split = value.split("#//"); String nsURI = nsMap.get(split[0]); return URI.createURI(nsURI + "#//" + split[1]); } else if (value.contains(":")) { return URI.createURI(value); } else { // is ID return uri.appendFragment(value); }/*from w ww.ja v a 2 s . c o m*/ }
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 .j av a 2 s .co m*/ JSONNumber number = node.isNumber(); if (number != null) { setEAttributeNumberValue(obj, attribute, number); } else { JSONBoolean bool = node.isBoolean(); if (bool != null) { setEAttributeBooleanValue(obj, attribute, bool); } } } }
From source file:org.eclipselabs.emfjson.gwt.internal.JSONLoad.java
License:Open Source License
private EObject createEntry(String key, JSONValue value) { EObject eObject = EcoreUtil.create(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY); eObject.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__KEY, key); String entryValue;/*w w w.ja v a 2 s . c o m*/ if (value.isString() != null) entryValue = value.isString().stringValue(); else entryValue = value.toString(); eObject.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__VALUE, entryValue); return eObject; }
From source file:org.eclipselabs.emfjson.gwt.internal.JSONLoad.java
License:Open Source License
private URI getEObjectURI(JSONValue jsonValue, Resource resource) { final JSONString string = jsonValue.isString(); final String value = string == null ? "" : string.stringValue(); if (value.startsWith("#//")) { // is fragment return URI.createURI(resource.getURI() + value); } else if (value.contains("#//") && nsMap.keySet().contains(value.split("#//")[0])) { String[] split = value.split("#//"); String nsURI = nsMap.get(split[0]); return URI.createURI(nsURI + "#//" + split[1]); } else if (value.contains(":")) { return URI.createURI(value); } else { // is ID return resource.getURI().appendFragment(value); }//from ww w . j a v a 2 s .c o m }
From source file:org.eclipselabs.emfjson.gwt.map.EAtttributeDeserializer.java
License:Open Source License
void deSerializeValue(EObject eObject, EAttribute attribute, JSONValue value) { final String stringValue; if (value.isString() != null) stringValue = value.isString().stringValue(); else if (value.isBoolean() != null) stringValue = Boolean.toString(value.isBoolean().booleanValue()); else if (value.isNumber() != null) stringValue = value.toString();//from w w w . ja v a 2 s. co m else stringValue = ""; if (stringValue != null && !stringValue.trim().isEmpty()) { Object newValue; if (attribute.getEAttributeType().getInstanceClass().isEnum()) { newValue = EcoreUtil.createFromString(attribute.getEAttributeType(), stringValue.toUpperCase()); } else { newValue = EcoreUtil.createFromString(attribute.getEAttributeType(), stringValue); } if (!attribute.isMany()) { eObject.eSet(attribute, newValue); } else { @SuppressWarnings("unchecked") Collection<Object> values = (Collection<Object>) eObject.eGet(attribute); values.add(newValue); } } }
From source file:org.eclipselabs.emfjson.gwt.map.MapDeserializer.java
License:Open Source License
EObject deSerializeEntry(String key, JSONValue value) { EObject eObject = EcoreUtil.create(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY); eObject.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__KEY, key); if (value.isString() != null) { eObject.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__VALUE, value.isString().stringValue()); } else {/*from w ww . ja va 2s . co m*/ eObject.eSet(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY__VALUE, value.toString()); } return eObject; }
From source file:org.ednovo.gooru.application.client.home.HomeView.java
License:Open Source License
/** * * @function getList//from w w w . j av a 2 s .co m * * @created_date : Aug 5, 2014 * * @description * * * @param jsonResponse * @return * * @return : List<JSONStandardsDo> * * @throws : <Mentioned if any exceptions> * * * * */ @SuppressWarnings("deprecation") public List<JSONStandardsDo> getList(String jsonResponse) { List<JSONStandardsDo> stdList = new ArrayList<JSONStandardsDo>(); JSONValue jsonValue = JSONParser.parse(jsonResponse); JSONArray jsonArray = jsonValue.isArray(); for (int i = 0; i < jsonArray.size(); i++) { JSONObject obj = jsonArray.get(i).isObject(); if (obj != null) { JSONStandardsDo stdObj = new JSONStandardsDo(); JSONValue label = obj.get("label").isString(); JSONNumber courseId = obj.get("courseId").isNumber(); JSONNumber subjectId = obj.get("subjectId").isNumber(); JSONValue link = obj.get("link").isString(); JSONValue extraParms = obj.get("extraParms").isString(); stdObj.setLabel(label.isString().stringValue()); stdObj.setCourseId((int) courseId.isNumber().getValue()); stdObj.setSubjectId((int) subjectId.isNumber().getValue()); stdObj.setLink(link.isString().stringValue()); stdObj.setExtraParms(extraParms != null ? extraParms.isString().stringValue() : null); stdList.add(stdObj); } } return stdList; }
From source file:org.emfjson.gwt.map.JsonReader.java
License:Open Source License
@SuppressWarnings("unchecked") private void setEntryObject(JSONObject entryObject, EObject owner, EReference reference) { EList<EObject> values = null;/*from w w w. j a v a2 s . c om*/ if (reference.isMany()) { values = (EList<EObject>) owner.eGet(reference); } if (entryObject != null) { for (String key : entryObject.keySet()) { final JSONValue entryValue = entryObject.get(key); final JSONString stringValue = entryValue.isString(); if (stringValue != null) { if (reference.isMany() && values != null) { values.add(createEntry(key, stringValue.stringValue())); } else { owner.eSet(reference, createEntry(key, stringValue.stringValue())); } } } } }
From source file:org.emfjson.gwt.map.JsonReader.java
License:Open Source License
private String getRef(JSONValue value) { final JSONObject refObject = value.isObject(); if (refObject != null) { final JSONValue refValue = refObject.get(options.refField); if (refValue != null) { final JSONString string = refValue.isString(); if (string != null) { return string.stringValue(); }/* w w w . j a v a 2s . co m*/ } } return null; }
From source file:org.emfjson.gwt.map.JsonReader.java
License:Open Source License
private String getType(JSONObject node) { final JSONValue typeValue = node.get(options.typeField); if (typeValue != null) { final JSONString stringValue = typeValue.isString(); if (stringValue != null) { return stringValue.stringValue(); }/*from w ww . j a v a 2 s. com*/ } return null; }