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

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

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

JSONArray.put介绍

[英]Sets the value at index to value, null padding this array to the required length if necessary. If a value already exists at index, it will be replaced.
[中]将索引处的值设置为value,如有必要,将此数组填充为null,使其达到所需的长度。如果索引中已存在值,则将替换该值。

代码示例

代码示例来源:origin: json-path/JsonPath

@Override
public void setArrayIndex(final Object array, final int index, final Object newValue) {
 Object v = newValue == null ? JSONObject.NULL : newValue;
 JSONArray list = (JSONArray) array;
 list.put(index, v);
}

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

public void addInitialization(InitializationPriority priority, String moduleName, String functionName, JSONArray arguments)
{
  assert priority != null;
  assert InternalUtils.isNonBlank(moduleName);
  String name = functionName == null ? moduleName : moduleName + ":" + functionName;
  if ((arguments == null || arguments.length() == 0))
  {
    if (pureInits.contains(name))
    {
      // A degenerate case is a pure init added repeatedly with different priorities. That isn't handled:
      // the first priority wins.
      return;
    }
    pureInits.add(name);
    InternalUtils.addToMapList(inits, priority, name);
  } else
  {
    JSONArray init = new JSONArray();
    init.put(name);
    init.putAll(arguments);
    InternalUtils.addToMapList(inits, priority, init);
  }
  initCount++;
}

代码示例来源:origin: com.jayway.jsonpath/json-path

@Override
public void setArrayIndex(final Object array, final int index, final Object newValue) {
 Object v = newValue == null ? JSONObject.NULL : newValue;
 JSONArray list = (JSONArray) array;
 list.put(index, v);
}

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

/**
 * Creates a new {@code JSONArray} with values from the given primitive array.
 *
 * @param values The values to use.
 * @throws RuntimeException if any of the values are non-finite double values (i.e. NaN or infinite)
 */
public JSONArray(Object... values) {
  this();
  for (int i = 0; i < values.length; ++i) {
    put(values[i]);
  }
}

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

/**
 * Creates a new {@code JSONArray} with values from the given primitive array.
 *
 * @param values The values to use.
 * @throws RuntimeException if any of the values are non-finite double values (i.e. NaN or infinite)
 */
public JSONArray(Object... values) {
  this();
  for (int i = 0; i < values.length; ++i) {
    put(values[i]);
  }
}

代码示例来源:origin: com.github.lafa.jsonpath/json-path

@Override
public void setArrayIndex(final Object array, final int index, final Object newValue) {
 Object v = newValue == null ? JSONObject.NULL : newValue;
 JSONArray list = (JSONArray) array;
 list.put(index, v);
}

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

public void addLibrary(String libraryURL)
{
  libraryURLs.put(libraryURL);
}

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

/**
 * Puts all objects from the collection into this JSONArray, using {@link #put(Object)}.
 *
 * @param collection
 *         List, array, JSONArray, or other iterable object, or null
 * @return this JSONArray
 * @since 5.4
 */
public JSONArray putAll(Iterable<?> collection)
{
  if (collection != null)
  {
    for (Object o : collection)
    {
      put(o);
    }
  }
  return this;
}

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

/**
 * Puts all objects from the collection into this JSONArray, using {@link #put(Object)}.
 *
 * @param collection
 *         List, array, JSONArray, or other iterable object, or null
 * @return this JSONArray
 * @since 5.4
 */
public JSONArray putAll(Iterable<?> collection)
{
  if (collection != null)
  {
    for (Object o : collection)
    {
      put(o);
    }
  }
  return this;
}

代码示例来源:origin: org.got5/tapestry5-jquery

/**
   * Transforms the matches into a JSONArray
   *
   * @return JSONArray of available responses
   */
  protected JSONArray generateResponseJSON(List matches)
  {
    JSONArray array = new JSONArray();
    for (Object o : matches)
    {
      if (o instanceof JSONObject) array.put(o);
      else array.put(o.toString());
    }
    return array;
  }
}

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

