当前位置: 首页>>代码示例>>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;未经允许,请勿转载。