当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.keySet方法代码示例

本文整理汇总了Java中com.google.gwt.json.client.JSONObject.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.keySet方法的具体用法?Java JSONObject.keySet怎么用?Java JSONObject.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.json.client.JSONObject的用法示例。


在下文中一共展示了JSONObject.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDefaultValues

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
 * Extracts default preference values from the gadget metadata JSON object
 * returned from GGS.
 *
 * @param prefs the preference JSON object received from GGS.
 */
public void parseDefaultValues(JSONObject prefs) {
  if (prefs != null) {
    for (String pref : prefs.keySet()) {
      if (!has(pref)) {
        JSONObject prefJson = prefs.get(pref).isObject();
        if (prefJson != null) {
          JSONValue value = prefJson.get("default");
          if ((value != null) && (value.isString() != null)) {
            put(pref, value.isString().stringValue());
            log("Gadget pref '" + pref + "' = '" + get(pref) + "'");
          }
        } else {
          log("Invalid pref '" + pref + "' value in Gadget metadata.");
        }
      }
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:GadgetUserPrefs.java

示例2: updateVariables

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private void updateVariables(JSONValue updatedVariablesJsonValue) {
    JSONObject obj = updatedVariablesJsonValue.isObject();
    if (obj != null) {
        for (String varName : obj.keySet()) {
            JobVariable variable = variables.get(varName);
            if (variable != null) {
                JSONValue variableJsonValue = obj.get(varName);
                JSONString variableJsonString = variableJsonValue.isString();
                if (variableJsonString != null) {
                    variable.setValue(variableJsonString.stringValue());
                }

            }
        }
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:17,代码来源:SubmitWindow.java

示例3: getJsonSlice

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected double[] getJsonSlice(JSONObject json, int i) {

        double[] res = new double[json.keySet().size()];

        int counter = 0;
        for (String key : json.keySet()) {
            JSONArray values = json.get(key).isArray();
            double numValue = 0;

            if (values != null) {
                JSONNumber num = values.get(i).isNumber();
                if (num != null) {
                    numValue = num.doubleValue();
                }
            }

            res[counter++] = numValue;
        }
        return res;
    }
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:21,代码来源:MBeanChart.java

示例4: processResult

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
public void processResult(String result) {

    JSONObject object = controller.parseJSON(result).isObject();
    if (object != null) {

        loadTable.removeRows(0, loadTable.getNumberOfRows());
        for (String key : object.keySet()) {
            addRow();

            double value = object.get(key).isArray().get(0).isObject().get("value").isNumber().doubleValue();
            long inMB = (long) (value / 1024);
            loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, beautifyName(key));
            loadTable.setValue(loadTable.getNumberOfRows() - 1, 1, inMB);
        }

        loadChart.draw(loadTable, loadOpts);
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:20,代码来源:DiskPieChart.java

示例5: toMap

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static Map<String, String> toMap(String jsonStr) {
  Map<String, String> map = new HashMap<String, String>();

  JSONValue parsed = JSONParser.parseStrict(jsonStr);
  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    for (String key : jsonObj.keySet()) {
      JSONValue jsonValue = jsonObj.get(key);
      JSONString jsonString = jsonValue.isString();
      // if the json value is a string, set the unescaped value, else set the json representation
      // of the value
      String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
      map.put(key, stringValue);
    }
  }

  return map;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JsonHelper.java

示例6: toMapOfLists

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static Map<String, List<String>> toMapOfLists(String jsonStr) {
  Map<String, List<String>> map = new HashMap<>();

  JSONValue parsed = JSONParser.parseStrict(jsonStr);
  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    for (String key : jsonObj.keySet()) {
      JSONValue jsonValue = jsonObj.get(key);
      JSONArray jsonArray = jsonValue.isArray();

      List<String> values = new ArrayList<>();
      for (int i = 0; i < jsonArray.size(); i++) {
        values.add(jsonArray.get(i).isString().stringValue());
      }
      map.put(key, values);
    }
  }

  return map;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:JsonHelper.java

示例7: UrlBuilder

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
 * Parse url and set initial parameters(protocol, host, port, path)<br>
 *
 * @param url
 */
public UrlBuilder(String url) {
  JavaScriptObject jso = parseUrl(url);
  o = new JSONObject(jso);
  setHost(o.get("host").isString().stringValue());
  setProtocol(o.get("protocol").isString().stringValue());
  if (o.containsKey("port")) {
    final String port = o.get("port").isString().stringValue();
    if (!port.isEmpty()) {
      setPort(Integer.valueOf(port));
    }
  }
  setPath(o.get("path").isString().stringValue());
  // fill query parameters
  JSONObject query = o.get("queryKey").isObject();
  for (String key : query.keySet()) {
    setParameter(key, query.get(key).isString().stringValue());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UrlBuilder.java

示例8: buildParts

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private void buildParts(final PanelDefinition panel,
                        final JsArray<JSPartDefinition> parts) {
    if (parts != null) {
        for (int i = 0; i < parts.length(); i++) {
            final JSPartDefinition part = parts.get(i);
            final PlaceRequest placeRequest = new DefaultPlaceRequest(part.getPlaceName());

            if (part.getParameters() != null) {
                final JSONObject json = new JSONObject(part.getParameters());
                for (final String key : json.keySet()) {
                    placeRequest.addParameter(key,
                                              json.get(key).isString().stringValue());
                }
            }

            final PartDefinition partDefinition = new PartDefinitionImpl(placeRequest);
            partDefinition.setContextDisplayMode(JSNativePerspective.this.getContextDisplayMode(part.getContextDisplayModeAsString(),
                                                                                                ContextDisplayMode.SHOW));
            if (part.getContextId() != null) {
                partDefinition.setContextDefinition(new ContextDefinitionImpl(new DefaultPlaceRequest(part.getContextId())));
            }

            panel.addPart(partDefinition);
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:JSNativePerspective.java

示例9: getLayoutDragComponent

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private LayoutDragComponent getLayoutDragComponent(JSONObject jsonObject,
                                                   String type) {
    LayoutDragComponent dragComponent = getLayoutDragComponent(type);

    if (dragComponent instanceof HasDragAndDropSettings) {
        HasDragAndDropSettings sComponent = (HasDragAndDropSettings) dragComponent;

        JSONObject params = jsonObject.get(COMPONENT_PARAMS).isObject();

        if (params != null) {
            for (String key : params.keySet()) {
                JSONString value = params.get(key).isString();
                if (value != null) {
                    sComponent.setSettingValue(key,
                                               value.stringValue());
                }
            }
        }
    }

    return dragComponent;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:DndDataJSONConverter.java

示例10: fire

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static void fire(HasDataSelectionEventHandlers source, Object sender, JavaScriptObject data) {
    DataSelectionEvent event = new DataSelectionEvent(sender);
    JSONObject array = new JSONObject(data);
    event.series = new LinkedList<Series>();
    for(String key : array.keySet()){

        JSONObject obj = array.get(key).isObject();
        if(obj != null){
            Series series1 = JavaScriptObject.createObject().cast();
            series1.setValue(obj.get("value").isNumber().doubleValue());
            series1.setColor(obj.get("fillColor").isString().stringValue());
            event.series.add(series1);
        }
    }
    source.fireEvent(event);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:DataSelectionEvent.java

示例11: parseMap

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static Map<String, String> parseMap(JSONValue jsonValue) {
	JSONObject obj = jsonValue.isObject();
	Map<String, String> map = new TreeMap<String, String>();
	
	if (obj != null) {
	
		for (String key : obj.keySet()) {
			JSONValue value = obj.get(key);

			if (value != null) {
				JSONString str = value.isString();
				
				if (str != null) {
					map.put(key, str.stringValue());
				}
			}
		}
	}
	
	return map;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:22,代码来源:JsonUtil.java

示例12: decodeItemState

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private StackMap<Integer, BookmarkProperties> decodeItemState(JSONObject object) {
    StackMap<Integer, BookmarkProperties> map = new StackMap<Integer, BookmarkProperties>();
    for (String key : object.keySet()) {
        Integer keyInt = NumberUtils.tryParseInt(key, null);
        BookmarkProperties props = BookmarkProperties.fromJSON(object.get(key));
        if (keyInt != null && props != null) {
            map.put(keyInt, props);
        }
    }
    return map;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:12,代码来源:BookmarkProcessorExtension.java

示例13: getJsonInternalSize

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected int getJsonInternalSize(JSONObject json) {

        // assuming the response structure is the following
        // {mbean1:{theonlyattr:[values]}, mbean2:{theonlyattr:[values]}, ...}

        for (String mbean : json.keySet()) {
            JSONObject attrObject = json.get(mbean).isObject();
            if (attrObject != null) {
                return super.getJsonInternalSize(attrObject);
            }
        }

        return 0;
    }
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:15,代码来源:MBeansChart.java

示例14: getJsonSlice

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected double[] getJsonSlice(JSONObject json, int i) {

        // assuming the response structure is the following
        // {mbean1:{theonlyattr:[values]}, mbean2:{theonlyattr:[values]}, ...}

        double[] res = new double[json.keySet().size()];

        int counter = 0;
        for (String mbean : json.keySet()) {
            JSONObject attrObject = json.get(mbean).isObject();

            double numValue = 0;
            if (attrObject != null) {
                for (String attr : attrObject.keySet()) {
                    JSONArray values = attrObject.get(attr).isArray();

                    if (values != null) {
                        JSONNumber num = values.get(i).isNumber();
                        if (num != null) {
                            numValue = num.doubleValue();
                        }
                    }
                    break;
                }
            }

            res[counter++] = numValue;
        }
        return res;
    }
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:31,代码来源:MBeansChart.java

示例15: getJsonInternalSize

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
protected int getJsonInternalSize(JSONObject json) {
    for (String key : json.keySet()) {
        JSONArray values = json.get(key).isArray();
        if (values != null) {
            return values.size();
        }
    }

    return 0;
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:11,代码来源:MBeanChart.java


注:本文中的com.google.gwt.json.client.JSONObject.keySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。