org.codehaus.jackson.node.ArrayNode.addAll()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(111)

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

ArrayNode.addAll介绍

[英]Method for adding given nodes as child nodes of this array node.
[中]用于将给定节点添加为此数组节点的子节点的方法。

代码示例

代码示例来源:origin: eBay/YiDB

public void addDisplayMeta(ArrayNode displayNode) {
  if (displayMeta == null) {
    displayMeta = JsonNodeFactory.instance.arrayNode();
  }
  displayMeta.addAll(displayNode);
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

private static JsonNode toJsonNode(final List<JsonNode> matching) {
  switch (matching.size()) {
  case 0:
    return NullNode.getInstance();
  case 1:
    return matching.get(0);
  default:
    final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
    arrayNode.addAll(matching);
    return arrayNode;
  }
}

代码示例来源:origin: org.apache.isis.viewer/json-applib

private static JsonNode toJsonNode(final List<JsonNode> matching) {
  switch (matching.size()) {
  case 0:
    return NullNode.getInstance();
  case 1:
    return matching.get(0);
  default:
    final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
    arrayNode.addAll(matching);
    return arrayNode;
  }
}

代码示例来源:origin: io.snamp/json-helpers

public static ArrayNode toJsonArray(final JsonNode... values){
  final ArrayNode result = ThreadLocalJsonFactory.getFactory().arrayNode();
  result.addAll(Arrays.asList(values));
  return result;
}

代码示例来源:origin: apache/helix

@GET
@Path("{instanceName}/healthreports")
public Response getHealthReportsOnInstance(@PathParam("clusterId") String clusterId,
  @PathParam("instanceName") String instanceName) throws IOException {
 HelixDataAccessor accessor = getDataAccssor(clusterId);
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 root.put(Properties.id.name(), instanceName);
 ArrayNode healthReportsNode = root.putArray(InstanceProperties.healthreports.name());
 List<String> healthReports =
   accessor.getChildNames(accessor.keyBuilder().healthReports(instanceName));
 if (healthReports != null && healthReports.size() > 0) {
  healthReportsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(healthReports));
 }
 return JSONRepresentation(root);
}

代码示例来源:origin: apache/helix

@GET
@Path("{instanceName}/resources")
public Response getResourcesOnInstance(@PathParam("clusterId") String clusterId,
  @PathParam("instanceName") String instanceName) throws IOException {
 HelixDataAccessor accessor = getDataAccssor(clusterId);
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 root.put(Properties.id.name(), instanceName);
 ArrayNode resourcesNode = root.putArray(InstanceProperties.resources.name());
 List<String> sessionIds = accessor.getChildNames(accessor.keyBuilder().sessions(instanceName));
 if (sessionIds == null || sessionIds.size() == 0) {
  return null;
 }
 // Only get resource list from current session id
 String currentSessionId = sessionIds.get(0);
 List<String> resources =
   accessor.getChildNames(accessor.keyBuilder().currentStates(instanceName, currentSessionId));
 if (resources != null && resources.size() > 0) {
  resourcesNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(resources));
 }
 return JSONRepresentation(root);
}

代码示例来源:origin: apache/helix

@GET
public Response getJobs(@PathParam("clusterId") String clusterId,
  @PathParam("workflowName") String workflowName) {
 TaskDriver driver = getTaskDriver(clusterId);
 WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflowName);
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 if (workflowConfig == null) {
  return badRequest(String.format("Workflow %s is not found!", workflowName));
 }
 Set<String> jobs = workflowConfig.getJobDag().getAllNodes();
 root.put(Properties.id.name(), JobProperties.Jobs.name());
 ArrayNode jobsNode = root.putArray(JobProperties.Jobs.name());
 if (jobs != null) {
  jobsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(jobs));
 }
 return JSONRepresentation(root);
}

代码示例来源:origin: apache/helix

@GET
public Response getResources(@PathParam("clusterId") String clusterId) {
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 root.put(Properties.id.name(), JsonNodeFactory.instance.textNode(clusterId));
 HelixZkClient zkClient = getHelixZkClient();
 ArrayNode idealStatesNode = root.putArray(ResourceProperties.idealStates.name());
 ArrayNode externalViewsNode = root.putArray(ResourceProperties.externalViews.name());
 List<String> idealStates = zkClient.getChildren(PropertyPathBuilder.idealState(clusterId));
 List<String> externalViews = zkClient.getChildren(PropertyPathBuilder.externalView(clusterId));
 if (idealStates != null) {
  idealStatesNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(idealStates));
 } else {
  return notFound();
 }
 if (externalViews != null) {
  externalViewsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(externalViews));
 }
 return JSONRepresentation(root);
}

代码示例来源:origin: apache/helix

if (partitions != null) {
 ArrayNode partitionsNode = resourcesNode.putArray(resourceName);
 partitionsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(partitions));

代码示例来源:origin: apache/helix

instancesNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(instances));
} else {
 return notFound();

相关文章