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


Java ArrayNode.elements方法代码示例

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


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

示例1: isArrayNodeSubset

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Returns true if expected is a subset of returned
 *
 * This is used for JSON serialiser comparisons.
 *
 * @param expected
 * @param returned
 * @return
 */
protected boolean isArrayNodeSubset(ArrayNode expected, ArrayNode returned) {

    Iterator<JsonNode> expectedChildren = expected.elements();
    Iterator<JsonNode> returnedChildren = returned.elements();

	for (JsonNode en; expectedChildren.hasNext();) {
		en = expectedChildren.next();

	    Boolean found = false;
		for (JsonNode en2; returnedChildren.hasNext();) {
			en2 = returnedChildren.next();
			if (isJsonNodeSubset(en, en2)) {
				found = true;

				// We want to be able to test for duplicates.
				returnedChildren.remove();
				break;
			}
		}
		if (!found) {
			// Can't use lower-down errors here, as I don't know which
			// item was the closest match.
			errorDescription = "Array does not contain expected value: " + en.toString();
			return false;
		}

		// Reset iterator to beginning (with removed elements).
		returnedChildren = returned.elements();
    }

	return true;
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:42,代码来源:SubsetStatus.java

示例2: initLookupMap

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private void initLookupMap(ObjectNode map) {
    ArrayNode array = (ArrayNode) map.get(KEY_SSID_MAP);
    Iterator<JsonNode> iter = array.elements();
    StringBuilder msg = new StringBuilder();
    while (iter.hasNext()) {
        ObjectNode node = (ObjectNode) iter.next();
        String ssidStr = node.get(KEY_SSID).asText();
        int ssid = Integer.valueOf(ssidStr);
        int subId = node.get(KEY_SUB_ID).asInt();
        LOOKUP.put(ssid, subId);
        msg.append(String.format("\n..binding SSID %s to sub-id %s", ssid, subId));
    }
    log.info(msg.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:CordModelCache.java

示例3: statusRecovery

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Recovers from XOS record. Re-sets up the mapping between private IP
 * address and public IP address, re-calculates intents and re-installs
 * those intents.
 */
private void statusRecovery() {
    log.info("vBNG starts to recover from XOS record......");
    ObjectNode map;
    try {
        RestClient restClient =
                new RestClient(vbngConfigurationService.getXosIpAddress(),
                        vbngConfigurationService.getXosRestPort());
        map = restClient.getRest();
    } catch (Exception e) {
        log.error("Could not contact XOS", e);
        return;
    }
    if (map == null) {
        log.info("Stop to recover vBNG status due to the vBNG map "
                + "is null!");
        return;
    }

    log.info("Get record from XOS: {}", map);

    ArrayNode array = (ArrayNode) map.get(VBNG_MAP_NAME);
    Iterator<JsonNode> entries = array.elements();
    while (entries.hasNext()) {
        ObjectNode entry = (ObjectNode) entries.next();

        IpAddress hostIpAdddress =
                IpAddress.valueOf(entry.get("private_ip").asText());
        IpAddress publicIpAddress =
                IpAddress.valueOf(entry.get("routeable_subnet").asText());
        MacAddress macAddress =
                MacAddress.valueOf(entry.get("mac").asText());
        String hostName = entry.get("hostname").asText();

        // Create vBNG
        createVbng(hostIpAdddress, publicIpAddress, macAddress, hostName);

    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:44,代码来源:VbngManager.java

示例4: deserialize

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
@Override
public AttributeValueDto deserialize(JsonParser jp, DeserializationContext ctxt)
    throws IOException, JsonProcessingException {
  JsonToken currentToken = jp.getCurrentToken();
  if (currentToken != null) {
    switch (currentToken) {
      case VALUE_NUMBER_INT:
      case VALUE_NUMBER_FLOAT:
        return new DoubleAttributeValueDto(jp.getDoubleValue());
      case VALUE_STRING:
        return new StringAttributeValueDto(jp.getText());
      case VALUE_TRUE:
        return new BooleanAttributeValueDto(jp.getBooleanValue());
      case VALUE_FALSE:
        return new BooleanAttributeValueDto(jp.getBooleanValue());
      case START_ARRAY: {
        ArrayAttributeValueDto arrayValue = null;
        ObjectMapper mapper = new ObjectMapper();
        ArrayNode arrayNode = mapper.readTree(jp);
        Iterator<JsonNode> it = arrayNode.elements();
        JsonNodeType arrayElemType = null;
        while (it.hasNext()) {
          JsonNode node = it.next();
          if (arrayValue == null) {
            // get the first element type
            arrayElemType = node.getNodeType();
            switch (arrayElemType) {
              case STRING:
                arrayValue = new ArrayOfStringsAttributeValueDto();
                break;
              case NUMBER:
                arrayValue = new ArrayOfDoublesAttributeValueDto();
                break;
              default:
                throw new UnsupportedOperationException(
                    "Unsupported array attribute items type.");
            }
          } else if (arrayElemType != node.getNodeType()) {
            String errString = String.format(
                "Array doesn't support different element types!Expected:{}, Found:{} ",
                arrayElemType, node.getNodeType());
            LOGGER.warn(errString);
            throw new UnsupportedOperationException(errString);
          }
          switch (arrayElemType) {
            case STRING:
              ((ArrayOfStringsAttributeValueDto) arrayValue).add(node.asText());
              break;
            case NUMBER:
              ((ArrayOfDoublesAttributeValueDto) arrayValue).add(node.asDouble());
              break;
            default:
              break;
          }
        }
        return arrayValue;
      }

      default:
        break;
    }
  }

  throw new UnsupportedOperationException("Not supported attribute value yet.");
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:66,代码来源:AttributeValueDeserializer.java

示例5: getSelectNonRoot

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private String getSelectNonRoot(ArrayNode jsonQuery, Set<String> input, String rootType) {


        JsonNode firstField = jsonQuery.elements().next();
        String graphID = ((SPARQLEndpointService) schema.getTypes().get(rootType).getFields().get(firstField.get("name").asText()).getService()).getGraph();
        String parentId = firstField.get("parentId").asText();
        String valueSTR = valuesSTR(parentId, input);

        Iterator<JsonNode> queryFieldsIterator = jsonQuery.elements();

        String whereClause = "";

        while (queryFieldsIterator.hasNext()) {

            JsonNode field = queryFieldsIterator.next();

            String subquery = getFieldSubquery(field);

            whereClause += subquery;
        }

        String selectQuery = selectQuerySTR(valueSTR + whereClause, graphID);

        return selectQuery;

    }
 
开发者ID:semantic-integration,项目名称:hypergraphql,代码行数:27,代码来源:SPARQLServiceConverter.java


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