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


Java ObjectNode.has方法代码示例

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


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

示例1: setInPath

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void setInPath(ObjectNode obj, JsonPointer path, JsonNode value) {
	String key = path.getMatchingProperty();
	path = path.tail();
	if (path.matches()) {
		if (!obj.has(key)) {
			obj.set(key, value);
		} else if (canMerge(obj, value, key)) {
			merge(obj, value, key);
		} else if (canAdd(obj, value)) {
			add(obj, value);
		} else {
			throw badStructure();
		}
	} else {
		obj = obj.has(key) ? (ObjectNode) obj.get(key) : obj.putObject(key);
		setInPath(obj, path, value);
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:19,代码来源:JsonPath.java

示例2: serviceHttpCollection

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ResponseEntity<String> serviceHttpCollection ( String serviceName, ObjectNode httpConfig )
		throws IOException {
	String httpCollectionUrl = httpConfig
		.get( "httpCollectionUrl" )
		.asText();

	JsonNode user = httpConfig.get( "user" );
	JsonNode pass = httpConfig.get( "pass" );

	if ( httpConfig.has( Application.getCurrentLifeCycle() ) ) {
		user = httpConfig
			.get( Application.getCurrentLifeCycle() )
			.get( "user" );
		pass = httpConfig
			.get( Application.getCurrentLifeCycle() )
			.get( "pass" );
	}
	RestTemplate localRestTemplate = getRestTemplate( serviceCollector.getMaxCollectionAllowedInMs(), user,
		pass, serviceName + " collection password" );

	ResponseEntity<String> collectionResponse;

	if ( Application.isRunningOnDesktop() && httpCollectionUrl.startsWith( "classpath" ) ) {
		File stubResults = new File( getClass()
			.getResource( httpCollectionUrl.substring( httpCollectionUrl.indexOf( ":" ) + 1 ) )
			.getFile() );

		logger.warn( "******** Application.isRunningOnDesktop() - using: " + stubResults
			.getAbsolutePath() );
		collectionResponse = new ResponseEntity<String>( FileUtils.readFileToString( stubResults ),
			HttpStatus.OK );

	} else {
		collectionResponse = localRestTemplate.getForEntity( httpCollectionUrl, String.class );
		// logger.debug("Raw Response: \n{}",
		// collectionResponse.toString());
	}
	return collectionResponse;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:40,代码来源:HttpCollector.java

示例3: decode

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public ConnectPoint decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    ElementId elementId;
    if (json.has(ELEMENT_DEVICE)) {
        elementId = DeviceId.deviceId(json.get(ELEMENT_DEVICE).asText());
    } else if (json.has(ELEMENT_HOST)) {
        elementId = HostId.hostId(json.get(ELEMENT_HOST).asText());
    } else {
        // invalid JSON
        return null;
    }
    PortNumber portNumber = portNumber(json.get(PORT).asText());
    return new ConnectPoint(elementId, portNumber);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ConnectPointCodec.java

示例4: alertsForHostMemory

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void alertsForHostMemory (	ObjectNode hostStatsNode, String hostName, ArrayNode errorArray,
									ObjectNode errorsFoundJson ) {
	if ( hostStatsNode.has( "memoryAggregateFreeMb" ) ) {
		int minFree = csapApp.lifeCycleSettings()
			.getMinFreeMemoryMb( hostName );
		int freeMem = hostStatsNode
			.path( "memoryAggregateFreeMb" )
			.asInt();

		logger.debug( "freeMem: {} , minFree: {}", freeMem, minFree );

		if ( freeMem < minFree ) {
			String message = hostName + ": " + " available memory " + freeMem
					+ " < min configured: " + minFree;
			errorArray.add( message );

			addNagiosStateMessage( errorsFoundJson, "memory", MetricsPublisher.NAGIOS_WARN, message );
		}
	} else {
		errorArray.add( hostName + ": "
				+ "Host response missing attribute: hostStats.memoryAggregateFreeMb" );
	}
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:24,代码来源:HostAlertProcessor.java

示例5: addItemToTotals

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * jackson apis do not store longs natively...so we need to iterate over
 *  data types.
 * @param itemJson
 * @param summaryJson
 * @param fieldName 
 */
protected void addItemToTotals(ObjectNode itemJson, ObjectNode summaryJson, String fieldName) {
	 logger.debug( "fieldName: {} int: {}, long: {}", fieldName ,itemJson.get(fieldName).isInt(), itemJson.get(fieldName).isLong() ) ;
	if (!summaryJson.has(fieldName) || fieldName.endsWith("Avg")) {
		if (itemJson.get(fieldName).isInt() || itemJson.get(fieldName).isLong())
			summaryJson.put(fieldName, itemJson.get(fieldName).asLong());
		
		else
			summaryJson.put(fieldName, itemJson.get(fieldName).asDouble());
		
	} else {
		if (itemJson.get(fieldName).isInt() || itemJson.get(fieldName).isLong())
			summaryJson.put(fieldName, itemJson.get(fieldName).asLong()
					+ summaryJson.get(fieldName).asLong());
		else
			summaryJson.put(fieldName,
					itemJson.get(fieldName).asDouble() + summaryJson.get(fieldName).asDouble());
	}

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

示例6: isV1ImageService

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private boolean isV1ImageService(ObjectNode node) {
  String profile;
  if (node.has("profile")) {
    profile = node.get("profile").asText();
  } else if (node.has("dcterms:conformsTo")) {
    profile = node.get("dcterms:conformsTo").asText();
    profile = profile.replace("conformance", "compliance");
  } else {
    return false;
  }
  return ImageApiProfile.V1_PROFILES.contains(profile);
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:13,代码来源:ServiceDeserializer.java

示例7: getManifestTemplateFromJson

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Instantiates a {@link ManifestTemplate} from a JSON string. This checks the {@code
 * schemaVersion} field of the JSON to determine which manifest version to use.
 */
private T getManifestTemplateFromJson(String jsonString)
    throws IOException, UnknownManifestFormatException {
  ObjectNode node = new ObjectMapper().readValue(jsonString, ObjectNode.class);
  if (!node.has("schemaVersion")) {
    throw new UnknownManifestFormatException("Cannot find field 'schemaVersion' in manifest");
  }

  if (!manifestTemplateClass.equals(ManifestTemplate.class)) {
    return JsonTemplateMapper.readJson(jsonString, manifestTemplateClass);
  }

  int schemaVersion = node.get("schemaVersion").asInt(-1);
  if (schemaVersion == -1) {
    throw new UnknownManifestFormatException("`schemaVersion` field is not an integer");
  }

  if (schemaVersion == 1) {
    return manifestTemplateClass.cast(
        JsonTemplateMapper.readJson(jsonString, V21ManifestTemplate.class));
  }
  if (schemaVersion == 2) {
    return manifestTemplateClass.cast(
        JsonTemplateMapper.readJson(jsonString, V22ManifestTemplate.class));
  }
  throw new UnknownManifestFormatException(
      "Unknown schemaVersion: " + schemaVersion + " - only 1 and 2 are supported");
}
 
开发者ID:GoogleCloudPlatform,项目名称:minikube-build-tools-for-java,代码行数:32,代码来源:ManifestPuller.java

示例8: childrenOf

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private Set<String> childrenOf(ObjectNode value) {
  Set<String> children = new HashSet<>();

  if (value.has(SAGA_CHILDREN)) {
    value.get(SAGA_CHILDREN)
        .forEach(node -> children.add(node.textValue()));
  }

  return children;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:11,代码来源:ChildrenExtractor.java

示例9: generateNagiosActiveMonitors

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
static private String generateNagiosActiveMonitors(ServiceInstance instance) {

		StringBuilder nagiosHostServiceDefinition = new StringBuilder();
		ObjectNode monitors = instance.getMonitors();

		logger.debug("{} monitor: {}", instance.getServiceName(), monitors);

		if (monitors != null && monitors.has("nagiosCommand")) {
			String command = monitors.get("nagiosCommand").asText();
			if (command.indexOf("-p") == -1)
				command += " -p " + instance.getPort();

			nagiosHostServiceDefinition.append("\n#\n#\t Active checks for " + instance.getServiceName()
					+ "\n#");
			nagiosHostServiceDefinition.append("\ndefine service{");
			nagiosHostServiceDefinition.append("\n\t use \t\t generic-service");
			nagiosHostServiceDefinition.append("\n\t host_name \t " + instance.getHostName());
			nagiosHostServiceDefinition.append("\n\t service_description \t   _"
					+ instance.getServiceName_Port());
			nagiosHostServiceDefinition.append("\n\t check_command \t " + command);
			ArrayNode nagiosOptionsFromCsapDefn = getNagiosOptionsFromCsapDefn();
			if (nagiosOptionsFromCsapDefn != null && nagiosOptionsFromCsapDefn.size() > 0) {
				for (JsonNode configLine : nagiosOptionsFromCsapDefn) {
					if (configLine.asText().contains("passive_checks_enabled"))
						continue;
					nagiosHostServiceDefinition.append("\n\t " + configLine.asText());
				}
			} else {
				nagiosHostServiceDefinition.append("\n\t active_checks_enabled  \t  1");
			}
			nagiosHostServiceDefinition.append("\n\t passive_checks_enabled \t  0");
			nagiosHostServiceDefinition.append("\n\t }\n\n");
		}

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

示例10: getCollectedMetric

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public int getCollectedMetric ( ObjectNode meterJson, String attribute, String collector, ObjectNode lastCollected ) {

		if ( lastCollected == null || !lastCollected.has( attribute ) ) {
			logger.info( " Null attribute: " + attribute + "\n collectionJson: " + lastCollected );
			return 0;
		}
		int collected = lastCollected.get( attribute ).asInt();
		meterJson.put( "vmCount", meterJson.get( "vmCount" ).asInt() + 1 );

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

示例11: alertsBuilder

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 *
 * Add errors to errorList.
 *
 * @param hostName
 * @param errorList
 * @param responseFromHostStatusJson
 */
public ObjectNode alertsBuilder ( double alertLevel, String hostName, ObjectNode responseFromHostStatusJson ) {

	ObjectNode alertMessages = jacksonMapper.createObjectNode();
	ArrayNode errorArray = alertMessages.putArray( Application.VALIDATION_ERRORS );

	if ( responseFromHostStatusJson.has( "error" ) ) {
		errorArray.add( hostName + ": " + responseFromHostStatusJson
			.path( "error" )
			.textValue() );
		// return result;
		return alertMessages;
	}

	ObjectNode hostStatsNode = (ObjectNode) responseFromHostStatusJson.path( HostKeys.hostStats.jsonId );
	if ( hostStatsNode == null ) {
		errorArray.add( hostName + ": " + "Host response missing attribute: hostStats" );
		// return result;
		return alertMessages;
	}

	alertsForHostCpu( hostStatsNode, hostName, alertLevel, errorArray, alertMessages );

	alertsForHostMemory( hostStatsNode, hostName, errorArray, alertMessages );

	alertsForHostDisk( hostStatsNode, hostName, alertLevel, errorArray, alertMessages );

	ObjectNode serviceHealthCollected = (ObjectNode) responseFromHostStatusJson.path( "services" );
	if ( serviceHealthCollected == null ) {
		errorArray.add( hostName + ": " + "Host response missing attribute: services" );
		// return result;
		return alertMessages;
	}

	alertsForServices( hostName, serviceHealthCollected, errorArray, alertLevel, alertMessages );

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

示例12: alertsForServices

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void alertsForServices (	String hostName, ObjectNode serviceHealthCollected,
									ArrayNode errorArray, double alertLevel,
									ObjectNode errorsFoundJson ) {

	StringBuilder serviceMessages = new StringBuilder();
	ArrayList<ServiceInstance> instancesOnHost = csapApp.getAllPackages()
		.getHostToConfigMap()
		.get( hostName );

	for ( ServiceInstance instance : instancesOnHost ) {
		if ( !serviceHealthCollected.has( instance.getServiceName_Port() ) ) {
			String message = hostName + ": " + instance.getServiceName_Port()
					+ " No status found";
			serviceMessages.append( message + "\n" );
			errorArray.add( message );
			continue;
		}
		// errorArray.addAll(
		try {

			List<String> serviceAlerts = ServiceAlertsEnum.getServiceAlertsAndUpdateCpu(
				instance, alertLevel,
				serviceHealthCollected.get( instance.getServiceName_Port() ),
				csapApp.lifeCycleSettings() );

			for ( String alertDescription : serviceAlerts ) {
				errorArray.add( alertDescription );
				serviceMessages.append( alertDescription + "\n" );
			}
		} catch (Exception e) {
			logger.error( "Failed parsing messages", e );
		}
	}
	if ( serviceMessages.length() > 0 ) {
		addNagiosStateMessage( errorsFoundJson, "processes", MetricsPublisher.NAGIOS_WARN, serviceMessages.toString() );
	}

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

示例13: cleanUpServiceCache

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 *
 *
 */
private void cleanUpServiceCache ( ObjectNode servicesNode ) {

	Iterator<String> keyIter = servicesMapNodes.keySet().iterator();
	while (keyIter.hasNext()) {
		String serviceName = keyIter.next();

		if ( !servicesNode.has( serviceName ) ) {
			keyIter.remove();
			logger.warn( "Removing service from monitor list: " + serviceName
					+ " , assumed due to definition update." );
		}
	}

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

示例14: insertMessageToJson

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private JsonNode insertMessageToJson(ObjectNode json, String content) {
	if (json.has(CONTENT_LITERAL)) {
		json.put(CONTENT_LITERAL, content);
	} else if (json.has(PART_CONTENT_LITERAL)) {
		json.put(PART_CONTENT_LITERAL, content);
	}
	return json;
}
 
开发者ID:daflockinger,项目名称:poppynotes,代码行数:9,代码来源:NoteEncryptionServiceImpl.java

示例15: killServiceUsingDocker

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void killServiceUsingDocker (	ServiceInstance serviceInstance,
										OutputFileMgr outputFileMgr,
										ArrayList<String> params )
		throws Exception {
	//
	logger.info( "Killing docker service: {}, using: {} ",
		serviceInstance.getServiceName_Port(), params );

	synchronizeServiceState( KILL_FILE, serviceInstance );

	ObjectNode results = dockerHelper
		.containerRemove( null,
			serviceInstance.getDockerContainerPath(),
			true, true );

	if ( results.has( DockerJson.errorReason.key ) ) {
		outputFileMgr.print( results.get( DockerJson.errorReason.key ).asText() );
	} else {
		outputFileMgr.print( jsonFormat( results ) );
	}

	if ( params != null && params.contains( "clean" ) ) {

		ObjectNode removeResults = dockerHelper
			.imageRemove( null,
				serviceInstance.getDockerImageName() );

		if ( removeResults.has( DockerJson.errorReason.key ) ) {
			outputFileMgr.print( removeResults.get( DockerJson.errorReason.key ).asText() );
		} else {
			outputFileMgr.print( jsonFormat( removeResults ) );
		}
	}

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


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