com.google.gwt.json.client.JSONObject Java Examples
The following examples show how to use
com.google.gwt.json.client.JSONObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DigitalObjectEditing.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override public String getToken(DigitalObjectEditorPlace place) { String[] digitalObjectPids = place.getPids(); if (digitalObjectPids != null && digitalObjectPids.length > 1) { // batch edits should not be bookmarked throw new UnsupportedOperationException(Arrays.toString(digitalObjectPids)); } Record[] digitalObjects = place.getDigitalObjects(); if (digitalObjects != null && digitalObjects.length > 1) { // batch edits should not be bookmarked String[] pids = ClientUtils.toFieldValues(digitalObjects, "pid"); throw new UnsupportedOperationException(Arrays.toString(pids)); } JSONObject json = new JSONObject(); JsonTokenizer.putString(json, EDITOR, place.editor == null ? null : place.editor.name()); JsonTokenizer.putString(json, PID, place.getPid()); String jsonString = json.toString(); return jsonString; }
Example #2
Source File: WaitForBuildResultCommand.java From appinventor-extensions with Apache License 2.0 | 6 votes |
private static String extractFormName(RpcResult result) { String extraString = result.getExtra(); if (extraString != null) { JSONValue extraJSONValue = JSONParser.parseStrict(extraString); JSONObject extraJSONObject = extraJSONValue.isObject(); if (extraJSONObject != null) { JSONValue formNameJSONValue = extraJSONObject.get("formName"); if (formNameJSONValue != null) { JSONString formNameJSONString = formNameJSONValue.isString(); if (formNameJSONString != null) { return formNameJSONString.stringValue(); } } } } return "Screen1"; }
Example #3
Source File: GwtGadgetInfoParser.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
private GadgetInfo parseGadgetInfo(JSONValue item) { JSONObject object = item.isObject(); if (object != null) { String name = object.get("name").isString().stringValue(); String desc = object.get("desc").isString().stringValue(); GadgetCategoryType primaryCategory = GadgetCategoryType.of(object.get("primaryCategory").isString().stringValue()); GadgetCategoryType secondaryCategory = GadgetCategoryType.of(object.get("secondaryCategory").isString().stringValue()); String gadgetUrl = object.get("gadgetUrl").isString().stringValue(); String author = object.get("author").isString().stringValue(); String submittedBy = object.get("submittedBy").isString().stringValue(); String imageUrl = object.get("imageUrl").isString().stringValue(); return new GadgetInfo(name, desc, primaryCategory, secondaryCategory, gadgetUrl, author, submittedBy, imageUrl); } return null; }
Example #4
Source File: BootstrapServerStore.java From core with GNU Lesser General Public License v2.1 | 6 votes |
public BootstrapServer restoreSelection() { if (storage != null) { //noinspection MismatchedQueryAndUpdateOfCollection StorageMap storageMap = new StorageMap(storage); if (storageMap.containsKey(KEY)) { String json = storageMap.get(SELECTED); if (json != null) { JSONValue jsonValue = JSONParser.parseStrict(json); if (jsonValue != null) { JSONObject jsonObject = jsonValue.isObject(); if (jsonObject != null) { AutoBean<BootstrapServer> bean = AutoBeanCodex .decode(factory, BootstrapServer.class, jsonObject.toString()); return bean.as(); } } } } } return null; }
Example #5
Source File: Index.java From core with GNU Lesser General Public License v2.1 | 6 votes |
public List<Document> search(final String text) { List<Document> results = new ArrayList<Document>(); JsArray jsonResult = searchInternal(text); if (jsonResult != null) { for (int i = 0; i < jsonResult.length(); i++) { JSONObject json = new JSONObject(jsonResult.get(i)); JSONString jsonId = json.get("ref").isString(); if (jsonId != null) { long id = Long.parseLong(jsonId.stringValue()); String documentJson = localStorage.getItem(key(id)); if (documentJson != null) { AutoBean<Document> autoBean = AutoBeanCodex.decode(beanFactory, Document.class, documentJson); results.add(autoBean.as()); } } } } return results; }
Example #6
Source File: UploadResponse.java From core with GNU Lesser General Public License v2.1 | 6 votes |
private String extractFailure(final JSONObject response) { String failure = "n/a"; JSONValue failureValue = response.get(FAILURE_DESCRIPTION); if (failureValue.isString() != null) { failure = failureValue.isString().stringValue(); } else if (failureValue.isObject() != null) { JSONObject failureObject = failureValue.isObject(); for (String key : failureObject.keySet()) { if (key.contains("failure") && failureObject.get(key).isString() != null) { failure = failureObject.get(key).isString().stringValue(); break; } } } return failure; }
Example #7
Source File: GadgetUserPrefs.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Extracts default preference values from the gadget metadata JSON object * returned from GGS. * * @param prefs the preference JSON object received from GGS. */ public void parseDefaultValues(JSONObject prefs) { if (prefs != null) { for (String pref : prefs.keySet()) { if (!has(pref)) { JSONObject prefJson = prefs.get(pref).isObject(); if (prefJson != null) { JSONValue value = prefJson.get("default"); if ((value != null) && (value.isString() != null)) { put(pref, value.isString().stringValue()); log("Gadget pref '" + pref + "' = '" + get(pref) + "'"); } } else { log("Invalid pref '" + pref + "' value in Gadget metadata."); } } } } }
Example #8
Source File: DataSelectionEvent.java From dashbuilder with Apache License 2.0 | 6 votes |
public static void fire(HasDataSelectionEventHandlers source, Object sender, JavaScriptObject data) { DataSelectionEvent event = new DataSelectionEvent(sender); JSONObject array = new JSONObject(data); event.series = new LinkedList<Series>(); for(String key : array.keySet()){ JSONObject obj = array.get(key).isObject(); if(obj != null){ Series series1 = JavaScriptObject.createObject().cast(); series1.setValue(obj.get("value").isNumber().doubleValue()); series1.setColor(obj.get("fillColor").isString().stringValue()); event.series.add(series1); } } source.fireEvent(event); }
Example #9
Source File: GwtGadgetInfoParser.java From swellrt with Apache License 2.0 | 6 votes |
private GadgetInfo parseGadgetInfo(JSONValue item) { JSONObject object = item.isObject(); if (object != null) { String name = object.get("name").isString().stringValue(); String desc = object.get("desc").isString().stringValue(); GadgetCategoryType primaryCategory = GadgetCategoryType.of(object.get("primaryCategory").isString().stringValue()); GadgetCategoryType secondaryCategory = GadgetCategoryType.of(object.get("secondaryCategory").isString().stringValue()); String gadgetUrl = object.get("gadgetUrl").isString().stringValue(); String author = object.get("author").isString().stringValue(); String submittedBy = object.get("submittedBy").isString().stringValue(); String imageUrl = object.get("imageUrl").isString().stringValue(); return new GadgetInfo(name, desc, primaryCategory, secondaryCategory, gadgetUrl, author, submittedBy, imageUrl); } return null; }
Example #10
Source File: MockMapFeatureBase.java From appinventor-extensions with Apache License 2.0 | 6 votes |
/** * Process the information from the feature's GeoJSON properties field. Subclasses may override * this function to set default values, but _must_ call super.processFromGeoJSON() otherwise * properties defined in superclasses will not get set. * * @param parent the mock feature collection that will contain the feature * @param properties the properties object from the GeoJSON */ protected void processFromGeoJSON(MockFeatureCollection parent, JSONObject properties) { setStrokeWidthProperty(DEFAULT_STROKE_COLOR); setStrokeColorProperty(DEFAULT_STROKE_WIDTH); String name = null; for (String key : properties.keySet()) { if (key.equalsIgnoreCase(PROPERTY_NAME_NAME)) { name = properties.get(key).isString().stringValue(); } else { processPropertyFromGeoJSON(key, properties.get(key)); } } processFeatureName(this, parent, name); // Use the name as the title if the properties did not include one (issue #1425) if (getPropertyValue(PROPERTY_NAME_TITLE).isEmpty()) { changeProperty(PROPERTY_NAME_TITLE, getPropertyValue(PROPERTY_NAME_NAME)); } }
Example #11
Source File: GadgetUserPrefs.java From swellrt with Apache License 2.0 | 6 votes |
/** * Extracts default preference values from the gadget metadata JSON object * returned from GGS. * * @param prefs the preference JSON object received from GGS. */ public void parseDefaultValues(JSONObject prefs) { if (prefs != null) { for (String pref : prefs.keySet()) { if (!has(pref)) { JSONObject prefJson = prefs.get(pref).isObject(); if (prefJson != null) { JSONValue value = prefJson.get("default"); if ((value != null) && (value.isString() != null)) { put(pref, value.isString().stringValue()); log("Gadget pref '" + pref + "' = '" + get(pref) + "'"); } } else { log("Invalid pref '" + pref + "' value in Gadget metadata."); } } } } }
Example #12
Source File: LeafletStyle.java From geowe-core with GNU General Public License v3.0 | 6 votes |
public static ProjectLayerStyle getStyle(String geoJSONCSS) { ProjectLayerStyle style = null; final JSONValue jsonValue = JSONParser.parseLenient(geoJSONCSS); final JSONObject geoJSONCssObject = jsonValue.isObject(); if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) { JSONObject styleObject = geoJSONCssObject .get(GeoJSONCSS.STYLE_NAME).isObject(); String fillColor = getStringValue(styleObject, FILL_COLOR_NAME); Double fillOpacity = getDoubleValue(styleObject, FILL_OPACITY_NAME); if(fillOpacity == null) { fillOpacity = getDoubleValue(styleObject, FILL_OPACITY2_NAME); } String strokeColor = getStringValue(styleObject, STROKE_COLOR_NAME); Double strokeWidth = getDoubleValue(styleObject, STROKE_WIDTH_NAME); style = new ProjectLayerStyle(fillColor, fillOpacity, strokeColor, strokeWidth); } return style; }
Example #13
Source File: Project.java From geowe-core with GNU General Public License v3.0 | 6 votes |
public String toJSON() { JSONObject projectObject = new JSONObject(); projectObject.put("version", new JSONString(getVersion())); projectObject.put("title", new JSONString(getTitle())); projectObject.put("description", new JSONString(getDescription())); projectObject.put("date", new JSONString(getDate())); JSONArray layersArray = new JSONArray(); int index = 0; for(ProjectVectorLayer projectLayer: vectors) { layersArray.set(index, projectLayer.getJSONObject()); index++; } projectObject.put("vectors", layersArray); return projectObject.toString(); }
Example #14
Source File: UploadFile.java From proarc with GNU General Public License v3.0 | 6 votes |
private void uploadFile() { JSONObject post = new JSONObject(); String mime = form.getValueAsString(FIELD_MIMETYPE); if (mime != null && !mime.trim().isEmpty()) { post.put(FIELD_MIMETYPE, new JSONString(mime)); } post.put(FIELD_PID, new JSONString(dobj.getPid())); String batchId = dobj.getBatchId(); if (batchId != null) { post.put(FIELD_BATCHID, new JSONString(batchId)); } post.put(DigitalObjectResourceApi.DISSEMINATION_ERROR, JSONBoolean.getInstance(true)); uploader.setPostParams(post); uploader.startUpload(); showUploading(true); }
Example #15
Source File: WorkflowManaging.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override public WorkflowPlace getPlace(String token) { WorkflowPlace place = new WorkflowJobPlace(); JSONObject json = JsonTokenizer.parseObject(token); if (json != null) { String type = JsonTokenizer.getString(json, TYPE); if ((place = WorkflowJobPlace.from(type, json)) == null) { if ((place = WorkflowTaskPlace.from(type, json)) == null) { if ((place = WorkflowNewJobPlace.from(type, json)) == null) { place = WorkflowNewJobEditPlace.from(type, json); } } } } return place; }
Example #16
Source File: Application.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
private static TimeseriesRenderingOptions createRenderingOptions(String options) { if (options == null) { return new TimeseriesRenderingOptions(); } TimeseriesRenderingOptions tsOptions = new TimeseriesRenderingOptions(); JSONObject tsRenderingOptions = new JSONObject(parseUntrustedJson(options)); if (tsRenderingOptions.containsKey("color")) { JSONString color = tsRenderingOptions.get("color").isString(); tsOptions.setColor(color.stringValue()); } if (tsRenderingOptions.containsKey("lineWidth")) { JSONNumber lineWidth = tsRenderingOptions.get("lineWidth").isNumber(); tsOptions.setLineWidth((int)lineWidth.doubleValue()); } return tsOptions; }
Example #17
Source File: GadgetNonEditorGwtTest.java From swellrt with Apache License 2.0 | 5 votes |
/** * Returns a test gadget metadata object. * * @param xmlSource gadget xml * @return the metadata object */ public GadgetMetadata getTestMetadata(String xmlSource) { String iFrameUrl = "//0" + GADGET_SERVER + "/gadgets/ifr?url=http://test.com/gadget.xml&view=canvas"; JSONObject canvasViewData = new JSONObject(); JSONObject viewData = new JSONObject(); viewData.put(VIEW_NAME, canvasViewData); JSONObject jsonData = new JSONObject(); jsonData.put("iframeUrl", new JSONString(iFrameUrl)); jsonData.put("views", viewData); jsonData.put("url", new JSONString(xmlSource)); jsonData.put("userPrefs", new JSONObject()); return new GadgetMetadata(jsonData); }
Example #18
Source File: GadgetMetadata.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Helper function to extract a boolean value from given JSON object. * * @param json JSON object to extract the value from. * @param key key of the value to extract. * @return the Boolean object extracted from JSON (can be null if the value * does not exist or is invalid. */ private static Boolean getJsonBooleanValue(JSONObject json, String key) { JSONValue value = json.get(key); JSONBoolean bool = (value == null) ? null : value.isBoolean(); if (bool != null) { return bool.booleanValue(); } else { return null; } }
Example #19
Source File: BitcoinJSONViewer.java From bitcoin-transaction-explorer with MIT License | 5 votes |
private void drawObject(final FlowPanel container, final int n, final JSONObject jsonObject) { for (final String key : jsonObject.keySet()) { container.add(createHeader(n, key)); final FlowPanel subPanel = new FlowPanel(); container.add(subPanel); subPanel.getElement().getStyle().setProperty("border", "2px solid gray"); subPanel.getElement().getStyle().setProperty("marginLeft", "4px"); subPanel.getElement().getStyle().setProperty("padding", "12px"); display(n + 1, subPanel, jsonObject.get(key)); } }
Example #20
Source File: ProjectVectorLayer.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public JSONObject getJSONObject() { JSONObject projectLayerObject = new JSONObject(); projectLayerObject.put("name", new JSONString(getName())); projectLayerObject.put("content", new JSONString(getContent())); projectLayerObject.put("style", style.getJSONObject()); return projectLayerObject; }
Example #21
Source File: GadgetMetadata.java From swellrt with Apache License 2.0 | 5 votes |
/** * Helper function to extract a boolean value from given JSON object. * * @param json JSON object to extract the value from. * @param key key of the value to extract. * @return the Boolean object extracted from JSON (can be null if the value * does not exist or is invalid. */ private static Boolean getJsonBooleanValue(JSONObject json, String key) { JSONValue value = json.get(key); JSONBoolean bool = (value == null) ? null : value.isBoolean(); if (bool != null) { return bool.booleanValue(); } else { return null; } }
Example #22
Source File: ProjectLayerStyle.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public JSONObject getJSONObject() { JSONObject projectLayerObject = new JSONObject(); projectLayerObject.put(FILL_COLOR_NAME, new JSONString(getFillColor())); projectLayerObject.put(FILL_OPACITY_NAME, new JSONNumber(getFillOpacity())); projectLayerObject.put(STROKE_COLOR_NAME, new JSONString(getStrokeColor())); projectLayerObject.put(STROKE_WIDTH_NAME, new JSONNumber(getStrokeWidth())); return projectLayerObject; }
Example #23
Source File: LoadCompatMatrix.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(Control<BootstrapContext> control) { TextResource compat = TextResources.INSTANCE.compat(); JSONValue root = JSONParser.parseLenient(compat.getText()); JSONObject versionList = root.isObject(); Set<String> keys = versionList.keySet(); for (String key : keys) { modelVersions.put(key, versionList.get(key).isString().stringValue()); } System.out.println("Build against Core Model Version: " + modelVersions.get("core-version")); control.proceed(); }
Example #24
Source File: Project.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public Project(String json) { final JSONValue jsonValue = JSONParser.parseLenient(json); final JSONObject jsonObject = jsonValue.isObject(); String projectDate = jsonObject.get(DATE_NAME).isString().stringValue(); String projectTitle = jsonObject.get(TITLE_NAME).isString().stringValue(); String projectVersion = jsonObject.get(VERSION_NAME).isString().stringValue(); String projectDescription = jsonObject.get(DESCRIPTION_NAME).isString().stringValue(); setDate(projectDate); setTitle(projectTitle); setVersion(projectVersion); setDescription(projectDescription); JSONArray layersArray = jsonObject.get(VECTORS_NAME).isArray(); if (layersArray != null) { for (int i = 0; i < layersArray.size(); i++) { JSONObject projectLayerObj = layersArray.get(i).isObject(); String name = projectLayerObj.get(NAME).isString().stringValue(); String content = projectLayerObj.get(CONTENT_NAME).isString().stringValue(); JSONObject styleProjectLayer = projectLayerObj.get(STYLE_NAME).isObject(); String fillColor = styleProjectLayer.get(ProjectLayerStyle.FILL_COLOR_NAME).isString().stringValue(); Double fillOpacity = styleProjectLayer.get(ProjectLayerStyle.FILL_OPACITY_NAME).isNumber().doubleValue(); String strokeColor = styleProjectLayer.get(ProjectLayerStyle.STROKE_COLOR_NAME).isString().stringValue(); Double strokeWidth = styleProjectLayer.get(ProjectLayerStyle.STROKE_WIDTH_NAME).isNumber().doubleValue(); add(name, content, fillColor, fillOpacity, strokeColor, strokeWidth); } } }
Example #25
Source File: Importing.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public String getToken(ImportPlace place) { JSONObject json = new JSONObject(); Type importType = place.getType(); JsonTokenizer.putString(json, TYPE, importType == null ? null : importType.name()); JsonTokenizer.putString(json, BATCHID, place.getBatchId()); return json.toString(); }
Example #26
Source File: Importing.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public ImportPlace getPlace(String token) { ImportPlace p = new ImportPlace(); JSONObject json = JsonTokenizer.parseObject(token); if (json != null) { p.type = Type.fromString(JsonTokenizer.getString(json, TYPE)); p.batchId = JsonTokenizer.getString(json, BATCHID); } return p; }
Example #27
Source File: UploadResponse.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public ModelNode get() { ModelNode node; if (contentType.startsWith(APPLICATION_DMR_ENCODED)) { node = ModelNode.fromBase64(payload); } else if (contentType.startsWith(APPLICATION_JSON)) { node = new ModelNode(); JSONObject response = JSONParser.parseLenient(payload).isObject(); JSONString outcome = response.get(OUTCOME).isString(); node.get(OUTCOME).set(outcome.stringValue()); if (outcome.stringValue().equals(SUCCESS)) { if (response.containsKey(RESULT) && response.get(RESULT).isObject() != null) { node.get(RESULT).set(stringify(response.get(RESULT).isObject().getJavaScriptObject(), 2)); } else { node.get(RESULT).set(new ModelNode()); } } else { String failure = extractFailure(response); node.get(FAILURE_DESCRIPTION).set(failure); } } else { node = new ModelNode(); node.get(OUTCOME).set(FAILED); node.get(FAILURE_DESCRIPTION).set("Unable to parse response with content-type " + contentType); } return node; }
Example #28
Source File: DigitalObjectCreating.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public String getToken(DigitalObjectCreatorPlace place) { JSONObject json = new JSONObject(); JsonTokenizer.putString(json, MODEL, place.model); JsonTokenizer.putString(json, PARENT, place.parent); String jsonString = json.toString(); return jsonString; }
Example #29
Source File: DigitalObjectCreating.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public DigitalObjectCreatorPlace getPlace(String token) { DigitalObjectCreatorPlace p = new DigitalObjectCreatorPlace(); JSONObject json = JsonTokenizer.parseObject(token); if (json != null) { p.model = JsonTokenizer.getString(json, MODEL); p.parent = JsonTokenizer.getString(json, PARENT); } return p; }
Example #30
Source File: LeafletStyle.java From geowe-core with GNU General Public License v3.0 | 5 votes |
private static String getStringValue(JSONObject styleObject, String key) { String newValue = ""; if (styleObject.containsKey(key)) { try { newValue = styleObject.get(key).isString().stringValue(); } catch (Exception e) { // si el valor del atributo no está bien definido es ignorado } } return newValue; }