Package com.google.gwt.json.client

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


    /**
     * @return the markings
     */
    public Markings getMarkings()
    {
        JSONArray array = getArray( MARKINGS_KEY );
        if ( null == array )
        {
            return null;
        }
        else
View Full Code Here


    WjrStoreMeta m = WjrStoreMeta.meta();
    WjrStore wjrStore = new WjrStore();

    JSONObject j = JSONParser.parseStrict(jsonString).isObject();

    JSONArray classItems = j.get(m.classItems).isArray();
    int classItemsSize = classItems.size();
    for (int i = 0; i < classItemsSize; i++) {
      wjrStore.addClassItem(createWjrClassItemFromJson(classItems
        .get(i)
        .toString()));
    }

    JSONArray methodItems = j.get(m.methodItems).isArray();
    int methodItemsSize = methodItems.size();
    for (int i = 0; i < methodItemsSize; i++) {
      wjrStore.addMethodItem(createWjrMethodItemFromJson(methodItems
        .get(i)
        .toString()));
    }

    return wjrStore;
View Full Code Here

        arrayObject.length = 0;
    }-*/;

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

        return str == null ? null : str.stringValue();
    }

    protected String[] getStringArray( String key )
    {
        JSONArray array = getArray( key );
        if ( array == null )
        {
            return null;
        }
        String[] result = new String[array.size()];
        for ( int i = 0; i < array.size(); i++ )
        {
            JSONString value = array.get( i ).isString();
            if ( null != value )
            {
                result[i] = value.stringValue();
            }
        }
View Full Code Here

    return jsobj;
  }

  @SuppressWarnings("unchecked")
  protected static JSONArray encodeList(List<Object> data) {
    JSONArray jsona = new JSONArray();
    for (int i = 0; i < data.size(); i++) {
      Object val = data.get(i);
      if (val instanceof ModelData) {
        jsona.set(i, encodeMap(((ModelData) val).getProperties()));
      } else if (val instanceof Map) {
        jsona.set(i, encodeMap((Map<String, Object>) val));
      } else if (val instanceof List) {
        jsona.set(i, encodeList((List<Object>) val));
      } else if (val instanceof String) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Number) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Boolean) {
        jsona.set(i, JSONBoolean.getInstance((Boolean) val));
      } else if (val == null) {
        jsona.set(i, JSONNull.getInstance());
      } else if (val instanceof Date) {
        jsona.set(i, new JSONString(encodeValue(val)));
      }
    }
    return jsona;
  }
View Full Code Here

    public static JSONObject getOptions(int min, int max, int[] defaultValues)
    {
        JSONObject options = new JSONObject();
        options.put(SliderOption.MIN.toString(), new JSONNumber(min));
        options.put(SliderOption.MAX.toString(), new JSONNumber(max));
        JSONArray vals = intArrayToJSONArray(defaultValues);
        options.put(SliderOption.VALUES.toString(), vals);
        return options;
    }
View Full Code Here

        return options;
    }

    private static JSONArray intArrayToJSONArray(int[] values)
    {
        JSONArray vals = new JSONArray();
        for (int i = 0, len = values.length; i < len; i++) {
            vals.set(i, new JSONNumber(values[i]));
        }
        return vals;
    }
View Full Code Here

         *
         * We don't want to fire multiple onChange events,
         * so we're setting this true here and w
         */
        m_firstOnChange = true;
        JSONArray vals = intArrayToJSONArray(values);
        setValuesJS(getElement().getId(), vals.getJavaScriptObject());
    }
View Full Code Here

    protected void handleQueryResponse(RESTObjectCallBack<OptionResultSet> callback, JSONValue val)
    {
        JSONObject obj = val.isObject();
        int totSize = JSONUtil.getIntValue(obj, m_helper.getTotalSizeKey());
        OptionResultSet options = new OptionResultSet(totSize);
        JSONArray optionsArray = JSONUtil.getJSONArray(obj, m_helper.getOptionsKey());

        if (options.getTotalSize() > 0 && optionsArray != null) {

            for (int i = 0; i < optionsArray.size(); i++) {
                if (optionsArray.get(i) == null) {
                    /*
                     This happens when a JSON array has an invalid trailing comma
                     */
                    continue;
                }

                JSONObject jsonOpt = optionsArray.get(i).isObject();
                Option option = createOption(jsonOpt);
                options.addOption(option);
            }
        }
        callback.success(options);
View Full Code Here

     */
    public static JSONArray getJSONArray(JSONObject obj, String key)
    {
        JSONValue v = obj.get(key);
        if (v != null) {
            JSONArray a = v.isArray();
            if (a != null) {
                return a;
            }
        }
       
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.