Package com.google.gwt.json.client

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


  private static native void clearJavaScriptArray(JavaScriptObject arrayObject) /*-{
        arrayObject.length = 0;
       }-*/;

  protected JSONArrayWrapper() {
    m_jsonArray = new JSONArray();
    m_currentIndex = -1;
  }
View Full Code Here


  protected PlotItem(JSONObject obj) {
    super(obj);
  }

  public DataPoint getDataPoint() {
    JSONArray array = getArray(DATAPOINT);
    if (array == null) {
      return null;
    }
    return new DataPoint(array);
  }
View Full Code Here

    try {
      JSONValue val = JSONParser.parseStrict(value);
      if (val == null) {
        return EMPTYLIST;
      }
      JSONArray arr = val.isArray();
      if (arr == null) {
        throw new RuntimeException("unrecognized payload" + val.toString());
      }
      ArrayList<MarshalledMessage> list = new ArrayList<MarshalledMessage>(arr.size());
      for (int i = 0; i < arr.size(); i++) {
        list.add(new MarshalledMessageImpl((JSONObject) arr.get(i)));
      }

      return list;
    }
    catch (Exception e) {
View Full Code Here

   public final String getOptionType(String name)
   {
      if (!hasOption(name))
         return null;

      JSONArray arr = new JSONArray(getOptionTypeNative(name));;
      if (arr.size() == 1)
         return arr.get(0).isString().stringValue();
      else
         return "list";
   }
View Full Code Here

         return "list";
   }
  
   public final ArrayList<String> getOptionValues(String name)
   {
      JSONArray arr = new JSONArray(getOptionTypeNative(name));
      ArrayList<String> values = new ArrayList<String>();
      for (int i=0; i<arr.size(); i++)
      {
         JSONArray array = arr.get(i).isArray();
         if (array == null)
            break;

         if (array.size() == 0)
            break;

         JSONString string = array.get(0).isString();
         if (string == null)
            break;

         values.add(string.stringValue());
      }
View Full Code Here

    }
    else if (v1.getClass() != v2.getClass()) {
      return false;
    }
    else if (v1.isArray() != null) {
      JSONArray a1 = v1.isArray();
      JSONArray a2 = v2.isArray();
      if (a1.size() != a2.size()) {
        return false;
      }
      for (int i = 0, n = a1.size(); i < n; i++) {
        if (!equals(a1.get(i), a2.get(i))) {
          return false;
        }
      }
      return true;
    }
View Full Code Here

    ErraiEntityType<E> attrEntityType = eem.getMetamodel().entity(attributeType);
    if (attrEntityType == null) {
      throw new IllegalArgumentException("Can't make a reference to collection of non-entity-typed attributes " + attr);
    }

    JSONArray array = new JSONArray();
    int index = 0;
    for (E element : (Iterable<E>) attrValue) {
      Object idToReference = attrEntityType.getId(Object.class).get(element);
      JSONObject ref = new JSONObject();
      ref.put("entityReference", JsonUtil.basicValueToJson(idToReference));
      array.set(index++, ref);
    }
    return array;
  }
View Full Code Here

    if (val == null || val.isArray() == null) {
      throw new RuntimeException("illegal payload: must be JSONArray");
    }

    final JSONArray jsonArray = val.isArray();
    final List<Message> messageList = new ArrayList<Message>(jsonArray.size());
    for (int i = 0; i < jsonArray.size(); i++) {
       messageList.add(decodeCommandMessage(GWTJSON.wrap(jsonArray.get(i))));
    }

    return messageList;
  }
View Full Code Here

  }
  public void startTutorial(){
    toNextStep();
  }
  private void parseSteps(JsonFile jsonConfigs,TaskHandler[] handlers){
    JSONArray stepConfigs=jsonConfigs.getJsonValue().isObject().get("tutorial_steps").isArray();
    this.steps=new Step[stepConfigs.size()];
    JSONObject jsonStep;
    for(int i=0;i<steps.length;i++){
      jsonStep=stepConfigs.get(i).isObject();
      this.steps[i]=new Step(jsonStep.get(Step.TITLE_KEY).isString().stringValue(),
          (int)jsonStep.get(Step.CORNER_X_KEY).isNumber().doubleValue(),
          (int)jsonStep.get(Step.CORNER_Y_KEY).isNumber().doubleValue(),
          parseTasks(jsonStep), handlers[i]);
    }
View Full Code Here

    this.height = bounds.get("height").isNumber().doubleValue();
   
    JSONObject camera=jsonContext.get("camera").isObject();
    this.viewPoint = new Point(camera.get(X).isNumber().doubleValue(),
                   camera.get(Y).isNumber().doubleValue());
    JSONArray defs;
    int i;
   
    defs=jsonContext.get("areaDefs").isArray();
    areaDefs=new String[defs.size()];
    for(i=0;i<areaDefs.length;i++){
      areaDefs[i]=defs.get(i).isString().stringValue();
    }
   
    defs=jsonContext.get("lineDefs").isArray();
    lineDefs=new String[defs.size()];
    for(i=0;i<lineDefs.length;i++){
      lineDefs[i]=defs.get(i).isString().stringValue();
    }
   
    defs=jsonContext.get("dotDefs").isArray();
    dotDefs=new String[defs.size()];
    for(i=0;i<dotDefs.length;i++){
      dotDefs[i]=defs.get(i).isString().stringValue();
    }
   
   
  }
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.