List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber
public JSONNumber(double value)
From source file:rpc.client.data.JSONSerializer.java
License:Open Source License
private JSONValue toJSONValue(Object object) { // Null//from w w w.j ava 2 s . c o m if (object == null) { return JSONNull.getInstance(); } // Boolean Boolean asBoolean = Utils.isBoolean(object); if (asBoolean != null) { return JSONBoolean.getInstance(asBoolean); } // Integer Integer asInteger = Utils.isInteger(object); if (asInteger != null) { return new JSONNumber(asInteger); } // Long Long asLong = Utils.isLong(object); if (asLong != null) { return new JSONNumber(asLong); } // Float Float asFloat = Utils.isFloat(object); if (asFloat != null) { return new JSONNumber(asFloat); } // Double Double asDouble = Utils.isDouble(object); if (asDouble != null) { return new JSONNumber(asDouble); } // String String asString = Utils.isString(object); if (asString != null) { return new JSONString(asString); } // Enum Enum asEnum = Utils.isEnum(object); if (asEnum != null) { return new JSONString(asEnum.toString()); } // Serializable Serializable asSerializable = Utils.isSerializable(object); if (asSerializable != null) { JSONObject jsonObject = new JSONObject(); for (String field : asSerializable.fields().keySet()) { Object value = asSerializable.get(field); jsonObject.put(field, toJSONValue(value)); } return jsonObject; } // List List<Object> asSerializableList = Utils.isSerializableList(object); if (asSerializableList != null) { JSONArray jsonArray = new JSONArray(); for (int i = 0; i < asSerializableList.size(); i++) { Object item = asSerializableList.get(i); jsonArray.set(i, toJSONValue(item)); } return jsonArray; } // Map Map<Object, Object> asSerializableMap = Utils.isSerializableMap(object); if (asSerializableMap != null) { JSONObject jsonObject = new JSONObject(); for (Map.Entry<Object, Object> entry : asSerializableMap.entrySet()) { Object keyObject = entry.getKey(); Object valueObject = entry.getValue(); String key = null; String keyAsString = Utils.isString(keyObject); if (keyAsString != null) { key = keyAsString; } Enum keyAsEnum = Utils.isEnum(keyObject); if (keyAsEnum != null) { key = keyAsEnum.toString(); } jsonObject.put(key, toJSONValue(valueObject)); } return jsonObject; } return null; }
From source file:stroom.dashboard.client.vis.PostMessage.java
License:Apache License
public void postMessage(final Element frame, final JSONObject json, final int frameId, final int callbackId) { final JSONObject message = new JSONObject(); message.put("frameId", new JSONNumber(frameId)); message.put("callbackId", new JSONNumber(callbackId)); message.put("data", json); nativePostMessage(frame, message.toString()); }
From source file:stroom.dashboard.client.vis.PostMessage.java
License:Apache License
public void postMessage(final Element frame, final JSONObject json, final int frameId) { final JSONObject message = new JSONObject(); message.put("frameId", new JSONNumber(frameId)); message.put("data", json); nativePostMessage(frame, message.toString()); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.common.client.view.DataFilesUploadViewImpl.java
License:Apache License
public DataFilesUploadViewImpl() { initWidget(Binder.BINDER.createAndBindUi(this)); JSONObject uploaderOptions = new JSONObject(); uploaderOptions.put("simultaneousUploads", new JSONNumber(1)); uploaderOptions.put("method", new JSONString("octet")); ResumableUploader uploader = ResumableUploader.newInstance(Urls.getContextUrl() + "upload", uploaderOptions);/* w w w. j a v a2 s. c o m*/ uploader.assignBrowse(uploadBtn.getElement()); uploader.assignDrop(fileListPanel.getElement()); progressPanel = new UploadProgressPopupPanel(uploader); ftpUploadDialog = new FTPUploadDialog(); fileListPanel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { deleteFilesBtn.setEnabled(!fileListPanel.getSelectedRows().isEmpty()); } }); // fileListPanel.addDomHandler(new DragEnterHandler() { // @Override // public void onDragEnter(DragEnterEvent event) { // fileListPanel.addStyleName("drop-active"); // } // }, DragEnterEvent.getType()); // // fileListPanel.addDomHandler(new DragLeaveHandler() { // @Override // public void onDragLeave(DragLeaveEvent event) { // fileListPanel.removeStyleName("drop-active"); // } // }, DragLeaveEvent.getType()); // // fileListPanel.addDomHandler(new DropHandler() { // @Override // public void onDrop(DropEvent event) { // fileListPanel.removeStyleName("drop-active"); // } // }, DropEvent.getType()); }
From source file:us.asciiroth.client.board.BoardWriter.java
License:Apache License
private void addPiece(Set<JSONObject> pieceSet, int x, int y, Piece piece) { JSONObject obj = new JSONObject(); obj.put(X_KEY, new JSONNumber(x)); obj.put(Y_KEY, new JSONNumber(y)); obj.put(KEY_KEY, new JSONString(Registry.get().getKey(piece))); pieceSet.add(obj);//from www .ja v a 2s. c o m }
From source file:us.asciiroth.client.board.WriterBase.java
License:Apache License
/** * Add a Number value as a property of the supplied JSON object. * @param b/*w w w .java 2 s.com*/ * @param name * @param value */ protected void addNumber(JSONObject b, String name, int value) { b.put(name, new JSONNumber(value)); }
From source file:viewer.Json.java
License:Open Source License
public Json add(final String field, final long value) { return add(field, new JSONNumber(value)); }
From source file:viewer.Json.java
License:Open Source License
public Json add(final String field, final double value) { return add(field, new JSONNumber(value)); }