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


Java ArrayNode.size方法代码示例

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


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

示例1: addToArray

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
static JsonNode addToArray(final JsonPointer path, final JsonNode node, final JsonNode value) {
    final ArrayNode target = (ArrayNode) node.at(path.head());
    final String rawToken = path.last().getMatchingProperty();

    if (rawToken.equals(LAST_ARRAY_ELEMENT)) {
        target.add(value);
        return node;
    }

    final int size = target.size();
    final int index;
    try {
        index = Integer.parseInt(rawToken);
    } catch (NumberFormatException ignored) {
        throw new JsonPatchException("not an index: " + rawToken + " (expected: a non-negative integer)");
    }

    if (index < 0 || index > size) {
        throw new JsonPatchException("index out of bounds: " + index +
                                     " (expected: >= 0 && <= " + size + ')');
    }

    target.insert(index, value);
    return node;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:26,代码来源:AddOperation.java

示例2: generateNagiosPassiveMonitors

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
static private String generateNagiosPassiveMonitors(String monitor, String host, String modelShortName) {

		StringBuilder nagiosHostServiceDefinition = new StringBuilder();
		nagiosHostServiceDefinition.append("\ndefine service{");
		nagiosHostServiceDefinition.append("\n\t use \t\t generic-service");
		nagiosHostServiceDefinition.append("\n\t host_name \t " + host);
		nagiosHostServiceDefinition.append("\n\t service_description \t  Csap_" + monitor);
		nagiosHostServiceDefinition.append("\n\t check_command \t  " + modelShortName + "_" + monitor);
		ArrayNode nagiosOptionsFromCsapDefn = getNagiosOptionsFromCsapDefn();
		if (nagiosOptionsFromCsapDefn != null && nagiosOptionsFromCsapDefn.size() > 0) {
			for (JsonNode configLine : nagiosOptionsFromCsapDefn) {
				if (configLine.asText().contains("active_checks_enabled"))
					continue;
				nagiosHostServiceDefinition.append("\n\t " + configLine.asText());
			}
		} else {
			nagiosHostServiceDefinition.append("\n\t passive_checks_enabled \t  1");
		}
		nagiosHostServiceDefinition.append("\n\t active_checks_enabled  \t  0");
		nagiosHostServiceDefinition.append("\n\t }\n\n");

		return nagiosHostServiceDefinition.toString();
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:24,代码来源:NagiosIntegration.java

示例3: updateMetricData

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private ObjectNode updateMetricData(long nowMs, String hostName, ObjectNode testData) {
	ObjectNode data;
	data = testData.deepCopy(); // copy test data, modify it

	ObjectNode attNode = (ObjectNode) data.path( "attributes" );
	attNode.put( "hostName", hostName );
	attNode.put( "currentTimeMillis", nowMs );

	ArrayNode timeStamps = (ArrayNode) data.path( "data" ).path( "timeStamp" );
	for (int i = 0; i < timeStamps.size(); i++) {
		long offset = i * 30000; // timeStamps in reverse order LIFO. latest
									// time is first
		timeStamps.set( i, LongNode.valueOf( nowMs - offset ) );
	}
	return data;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:17,代码来源:Agent_Capacity_Tests.java

示例4: string2Map

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Десериализатор TreeNode массива в Map где четный элемент ключ а не четный
 * значение
 * 
 * @param <T>
 *            тип ключя карты
 * @param <V>
 *            тип значения карты
 * @param node
 *            узел
 * @param keyClass
 *            класс для ключа карты
 * @param valueClass
 *            класс для значения карты
 * @throws IOException
 *             исключение парсера
 * @return карта
 */
private static <T, V> Map<T, V> string2Map(TreeNode node, Class<T> keyClass, Class<V> valueClass)
		throws IOException {
	ObjectMapper mapper = new ObjectMapper();
	Map<T, V> ret = new HashMap<T, V>();
	if (node.isArray()) {
		T key = null;
		ArrayNode key2value = (ArrayNode) node;
		for (int i = 0; i < key2value.size(); i++) {
			if (i % 2 == 0) {
				key = mapper.treeToValue(key2value.get(i), keyClass);
			} else {
				V value = mapper.treeToValue(key2value.get(i), valueClass);
				ret.put(key, value);
			}
		}
	}
	return ret;
}
 
开发者ID:onixred,项目名称:golos4j,代码行数:37,代码来源:Util.java

示例5: saveFiles

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
protected void saveFiles(final ItemId itemId, File filesDir) throws IOException
{
	ObjectNode files = itemRequests.listFiles(itemId);
	ArrayNode fileList = files.withArray("files");
	if( fileList.size() > 0 )
	{
		filesDir.mkdirs();
		for( JsonNode file : fileList )
		{
			final String name = file.get("name").asText();
			ByteSource src = new ByteSource()
			{
				@Override
				public InputStream openStream() throws IOException
				{
					return itemRequests.file(itemRequests.successfulRequest(), itemId, name).body().asInputStream();
				}
			};
			File destFile = new File(filesDir, name);
			destFile.getParentFile().mkdirs();
			src.copyTo(Files.asByteSink(destFile));
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:SaveInstitutionToFile.java

示例6: deserialize

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
@Override
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
    throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  if (node instanceof ArrayNode) {
    ArrayNode arrayNode = (ArrayNode) node;
    ArrayList<String> ret = new ArrayList<>();
    for (int i = 0; i < arrayNode.size(); i++) {
      ret.add(arrayNode.get(i).textValue());
    }
    return ret.toArray(new String[0]);
  } else {
    return new String[]{node.textValue()};
  }

}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:18,代码来源:StringArrayOrElementStringDeserializer.java

示例7: deserialize

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
@Override
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
    throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  if (node instanceof ArrayNode) {
    ArrayNode arrayNode = (ArrayNode) node;
    ArrayList<String> ret = new ArrayList<>();
    for (int i = 0; i < arrayNode.size(); i++) {
      ret.add(arrayNode.get(i).textValue());
    }
    return ret;
  } else {
    return Arrays.asList(node.textValue());
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:17,代码来源:StringListOrElementDeserializer.java

示例8: readList

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
protected Object readList(ListSchema schema, JsonNode node) {
    List list = Lists.newArrayList();
    ArrayNode arrayNode = (ArrayNode) node;
    for (int i = 0; i < arrayNode.size(); i++) {
        JsonNode val = arrayNode.get(i);
        list.add(getNodeData(schema.getValueSchema(), val));
    }
    return list;
}
 
开发者ID:atlascon,项目名称:travny,代码行数:10,代码来源:JsonReader.java

示例9: parseJson

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public Query parseJson(String queryName, ObjectNode fullQuery) throws QueryException {
	Query query = new Query(queryName, packageMetaData);
	if (fullQuery.has("defines")) {
		JsonNode defines = fullQuery.get("defines");
		if (defines instanceof ObjectNode) {
			parseDefines(query, (ObjectNode)fullQuery.get("defines"));
		} else {
			throw new QueryException("\"defines\" must be of type object");
		}
	}
	if (fullQuery.has("queries")) {
		JsonNode queriesNode = fullQuery.get("queries");
		if (queriesNode instanceof ArrayNode) {
			ArrayNode queries = (ArrayNode) fullQuery.get("queries");
			if (queries.size() == 0) {
				throw new QueryException("\"queries\" must contain at least one query");
			}
			for (int i=0; i<queries.size(); i++) {
				parseJsonQuery(query, (ObjectNode)queries.get(i));
			}
		} else {
			throw new QueryException("\"queries\" must be of type array");
		}
	} else if (fullQuery.has("query")) {
		JsonNode queryNode = fullQuery.get("query");
		if (queryNode instanceof ObjectNode) {
			parseJsonQuery(query, (ObjectNode) fullQuery.get("query"));
		} else {
			throw new QueryException("\"query\" must be of type object");
		}
	} else if (!fullQuery.has("defines")) {
		parseJsonQuery(query, fullQuery);
	}
	return query;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:36,代码来源:JsonQueryObjectModelConverter.java

示例10: getInterfaces

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Returns the list of interfaces enabled on this router.
 *
 * @return list of interface names that are enabled, or an empty list if
 * all available interfaces should be used
 */
public List<String> getInterfaces() {
    JsonNode intfNode = object.path(INTERFACES);
    if (intfNode.isMissingNode() || !intfNode.isArray()) {
        return Collections.emptyList();
    }
    ArrayNode array = (ArrayNode) intfNode;
    List<String> interfaces = new ArrayList<>(array.size());
    for (JsonNode intf : array) {
        interfaces.add(intf.asText());
    }
    return interfaces;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:RouterConfig.java

示例11: validateFilters

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private void validateFilters(JsonNode filtersJson) {
    if (filtersJson == null || filtersJson.isNull()) {
        throw new IncorrectParameterException("Rule filters are required!");
    }
    if (!filtersJson.isArray()) {
        throw new IncorrectParameterException("Filters json is not an array!");
    }
    ArrayNode filtersArray = (ArrayNode) filtersJson;
    for (int i = 0; i < filtersArray.size(); i++) {
        validateComponentJson(filtersArray.get(i), ComponentType.FILTER);
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:13,代码来源:BaseRuleService.java

示例12: getGroups

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
@NotNull
private static ArrayNode getGroups(@NotNull JsonNode node) {
    @NotNull final ArrayNode groups = requireArrayValue(node, GROUPS_NAME);
    if (groups.size() == 0) {
        throw new RuntimeException("Value of groups is an empty array. At least one group is required.");
    }
    return groups;
}
 
开发者ID:mgrand,项目名称:crypto-shuffle,代码行数:9,代码来源:JsonUtil.java

示例13: resolveArrayNode

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private JsonNode resolveArrayNode(LogEvent event, JsonNode srcNode) {
    ArrayNode dstNode = objectMapper.createArrayNode();
    for (int nodeIndex = 0; nodeIndex < srcNode.size(); nodeIndex++) {
        JsonNode srcChildNode = srcNode.get(nodeIndex);
        JsonNode dstChildNode = resolveNode(event, srcChildNode);
        if (dstChildNode != null) {
            dstNode.add(dstChildNode);
        }
    }
    return dstNode.size() > 0 ? dstNode : null;
}
 
开发者ID:vy,项目名称:log4j2-logstash-layout,代码行数:12,代码来源:TemplateRenderer.java

示例14: removeSpeaker

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Removes BGP speaker from configuration.
 *
 * @param speakerName BGP speaker name
 */
public void removeSpeaker(String speakerName) {
    ArrayNode speakersArray = (ArrayNode) object.get(SPEAKERS);

    for (int i = 0; i < speakersArray.size(); i++) {
        if (speakersArray.get(i).hasNonNull(NAME) &&
                speakersArray.get(i).get(NAME).asText().equals(speakerName)) {
            speakersArray.remove(i);
            return;
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:BgpConfig.java

示例15: handleTabbedFields

import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private ObjectNode handleTabbedFields(ObjectMapper mapper, Field[] declaredFields, Map<Field, JsonNode> nodes) {
	Predicate<? super Field> checkTabAnnotation = field -> field.isAnnotationPresent(Tab.class);

	Comparator<? super Field> tabIndexComparator = (field1, field2) -> Integer
			.compare(field1.getAnnotation(Tab.class).index(), field2.getAnnotation(Tab.class).index());

	Comparator<? super Field> fieldIndexComparator = (entry1, entry2) -> {
		Index field1Index = entry1.getAnnotation(Index.class);
		Index field2Index = entry2.getAnnotation(Index.class);
		return Integer.compare((field1Index != null ? field1Index.value() : Integer.MAX_VALUE),
				field2Index != null ? field2Index.value() : Integer.MAX_VALUE);
	};

	Map<String, List<JsonNode>> groupedFieldsByTab = new LinkedHashMap<>();

	Arrays.stream(declaredFields).filter(checkTabAnnotation).sorted(fieldIndexComparator).sorted(tabIndexComparator)
			.forEach(field -> groupFieldsByTab(nodes, field, groupedFieldsByTab));

	ArrayNode tabs = mapper.createArrayNode();

	groupedFieldsByTab.entrySet().stream().forEachOrdered(tabElements -> {
		ObjectNode tabNode = mapper.createObjectNode();
		tabNode.put(KEY_TITLE, tabElements.getKey());
		ArrayNode tabItems = mapper.createArrayNode();
		tabElements.getValue().stream().forEach(tabItems::add);
		tabNode.set(KEY_ITEMS, tabItems);
		tabs.add(tabNode);
	});
	if (tabs.size() > 0) {
		ObjectNode tabsNode = mapper.createObjectNode();
		tabsNode.put(KEY_TYPE, KEY_TABS);
		tabsNode.set(KEY_TABS, tabs);
		return tabsNode;
	}
	return null;

}
 
开发者ID:JsonSchema-JavaUI,项目名称:sf-java-ui,代码行数:38,代码来源:UiFormSchemaGenerator.java


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