/**
 * Same as {@link #put}, with added validity checks.
 *
 * @param value The value to append.
 */
void checkedPut(Object value) {
  JSONObject.testValidity(value);
  if (value instanceof Number) {
    JSON.checkDouble(((Number) value).doubleValue());
  }
  put(value);
}

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

/**
 * Same as {@link #put}, with added validity checks.
 *
 * @param value The value to append.
 */
void checkedPut(Object value) {
  JSONObject.testValidity(value);
  if (value instanceof Number) {
    JSON.checkDouble(((Number) value).doubleValue());
  }
  put(value);
}

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

public void addScript(InitializationPriority priority, String script)
{
  addInitialization(priority, "t5/core/pageinit", "evalJavaScript", new JSONArray().put(script));
}

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

public void addStylesheetLink(StylesheetLink stylesheet)
{
  JSONObject object = new JSONObject(
      "href", stylesheet.getURL(),
      "media", stylesheet.getOptions().media);
  stylesheets.put(object);
}

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

public String getInitialJSON()
{
  JSONArray array = new JSONArray();
  for (Object o : selected)
  {
    String value = encoder.toClient(o);
    array.put(value);
  }
  return array.toString(compactJSON);
}

代码示例来源:origin: fabienrenaud/java-json-benchmark

@Override
public org.apache.tapestry5.json.JSONObject tapestry(final Users obj) throws IOException {
  org.apache.tapestry5.json.JSONObject jso = new org.apache.tapestry5.json.JSONObject();
  if (obj.users != null) {
    org.apache.tapestry5.json.JSONArray jsarr = new org.apache.tapestry5.json.JSONArray();
    for (User u : obj.users) {
      jsarr.put(tapestry(u));
    }
    jso.put("users", jsarr);
  }
  return jso;
}

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

private void addPublishEventInfo(Flow<EventHandlerMethod> eventHandlerMethods,
    MutableComponentModel model)
{
  JSONArray publishEvents = new JSONArray();
  for (EventHandlerMethod eventHandlerMethod : eventHandlerMethods)
  {
    if (eventHandlerMethod.publishEvent != null)
    {
      publishEvents.put(eventHandlerMethod.eventType.toLowerCase());
    }
  }
  
  // If we do have events to publish, we apply the mixin and pass
  // event information to it.
  if (publishEvents.length() > 0) {
    model.addMixinClassName(PublishServerSideEvents.class.getName(), "after:*");
    model.setMeta(InternalConstants.PUBLISH_COMPONENT_EVENTS_META, publishEvents.toString());
  }
}

代码示例来源:origin: org.got5/tapestry5-jquery

void beginRender(MarkupWriter writer)
{
  JSONArray selectedValues = new JSONArray();
  for (OptionModel selected : selectedOptions)
  {
    Object value = selected.getValue();
    String clientValue = encoder.toClient(value);
    selectedValues.put(clientValue);
  }
  JSONArray naturalOrder = new JSONArray();
  for (String value : this.naturalOrder)
  {
    naturalOrder.put(value);
  }
  String clientId = getClientId();
  JSONObject options = new JSONObject();
  options.put("id", clientId);
  options.put("reorder", reorder);
  options.put("naturalOrder", naturalOrder);
  javascriptSupport.require("tjq/palette").with(options);
  writer.element("input", "type", "hidden", "id", clientId + "-values", "name", getControlName() + "-values",
      "value", selectedValues);
  writer.end();
}

代码示例来源:origin: org.got5/tapestry5-jquery

if (item.getIsSeparator()) {
  keys.put("sep" + sepKeySuffix);
  jsonItems.put("sep" + sepKeySuffix, "---------");
  sepKeySuffix++;
  jsonItem.put("url", link.toAbsoluteURI());
  keys.put(item.event);
  jsonItems.put(item.event, jsonItem);

代码示例来源:origin: org.got5/tapestry5-jquery

confs.put("mDataProp", propertyName);
confs.put("bSortable", getModel().get(propertyName).isSortable());
columnConfs.put(confs);

相关文章