當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectNode.deepCopy方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode.deepCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.deepCopy方法的具體用法?Java ObjectNode.deepCopy怎麽用?Java ObjectNode.deepCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.node.ObjectNode的用法示例。


在下文中一共展示了ObjectNode.deepCopy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateMetricData

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的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

示例2: updateOrValidateSettings

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@RequestMapping ( value = "/settings" , produces = MediaType.APPLICATION_JSON_VALUE , method = RequestMethod.POST )
public ObjectNode updateOrValidateSettings (
												@RequestParam ( "lifeToEdit" ) String lifeToEdit,
												@RequestParam ( "definition" ) String definitionText,
												@RequestParam ( value = "isUpdate" , required = false ) String isUpdate ) {

	if ( lifeToEdit == null ) {
		lifeToEdit = Application.getCurrentLifeCycle();
	}

	logger.info( "lifeToEdit: {} , isUpdate: {}", lifeToEdit, isUpdate );
	logger.debug( "definitionText: \n{}", definitionText );

	ObjectNode updateResultNode = jacksonMapper.createObjectNode();

	try {
		ObjectNode updatedSettingsDefinition = (ObjectNode) jacksonMapper.readTree( definitionText );
		updatedSettingsDefinition.put( "lastModifiedBy", CsapUser.currentUsersID() );

		ObjectNode modelNode = (ObjectNode) csapApp.getRootModel().getJsonModelDefinition();

		ObjectNode testPackageModel = modelNode.deepCopy();

		JsonNode currentLifeNode = testPackageModel.at( DefinitionParser.buildLifePtr( lifeToEdit ) );

		((ObjectNode) currentLifeNode).set( DefinitionParser.PARSER_SETTINGS, updatedSettingsDefinition );

		updateResultNode.put( "lifeToEdit", lifeToEdit );
		logger.debug( "updateNode: \n{}", updatedSettingsDefinition.toString() );

		ObjectNode validationResults = csapApp.checkDefinitionForParsingIssues(
			testPackageModel.toString(),
			csapApp.getRootModel().getReleasePackageName(),
			"settingsUpdate" );

		updateResultNode.set( "validationResults", validationResults );

		boolean validatePassed = ((ArrayNode) validationResults.get( Application.VALIDATION_ERRORS )).size() == 0;

		if ( validatePassed ) {
			validateTrendingAndRealTimeDefinition( lifeToEdit, updatedSettingsDefinition, validationResults );
		}

		if ( isUpdate != null && validatePassed ) {
			updateResultNode.put( "updatedHost", Application.getHOST_NAME() );
			csapApp.getRootModel().setJsonModelDefinition( testPackageModel );
		}

	} catch (Throwable ex) {
		logger.error( "Failed to parse", ex );
		return buildEditingErrorResponse( ex, updateResultNode );
	}

	return updateResultNode;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:56,代碼來源:DefinitionRequests.java


注:本文中的com.fasterxml.jackson.databind.node.ObjectNode.deepCopy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。