コード例 #1
0
  public void setEnumerationValueMapping(JSONObject target, String value) {
    JSONArray mappings = target.getJSONArray("mappings");
    JSONObject mapping = null;

    mappings.clear();
    if (value != null && value.length() > 0) {
      mapping = new JSONObject();
      mapping.put("type", "constant");
      mapping.put("value", value);
      mappings.add(mapping);
    }
  }
コード例 #2
0
  private void clearAllMappings(JSONObject object) {
    JSONArray mappings = object.getJSONArray("mappings");
    mappings.clear();

    if (object.has("attributes")) {
      JSONArray attributes = object.getJSONArray("attributes");
      for (int i = 0; i < attributes.size(); i++) {
        JSONObject a = (JSONObject) attributes.get(i);
        clearAllMappings(a);
      }
    }

    if (object.has("children")) {
      JSONArray children = object.getJSONArray("children");
      for (int i = 0; i < children.size(); i++) {
        JSONObject a = (JSONObject) children.get(i);
        clearAllMappings(a);
      }
    }
  }