本文整理匯總了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;
}