org.apache.tapestry5.json.JSONArray.checkedPut()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.apache.tapestry5.json.JSONArray.checkedPut()方法的一些代码示例,展示了JSONArray.checkedPut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.checkedPut()方法的具体详情如下:
包路径:org.apache.tapestry5.json.JSONArray
类名称:JSONArray
方法名:checkedPut

JSONArray.checkedPut介绍

[英]Same as #put, with added validity checks.
[中]与#put相同,增加了有效性检查。

代码示例

代码示例来源:origin: apache/tapestry-5

array.checkedPut(value);
} else {
  JSONArray array = new JSONArray();
  array.checkedPut(current);
  array.checkedPut(value);
  nameValuePairs.put(name, array);

代码示例来源:origin: org.apache.tapestry/tapestry-json

array.checkedPut(value);
} else {
  JSONArray array = new JSONArray();
  array.checkedPut(current);
  array.checkedPut(value);
  nameValuePairs.put(name, array);

代码示例来源:origin: org.apache.tapestry/tapestry-json

/**
 * Appends values to the array mapped to {@code name}. A new {@link JSONArray}
 * mapping for {@code name} will be inserted if no mapping exists. If the existing
 * mapping for {@code name} is not a {@link JSONArray}, a {@link RuntimeException}
 * will be thrown.
 *
 * @param name  The name of the array to which the value should be appended.
 * @param value The value to append.
 * @return this object.
 * @throws RuntimeException if {@code name} is {@code null} or if the mapping for
 *                       {@code name} is non-null and is not a {@link JSONArray}.
 */
public JSONObject append(String name, Object value) {
  testValidity(value);
  Object current = nameValuePairs.get(checkName(name));
  final JSONArray array;
  if (current instanceof JSONArray) {
    array = (JSONArray) current;
  } else if (current == null) {
    JSONArray newArray = new JSONArray();
    nameValuePairs.put(name, newArray);
    array = newArray;
  } else {
    throw new RuntimeException("JSONObject[\"" + name + "\"] is not a JSONArray.");
  }
  array.checkedPut(value);
  return this;
}

代码示例来源:origin: apache/tapestry-5

/**
 * Appends values to the array mapped to {@code name}. A new {@link JSONArray}
 * mapping for {@code name} will be inserted if no mapping exists. If the existing
 * mapping for {@code name} is not a {@link JSONArray}, a {@link RuntimeException}
 * will be thrown.
 *
 * @param name  The name of the array to which the value should be appended.
 * @param value The value to append.
 * @return this object.
 * @throws RuntimeException if {@code name} is {@code null} or if the mapping for
 *                       {@code name} is non-null and is not a {@link JSONArray}.
 */
public JSONObject append(String name, Object value) {
  testValidity(value);
  Object current = nameValuePairs.get(checkName(name));
  final JSONArray array;
  if (current instanceof JSONArray) {
    array = (JSONArray) current;
  } else if (current == null) {
    JSONArray newArray = new JSONArray();
    nameValuePairs.put(name, newArray);
    array = newArray;
  } else {
    throw new RuntimeException("JSONObject[\"" + name + "\"] is not a JSONArray.");
  }
  array.checkedPut(value);
  return this;
}

相关文章