Package com.google.gwt.json.client

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


* @author Jon Crosby
*/
public class JsonResourceCollectionParser implements ResourceCollectionParser {

    public Collection parse(String text, ResourceFactory factory) {
        JSONArray json = (JSONArray) JSONParser.parse(text);
        Collection resources = new ArrayList();
           
        for (int i = 0; i < json.size(); i++) {
            Resource resource = factory.create();
            resource.populateFromRepresentation(json.get(i).isObject().toString());
            resources.add(resource);
        }
       
        return resources;
    }
View Full Code Here


        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());
View Full Code Here

        message.setText("");

        item.setPrice(newBidValue);
        int numberOfBids = item.getNumberOfBids();

        JSONArray array = new JSONArray();
        array.set(0, new JSONNumber(itemId));
        array.set(1, new JSONNumber(newBidValue));
        array.set(2, new JSONNumber(numberOfBids));

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

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

        }

        public void onSuccess(Object result) {

            JSONObject resultObject = (JSONObject) result;
            JSONArray resultArray = (JSONArray) resultObject.get("value");
            JSONNumber itemId = (JSONNumber) resultArray.get(0);
            JSONNumber itemPrice = (JSONNumber) resultArray.get(1);
            JSONNumber numberOfBids = (JSONNumber) resultArray.get(2);

            Integer itemKey = new Integer((int) itemId.getValue());
            ((Label) mapOfItemPrices.get(itemKey)).setText("$ " + itemPrice.toString());
            ((Label) mapOfNumberOfBids.get(itemKey)).setText("" + Double.valueOf(numberOfBids.toString()).intValue());
        }
View Full Code Here

    private void addTreeItems(Response response) {
      GWT.log(response.getText(), null);
      try {
        // parse the response text into JSON
        JSONValue jsonValue = JSONParser.parse(response.getText());
        JSONArray jsonArray = jsonValue.isArray();

        if (jsonArray != null) {
          for (int index = 0; index < jsonArray.size(); index++) {
            addTreeItem(((JSONObject) jsonArray.get(index)), index);
          }
        } else {
          throw new JSONException(
              "Invalid Json structure when retrieve the Sling nodes");
        }
View Full Code Here

    private void addProperties(Response response) {
      GWT.log(response.getText(), null);
      try {
        // parse the response text into JSON
        JSONValue jsonValue = JSONParser.parse(response.getText());
        JSONArray jsonArray = jsonValue.isArray();

        if (jsonArray != null) {
          for (int index = 0; index < jsonArray.size(); index++) {
            addProperty(((JSONObject) jsonArray.get(index)), index);
          }
        } else {
          throw new JSONException(
              "Invalid Json structure when retrieve the Sling nodes");
        }
View Full Code Here

  /**
   * Returns a table filled with data
   * @return data
   */
  private JSONArray createData() {
    JSONArray data = new JSONArray();
    JSONObject item;
   
    item = new JSONObject();
    item.put("start", new JSONNumber(dateToLong("2010-08-23")));
    item.put("content", new JSONString("<div>Conversation</div><img src='img/comments-icon.png' style='width:32px; height:32px;'>"));
    data.set(data.size(), item);
   
    item = new JSONObject();
    item.put("start", new JSONNumber(datetimeToLong("2010-08-23 23:00:00")));
    item.put("content", new JSONString("<div>Mail from boss</div><img src='img/mail-icon.png' style='width:32px; height:32px;'>"));
    data.set(data.size(), item);

    item = new JSONObject();
    item.put("start", new JSONNumber(datetimeToLong("2010-08-24 16:00:00")));
    item.put("content", new JSONString("Report"));
    data.set(data.size(), item);

    item = new JSONObject();
    item.put("start", new JSONNumber(dateToLong("2010-08-26")));
    item.put("end", new JSONNumber(dateToLong("2010-09-02")));
    item.put("content", new JSONString("Traject A"));
    data.set(data.size(), item);
   
    item = new JSONObject();
    item.put("start", new JSONNumber(dateToLong("2010-08-28")));
    item.put("content", new JSONString("<div>Memo</div><img src='img/notes-edit-icon.png' style='width:48px; height:48px;'>"));
    data.set(data.size(), item);

    item = new JSONObject();
    item.put("start", new JSONNumber(dateToLong("2010-08-29")));
    item.put("content", new JSONString("<div>Phone call</div><img src='img/Hardware-Mobile-Phone-icon.png' style='width:32px; height:32px;'>"));
    data.set(data.size(), item);

    item = new JSONObject();
    item.put("start", new JSONNumber(dateToLong("2010-08-31")));
    item.put("end", new JSONNumber(dateToLong("2010-09-03")));
    item.put("content", new JSONString("Traject B"));
    data.set(data.size(), item);

    item = new JSONObject();
    item.put("start", new JSONNumber(datetimeToLong("2010-09-04 12:00:00")));
    item.put("content", new JSONString("<div>Report</div><img src='img/attachment-icon.png' style='width:32px; height:32px;'>"));
    data.set(data.size(), item);

    return data;
  }
View Full Code Here

            JsArray<JavaScriptObject> arguments) {
        if (iface == null) {
            iface = findWildcardInterface(method);
        }

        JSONArray argumentsArray = new JSONArray(arguments);
        Object[] parameters = new Object[arguments.length()];
        for (int i = 0; i < parameters.length; i++) {
            parameters[i] = argumentsArray.get(i);
        }
        connector.getConnection().addMethodInvocationToQueue(
                new JavaScriptMethodInvocation(connector.getConnectorId(),
                        iface, method, parameters), false, false);
    }
View Full Code Here

    private void fireCallback(String name, JsArray<JavaScriptObject> arguments) {
        MethodInvocation invocation = new JavaScriptMethodInvocation(
                connector.getConnectorId(),
                "com.vaadin.ui.JavaScript$JavaScriptCallbackRpc", "call",
                new Object[] { name, new JSONArray(arguments) });
        connector.getConnection().addMethodInvocationToQueue(invocation, false,
                false);
    }
View Full Code Here

TOP

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

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.