本文整理汇总了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;
}
示例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());
}
示例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);
}
}
示例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.");
}
示例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;
}