Package com.google.gwt.json.client

Examples of com.google.gwt.json.client.JSONString


        buttonSendMessage.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                if (!"".equals(textBoxNewMessage.getText())) {
                    JSONArray array = new JSONArray();
                    array.set(0, new JSONString(textBoxNewMessage.getText()));

                    JSONObject container = new JSONObject();
                    container.put("value", array);

                    streamingService.sendMessage(textBoxTopic.getText(), container);
View Full Code Here


        public void onSuccess(Object result) {

            JSONObject resultObject = (JSONObject) result;
            JSONArray resultArray = (JSONArray) resultObject.get("value");
            JSONString resultString = (JSONString) resultArray.get(0);

            StringBuffer newText = new StringBuffer(textAreaHistory.getText());
            newText.append(queueName);
            newText.append(':');
            newText.append(resultString.stringValue());
            newText.append('\n');
            textAreaHistory.setText(newText.toString());
            textAreaHistory.setCursorPos(textAreaHistory.getVisibleLines());
        }
View Full Code Here

    public void put(String key, long value) {
        object.put(key, new JSONNumber(value));
    }

    public void put(String key, String value) {
        object.put(key, new JSONString(value));
    }
View Full Code Here

            return (JSONValue) value;
        } else if (value instanceof String[]) {
            String[] array = (String[]) value;
            JSONArray jsonArray = new JSONArray();
            for (int i = 0; i < array.length; ++i) {
                jsonArray.set(i, new JSONString(array[i]));
            }
            return jsonArray;
        } else if (value instanceof String) {
            return new JSONString((String) value);
        } else if (value instanceof Boolean) {
            return JSONBoolean.getInstance((Boolean) value);
        } else if (value instanceof Byte) {
            return new JSONNumber((Byte) value);
        } else if (value instanceof Character) {
            return new JSONString(String.valueOf(value));
        } else if (value instanceof Object[] && type == null) {
            // Non-legacy arrays handed by generated serializer
            return encodeLegacyObjectArray((Object[]) value, connection);
        } else if (value instanceof Enum) {
            return encodeEnum((Enum<?>) value, connection);
        } else if (value instanceof Map) {
            return encodeMap((Map) value, type, connection);
        } else if (value instanceof Connector) {
            Connector connector = (Connector) value;
            return new JSONString(connector.getConnectorId());
        } else if (value instanceof Collection) {
            return encodeCollection((Collection) value, type, connection);
        } else if (value instanceof UidlValue) {
            return encodeVariableChange((UidlValue) value, connection);
        } else {
            // First see if there's a custom serializer
            JSONSerializer<Object> serializer = null;
            if (type != null) {
                serializer = (JSONSerializer<Object>) type.findSerializer();
                if (serializer != null) {
                    return serializer.serialize(value, connection);
                }
            }

            String transportType = getTransportType(value);
            if (transportType != null) {
                // Send the string value for remaining legacy types
                return new JSONString(String.valueOf(value));
            } else if (type != null) {
                // And finally try using bean serialization logic
                try {
                    JsArrayObject<Property> properties = type
                            .getPropertiesAsArray();
View Full Code Here

                valueType = value.getClass().getName();
            }
            throw new IllegalArgumentException("Cannot encode object of type "
                    + valueType);
        }
        jsonArray.set(0, new JSONString(transportType));
        jsonArray.set(1, encode(value, null, connection));

        return jsonArray;
    }
View Full Code Here

        return jsonMap;
    }

    private static JSONValue encodeEnum(Enum<?> e,
            ApplicationConnection connection) {
        return new JSONString(e.toString());
    }
View Full Code Here

        startRequest();

        JSONObject payload = new JSONObject();
        if (!getCsrfToken().equals(
                ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) {
            payload.put(ApplicationConstants.CSRF_TOKEN, new JSONString(
                    getCsrfToken()));
        }
        payload.put(ApplicationConstants.RPC_INVOCATIONS, reqInvocations);
        payload.put(ApplicationConstants.SERVER_SYNC_ID, new JSONNumber(
                lastSeenServerSyncId));
View Full Code Here

            }

            for (MethodInvocation invocation : pendingInvocations.values()) {
                JSONArray invocationJson = new JSONArray();
                invocationJson.set(0,
                        new JSONString(invocation.getConnectorId()));
                invocationJson.set(1,
                        new JSONString(invocation.getInterfaceName()));
                invocationJson.set(2,
                        new JSONString(invocation.getMethodName()));
                JSONArray paramJson = new JSONArray();

                Type[] parameterTypes = null;
                if (!isLegacyVariableChange(invocation)
                        && !isJavascriptRpc(invocation)) {
View Full Code Here

   */
  public void onModuleLoad() {

    JSONObject n1 = new JSONObject();
    n1.put("id", new JSONNumber(1));
    n1.put("text", new JSONString("Node 1"));

    JSONObject n2 = new JSONObject();
    n2.put("id", new JSONNumber(2));
    n2.put("text", new JSONString("Node 2"));

    JSONObject n3 = new JSONObject();
    n3.put("id", new JSONNumber(3));
    n3.put("text", new JSONString("Node 3"));

    JSONArray nodes = new JSONArray();
    nodes.set(0, n1);
    nodes.set(1, n2);
    nodes.set(2, n3);
View Full Code Here

  void deletePackage() {
    JSONObject p = new JSONObject();
    p.put("id", new JSONNumber(packageId));
    p.put("from", new JSONNumber(2));
    p.put("to", new JSONNumber(3));
    p.put("action", new JSONString("delete"));

    JSONArray packages = new JSONArray();
    packages.set(0, p);

    network.addPackages(packages.getJavaScriptObject());
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.