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


Java ArrayNode.addObject方法代碼示例

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


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

示例1: accessViolation

import com.fasterxml.jackson.databind.node.ArrayNode; //導入方法依賴的package包/類
private void accessViolation ( HttpServletResponse response, File targetFile, String browseFolder )
		throws IOException, JsonProcessingException {

	logger.debug( "Verify access: {} by {}", browseFolder, targetFile.getCanonicalPath() );
	ArrayNode childArray = jacksonMapper.createArrayNode();
	ObjectNode itemJson = childArray.addObject();
	itemJson.put( "name", "permission denied" );
	itemJson.put( "title", "permission denied" );

	response.getWriter().println(
		jacksonMapper.writeValueAsString( childArray ) );
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:13,代碼來源:FileRequests.java

示例2: processStatus

import com.fasterxml.jackson.databind.node.ArrayNode; //導入方法依賴的package包/類
public ArrayNode processStatus () {
	ArrayNode processArray = jacksonMapper.createArrayNode();
	String[] pslines = lastProcessStatsCollected().split( LINE_SEPARATOR );
	for ( int i = 0; i < pslines.length; i++ ) {
		String curline = pslines[i].trim();
		String[] cols = curline.split( " " );
		if ( cols.length < 7 ) {
			logger.debug( "Skipping line: {}", curline );
			continue;
		}
		String cpu = cols[0];
		String rssMemory = cols[1];
		String vMemory = cols[1];
		String threads = cols[3];
		String user = cols[4];
		String pid = cols[5];
		try {
			Integer.parseInt( pid );
		} catch (NumberFormatException e) {

			logger.info( "Skipping line: {}", curline );
			continue;
		}
		String priority = cols[6];

		ObjectNode processNode = processArray.addObject();

		processNode.put( "pid", pid );
		processNode.put( "command",
			curline.substring( curline.indexOf( pid ) ) );
		processNode.put( "user", user );
		processNode.put( "cpuUtil", cpu );
		processNode.put( "currentProcessPriority", priority );
		processNode.put( "topCpu",
			topStatsRunnable.getCpuForPid( Arrays.asList( pid ) ) );
		processNode.put( "threadCount", threads );
		processNode.put( "rssMemory", rssMemory );
		processNode.put( "virtualMemory", vMemory );
		processNode.put( "fileCount", "" );
		processNode.put( "socketCount", "" );
		processNode.put( "runHeap", "" );
	}

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

示例3: buildSummaryReport

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

示例4: buildListingUsingJava

import com.fasterxml.jackson.databind.node.ArrayNode; //導入方法依賴的package包/類
private ArrayNode buildListingUsingJava ( String fromFolder, String[] duLines, List<File> filesInFolder ) {

		ArrayNode fileListing = jacksonMapper.createArrayNode();
		for ( File itemInFolder : filesInFolder ) {

			String fsize = itemInFolder.length() + " b, ";
			if ( itemInFolder.length() > 1000 ) {
				fsize = itemInFolder.length() / 1000 + "kb, ";
			}
			Long fsizeNumeric = itemInFolder.length();

			ObjectNode itemJson = fileListing.addObject();
			// ObjectNode dataNode =jacksonMapper.createObjectNode() ;

			if ( itemInFolder.isDirectory() ) {
				itemJson.put( "folder", true );
				itemJson.put( "lazy", true );
				for ( int i = 0; i < duLines.length; i++ ) {
					//
					// logger.debug("Checking " + duLines[i] +
					// " contains "
					// + itemInFolder.getAbsolutePath());
					if ( duLines[i].endsWith( "/"
							+ itemInFolder.getName() ) ) {
						fsize = duLines[i].substring( 0,
							duLines[i].indexOf( " " ) )
								+ "Mb, ";

						try {
							fsizeNumeric = Long.parseLong( duLines[i]
								.substring( 0,
									duLines[i].indexOf( " " ) ) );
							fsizeNumeric = fsizeNumeric * 1000 * 1000;
							// gets to bytes
						} catch (Exception e) {
							logger.error( "Failed to parse to long" + fsize );
						}

						duLines[i] = ""; // optimize by shortening since
						// only 1 match
						break;
					}
				}
			}
			boolean filtered = false;
			if ( itemInFolder.getName().equals( ".ssh" ) ) {
				filtered = true;
			}

			itemJson.put( "name", itemInFolder.getName() );
			itemJson.put( "filter", filtered );
			itemJson.put( "location",
				fromFolder + itemInFolder.getName() );
			// itemJson.put("data", dataNode) ;
			itemJson.put( "title", itemInFolder.getName() );
			itemJson.put(
				"meta",
				"~"
						+ fsize
						+ fileDateOutput.format( new Date( itemInFolder
							.lastModified() ) ) );
			itemJson.put( "size", fsizeNumeric.longValue() );
			itemJson.put( "target", fromFolder + itemInFolder.getName()
					+ "/" );

		}

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


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