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


Java ObjectNode.fieldNames方法代码示例

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


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

示例1: addUpdateDependencySteps

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
protected void addUpdateDependencySteps(List<DependencyVersionChange> list, JsonNode tree, DependencySet dependencySet, String dependencyKey) {
    if (dependencySet != null) {
        Filter<String> filter = dependencySet.createFilter();
        JsonNode dependencies = tree.get(dependencyKey);
        if (dependencies instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) dependencies;
            Iterator<String> iter = objectNode.fieldNames();
            while (iter.hasNext()) {
                String field = iter.next();
                if (filter.matches(field)) {
                    String value = JsonNodes.textValue(objectNode, field);
                    if (value != null) {
                        list.add(new DependencyVersionChange(Kind.NPM, field, value, dependencyKey));
                    }
                }
            }
        }
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:20,代码来源:PackageJsonUpdater.java

示例2: parse

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
protected void parse(JsonNode tree, DependencyInfo parent) {
    for (String dependencyKey : DEPENDENCY_KEYS) {
        JsonNode deps = tree.get(dependencyKey);
        if (deps instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) deps;
            Iterator<String> iter = objectNode.fieldNames();
            while (iter.hasNext()) {
                String field = iter.next();
                JsonNode properties = objectNode.get(field);
                String version = JsonNodes.textValue(properties, "version");
                DependencyInfo dependencyInfo = getOrCreateDependencyInfo(field);
                if (parent == null) {
                    dependencyInfo.setVersion(version);
                } else {
                    dependencyInfo.addDependency(parent, version, dependencyKey);
                }
                parse(properties, dependencyInfo);
            }
        }
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:22,代码来源:DependencyTree.java

示例3: modifyReleasedVersions

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void modifyReleasedVersions(JsonNode tree, boolean recurse) {
    for (String dependencyKey : NpmDependencyKinds.DEPENDENCY_KEYS) {
        JsonNode dependencies = tree.get(dependencyKey);
        if (dependencies instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) dependencies;
            modifyReleasedVersionsChild(objectNode);


            // we are in a child dependency of a released version so lets check for
            // any transitive versions to update too
            if (recurse) {
                Iterator<String> iter = objectNode.fieldNames();
                while (iter.hasNext()) {
                    String field = iter.next();
                    JsonNode dependentPackage = objectNode.get(field);
                    if (dependentPackage != null) {
                        modifyReleasedVersions(dependentPackage, true);
                    }
                }
            }
        }
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:24,代码来源:TestNpmDependencyTreeGenerator.java

示例4: mergeObjectNodes

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode mergeObjectNodes(ObjectNode targetNode, ObjectNode updateNode) {
    Iterator<String> fieldNames = updateNode.fieldNames();
    while (fieldNames.hasNext()) {

        String fieldName = fieldNames.next();
        JsonNode targetValue = targetNode.get(fieldName);
        JsonNode updateValue = updateNode.get(fieldName);

        if (targetValue == null) {
            // Target node doesn't have this field from update node: just add it
            targetNode.set(fieldName, updateValue);

        } else {
            // Both nodes have the same field: merge the values
            if (targetValue.isObject() && updateValue.isObject()) {
                // Both values are objects: recurse
                targetNode.set(fieldName, mergeObjectNodes((ObjectNode) targetValue, (ObjectNode) updateValue));
            } else if (targetValue.isArray() && updateValue.isArray()) {
                // Both values are arrays: concatenate them to be merged later
                ((ArrayNode) targetValue).addAll((ArrayNode) updateValue);
            } else {
                // Values have different types: use the one from the update node
                targetNode.set(fieldName, updateValue);
            }
        }
    }

    return targetNode;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:SchemaGenerator.java

示例5: getJsonAttributeStream

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public static Stream<String> getJsonAttributeStream ( ObjectNode jsonTree ) {

		// handle empty lists
		if ( jsonTree == null ) {
			return (new ArrayList<String>()).stream();
		}

		Iterable<String> jsonIterable = () -> jsonTree.fieldNames();
		return StreamSupport.stream( jsonIterable.spliterator(), false );
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:11,代码来源:ServiceBaseParser.java

示例6: checkFields

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private boolean checkFields(ObjectNode node, Set<String> original) {
    Iterator<String> fieldNames = node.fieldNames();
    while (fieldNames.hasNext()) {
        String fieldName = fieldNames.next();
        if (!original.contains(fieldName) || node.get(fieldName) == null) {
            log.warn("Illegal field name: {}", fieldName);
            return false;
        }
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:SystemMetricsCollectorWebResource.java

示例7: buildApplicationReports

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public void buildApplicationReports (	boolean isUpdateSummary, int requestedSampleSize, List<String> servicesFilter,
										ObjectNode dataNode,
										int numSamples ) {
	// custom Collections
	String serviceName = servicesFilter.get( 0 );
	ObjectNode serviceCacheNode = customResultsCache
		.get( serviceName );

	String sumName = serviceName;
	int index = sumName.indexOf( "_" );
	if ( index != -1 ) {
		sumName = sumName.substring( 0, index );
	}

	//
	ObjectNode serviceSummaryJson = jacksonMapper.createObjectNode();
	if ( isUpdateSummary ) {
		// Done on a single thread
		serviceSummaryJson = _lastCustomServiceSummary.putObject( sumName );
	}

	serviceSummaryJson.put( "numberOfSamples", numSamples );

	if ( serviceCacheNode == null ) {

		logger.debug( "Warning: serviceCacheNode is null" );

	} else {

		// logger.info("**** serviceName " + serviceName);
		for ( Iterator<String> metricIdIterator = serviceCacheNode
			.fieldNames(); metricIdIterator.hasNext(); ) {

			String metricId = metricIdIterator
				.next()
				.trim();

			logger.debug( "metricId: {}", metricId );

			ArrayNode metricCacheArray = (ArrayNode) serviceCacheNode
				.get( metricId );

			ArrayNode metricResultsArray = dataNode.putArray( metricId );

			//
			if ( requestedSampleSize == -1 ) {
				metricResultsArray.addAll( metricCacheArray );
			} else {

				// summary reports as ints? maybe switch to doubles
				//
				// logger.info( "metricCacheArray size: " +
				// metricCacheArray.size() ) ;
				long metricTotal = 0;
				for ( int i = 0; i < requestedSampleSize
						&& i < metricCacheArray.size(); i++ ) {

					metricResultsArray.add( metricCacheArray.get( i ) );
					long current = metricCacheArray
						.get( i )
						.asLong();
					metricTotal += current;
				}
				serviceSummaryJson.put( metricId, metricTotal );
				logger.debug( "{}  total: {} ", metricId, metricTotal );
				// logger.info("Type: " +
				// serviceSummaryJson.get(metricId).getNodeType() ) ;
			}

		}
	}
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:73,代码来源:ServiceCollector.java

示例8: buildSummaryReport

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
protected JsonNode buildSummaryReport(boolean isSecondary) {

		// Step 1 - build map with total for services
		ObjectNode summaryTotalJson = jacksonMapper.createObjectNode();

		ArrayNode cache = summary24HourCache;
		if (isSecondary)
			cache = summary24HourApplicationCache;

		logger.debug("** intervalReports size: {}, isSecondary: {}", cache.size(), isSecondary);

		for (JsonNode intervalReport : cache) {

			Iterator<String> fields = intervalReport.fieldNames();
			while (fields.hasNext()) {

				String field = fields.next();

				ObjectNode serviceInterval = (ObjectNode) intervalReport.get(field);

				if (!summaryTotalJson.has(field))
					summaryTotalJson.putObject(field);
				ObjectNode serviceSummaryNode = (ObjectNode) summaryTotalJson.get(field);

				Iterator<String> subFields = serviceInterval.fieldNames();
				while (subFields.hasNext()) {
					String subField = subFields.next();

					// logger.info(" subField: " + subField);
					addItemToTotals(serviceInterval, serviceSummaryNode, subField);
				}

			}

		}

		// Step 2 convert to mongo aggregation friendly array
		ArrayNode summaryArray = jacksonMapper.createArrayNode();
		Iterator<String> serviceNames = summaryTotalJson.fieldNames();
		while (serviceNames.hasNext()) {
			String serviceName = serviceNames.next();
			ObjectNode serviceItem = summaryArray.addObject();
			serviceItem.put("serviceName", serviceName);

			ObjectNode serviceData = (ObjectNode) summaryTotalJson.get(serviceName);
			serviceItem.setAll(serviceData);
		}

		logger.debug("** Report: {}", summaryArray);

		return summaryArray;
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:53,代码来源:HostCollector.java

示例9: updateCustomResultCache

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public void updateCustomResultCache ( Map<String, ObjectNode> customResultCacheNode ) {

		if ( !serviceInstance.hasServiceMeters() ) {
			logger.debug( "No Meters found" );
			return;
		}

		ensureCustomCacheInitialized( customResultCacheNode );

		String serviceNamePort = serviceInstance.getServiceName_Port();
		ObjectNode serviceCustomMetricNode = customResultCacheNode.get( serviceNamePort );
		// boolean isSomeNewItems=false ;
		StringBuilder customStorage = new StringBuilder( serviceNamePort + ": \t" );
		// for ( String metricId: customMap.keySet()) {
		ServiceInstance.getJsonAttributeStream( customMap )
			.forEach( metricId -> {

				// logger.info("Adding Custom Results" + metricId) ;
				ArrayNode metricArray = (ArrayNode) serviceCustomMetricNode.get( metricId );

				if ( metricArray == null ) {
					metricArray = serviceCustomMetricNode.putArray( metricId );
					customStorage.append( metricId + ", " );
					// isSomeNewItems = true ;
					// logger.warn(serviceNamePort + " metricArray not
					// initialized for custom attribute not found in result set:
					// " + metricId ) ;
					// continue ;
				}
				if ( !customMap.has( metricId ) ) {
					logger.warn( "{} custom attribute not found in result set: {}", serviceNamePort, metricId );
					// continue ;
					metricArray.insert( 0, 0 );
				} else if ( metricArray.size() == 0 ) {
					// initialize to 0 to support sampling deltas in simon and
					// jmx delta in csap
					metricArray.insert( 0, 0 );

				} else {
					metricArray.insert( 0, customMap.get( metricId ) );
				}
				if ( metricArray.size() > inMemoryCacheSize ) {
					metricArray.remove( metricArray.size() - 1 );
				}

			} );

		Iterator<String> keyIter = serviceCustomMetricNode.fieldNames();
		while (keyIter.hasNext()) {
			String metricName = keyIter.next();

			if ( !serviceInstance.hasMeter( metricName ) ) {
				logger.warn( "{} :  Removing metricName: {} - assumed due to definition update.", serviceNamePort, metricName );
				keyIter.remove();
			}
		}

		// if ( isSomeNewItems )
		// logger.info("Custom storage allocated: " + customStorage);
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:61,代码来源:ServiceCollectionResults.java

示例10: unspecified

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm formData, HttpServletRequest request,
	HttpServletResponse response) throws Exception
{
	MainForm form = (MainForm) formData;
	setupCollections(form);
	Properties properties = new Properties();
	properties.load(getClass().getResourceAsStream("/defaults.properties"));
	BeanUtils.populate(form, properties);

	InputStream xml = null;
	try
	{
		xml = getClass().getResourceAsStream("/defaults.xml");
		if( xml != null )
		{
			Map<String, String> xmlProps = new HashMap<String, String>();
			PropBagEx pbag = new PropBagEx(xml);
			for( PropBagEx value : pbag.iterateAll("*") )
			{
				xmlProps.put(value.getNodeName(), value.getSubtree("*").toString());
			}
			BeanUtils.populate(form, xmlProps);
		}
	}
	finally
	{
		if( xml != null )
		{
			xml.close();
		}
	}

	InputStream json = null;
	try
	{
		json = getClass().getResourceAsStream("/defaults.json");
		if( json != null )
		{
			Map<String, String> jsonProps = new HashMap<String, String>();

			ObjectMapper objectMapper = new ObjectMapper();
			objectMapper.enable(SerializationFeature.INDENT_OUTPUT);

			ObjectNode obj = (ObjectNode) objectMapper.readTree(json);
			Iterator<String> fields = obj.fieldNames();
			while( fields.hasNext() )
			{
				String field = fields.next();
				JsonNode node = obj.get(field);

				jsonProps.put(field, objectMapper.writeValueAsString(node));
			}
			BeanUtils.populate(form, jsonProps);
		}
	}
	finally
	{
		if( json != null )
		{
			json.close();
		}
	}

	form.setMethod("submit");
	return mapping.findForward("main");
}
 
开发者ID:equella,项目名称:Equella,代码行数:68,代码来源:MainAction.java


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