當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。