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


Java JsonGenerationException类代码示例

本文整理汇总了Java中org.codehaus.jackson.JsonGenerationException的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerationException类的具体用法?Java JsonGenerationException怎么用?Java JsonGenerationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addVertexToPolygon

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
private void addVertexToPolygon(double lat, double lon, double hae)
		throws JsonGenerationException, IOException {
	try {
		if (firstVertex) {
			firstVertex = false;
			cachedLat = lat;
			cachedLon = lon;
			cachedHae = hae;
			firstVertex = false;
		}

		generator.writeStartArray();
		generator.writeNumber(lon);
		generator.writeNumber(lat);
		// generator.writeNumber(hae);
		generator.writeEndArray();
	} catch (Exception e) {
		log.error(e);
		log.error(e.getStackTrace());
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:CoTAdapterInbound.java

示例2: addVertexToPolygon

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException
{
	if( firstVertex )
	{
		firstVertex = false;
		cachedLat = lat;
		cachedLon = lon;
		cachedHae = hae;
		firstVertex = false;
	}

	generator.writeStartArray();
	generator.writeNumber(lon);
	generator.writeNumber(lat);
	//generator.writeNumber(hae);
	generator.writeEndArray();
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:18,代码来源:CoTAdapter.java

示例3: testBucketCache

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
@Test
public void testBucketCache() throws JsonGenerationException, JsonMappingException, IOException {
  this.conf.set(HConstants.BUCKET_CACHE_IOENGINE_KEY, "offheap");
  this.conf.setInt(HConstants.BUCKET_CACHE_SIZE_KEY, 100);
  CacheConfig cc = new CacheConfig(this.conf);
  assertTrue(cc.getBlockCache() instanceof CombinedBlockCache);
  logPerBlock(cc.getBlockCache());
  final int count = 3;
  addDataAndHits(cc.getBlockCache(), count);
  // The below has no asserts.  It is just exercising toString and toJSON code.
  LOG.info(cc.getBlockCache().getStats());
  BlockCacheUtil.CachedBlocksByFile cbsbf = logPerBlock(cc.getBlockCache());
  LOG.info(cbsbf);
  logPerFile(cbsbf);
  bucketCacheReport(cc.getBlockCache());
  LOG.info(BlockCacheUtil.toJSON(cbsbf));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestBlockCacheReporting.java

示例4: testLruBlockCache

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
@Test
public void testLruBlockCache() throws JsonGenerationException, JsonMappingException, IOException {
  CacheConfig cc = new CacheConfig(this.conf);
  assertTrue(cc.isBlockCacheEnabled());
  assertTrue(CacheConfig.DEFAULT_IN_MEMORY == cc.isInMemory());
  assertTrue(cc.getBlockCache() instanceof LruBlockCache);
  logPerBlock(cc.getBlockCache());
  addDataAndHits(cc.getBlockCache(), 3);
  // The below has no asserts.  It is just exercising toString and toJSON code.
  BlockCache bc = cc.getBlockCache();
  LOG.info("count=" + bc.getBlockCount() + ", currentSize=" + bc.getCurrentSize() +
      ", freeSize=" + bc.getFreeSize() );
  LOG.info(cc.getBlockCache().getStats());
  BlockCacheUtil.CachedBlocksByFile cbsbf = logPerBlock(cc.getBlockCache());
  LOG.info(cbsbf);
  logPerFile(cbsbf);
  bucketCacheReport(cc.getBlockCache());
  LOG.info(BlockCacheUtil.toJSON(cbsbf));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestBlockCacheReporting.java

示例5: logPerFile

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
private void logPerFile(final BlockCacheUtil.CachedBlocksByFile cbsbf)
throws JsonGenerationException, JsonMappingException, IOException {
  for (Map.Entry<String, NavigableSet<CachedBlock>> e:
      cbsbf.getCachedBlockStatsByFile().entrySet()) {
    int count = 0;
    long size = 0;
    int countData = 0;
    long sizeData = 0;
    for (CachedBlock cb: e.getValue()) {
      count++;
      size += cb.getSize();
      BlockType bt = cb.getBlockType();
      if (bt != null && bt.isData()) {
        countData++;
        sizeData += cb.getSize();
      }
    }
    LOG.info("filename=" + e.getKey() + ", count=" + count + ", countData=" + countData +
        ", size=" + size + ", sizeData=" + sizeData);
    LOG.info(BlockCacheUtil.toJSON(e.getKey(), e.getValue()));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestBlockCacheReporting.java

示例6: output

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
public void output(Map<String, Object> parameters, boolean withRequest, boolean prettyPrint)
        throws JsonGenerationException, JsonMappingException, IOException {
    Map<String, Object> result = new LinkedHashMap<String, Object>();

    // put request to result
    if (withRequest) {
        Map<String, Object> request = new LinkedHashMap<String, Object>();
        request.put("command", getName());
        request.put("parameters", parameters);
        result.put("request", request);
    }

    // put response to result
    putResponse("status", getStatus());
    putResponse("message", getMessage());
    result.put("response", getResponse());

    ObjectMapper mapper = new ObjectMapper();
    if (prettyPrint) {
        // enable pretty print
        System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(result));
    } else {
        System.out.println(mapper.writeValueAsString(result));
    }
}
 
开发者ID:mosuka,项目名称:zookeeper-cli,代码行数:26,代码来源:Command.java

示例7: CommandImpl

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
public CommandImpl(Long id, IPolicy policy, ITask task, List<String> dnList, DNType dnType, List<String> uidList,
		String commandOwnerUid, Date activationDate, Date expirationDate, Date createDate,
		List<CommandExecutionImpl> commandExecutions, boolean sentMail)
		throws JsonGenerationException, JsonMappingException, IOException {
	this.id = id;
	this.policy = (PolicyImpl) policy;
	this.task = (TaskImpl) task;
	ObjectMapper mapper = new ObjectMapper();
	this.dnListJsonString = mapper.writeValueAsString(dnList);
	setDnType(dnType);
	this.uidListJsonString = uidList != null ? mapper.writeValueAsString(uidList) : null;
	this.commandOwnerUid = commandOwnerUid;
	this.activationDate = activationDate;
	this.expirationDate = expirationDate;
	this.createDate = createDate;
	this.commandExecutions = commandExecutions;
	this.sentMail = sentMail;
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:19,代码来源:CommandImpl.java

示例8: namedpipeLoop

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
/***********  stdin/namedpipe loop  ***********/

	void namedpipeLoop() throws JsonGenerationException, JsonMappingException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
		String inputline;
		BufferedOutputStream out = new BufferedOutputStream(
				new FileOutputStream(outpipeFilename, true));
//		OutputStream out = new FileOutputStream(outpipeFilename, true);
		log("Waiting for commands on stdin");
		while ( (inputline=reader.readLine()) != null) {
			JsonNode result = parseAndRunCommand(inputline);
			writeResultToStream(result, out);
			out.flush();
			checkTimings();
		}

	}
 
开发者ID:UKPLab,项目名称:tac2015-event-detection,代码行数:18,代码来源:SocketServer.java

示例9: execute

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
public HashMap<String, Object> execute(String operation, String content) 
		throws JsonGenerationException, JsonMappingException, IOException, UserSysException
{	
	HashMap<String, Object> res = callOpenAPI(operation, content);
	
	
	//try {
		//int status = (Integer)res.get("status");
		String body = (String)res.get("body");
		ObjectMapper mapper = new ObjectMapper();
		Object json = mapper.readValue(body, Object.class);
		res.put("json", json);
	//} catch (JsonGenerationException ex) {
	//	res.put("exception", ex);
	//} catch (JsonMappingException ex) {
	//	res.put("exception", ex);
	//} catch (IOException ex) {
	//	res.put("exception", ex);
	//} catch (UserSysException ex) {
		
	//}
	
	return res;
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:25,代码来源:OpenApiService.java

示例10: setOrRemoveOptionalAttributeList

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
private static void setOrRemoveOptionalAttributeList(GluuCustomPerson destination, List<?> items, String attributeName)
		throws JsonGenerationException, JsonMappingException, IOException {
	if (items == null) {
		log.trace(" removing " + attributeName);
		destination.removeAttribute(attributeName);
	} else {
		log.trace(" setting " + attributeName);

		StringWriter listOfItems = new StringWriter();
		ObjectMapper mapper = new ObjectMapper();
		mapper.writeValue(listOfItems, items);
		destination.setAttribute(attributeName, listOfItems.toString());

	}

}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:17,代码来源:CopyUtils.java

示例11: toJsonString

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
public static String toJsonString(Object obj, boolean bStripJsReservedWords) throws JsonGenerationException, JsonMappingException, IOException {
	String strResult = null;
	if (obj != null) {
		
		if (bStripJsReservedWords && obj instanceof JetstreamEvent)
			obj = ((JetstreamEvent)obj).getFilteredEvent();
		
		try {
			ObjectMapper mapper = new ObjectMapper();
			Writer writer = new StringWriter();
			mapper.writeValue(writer, obj);
			strResult = writer.toString();
		}
		catch (Throwable t) {
			if (m_nErrorCount++ % 10000 == 0 && LOGGER.isErrorEnabled())
				LOGGER.error( "", t); 
		}
	}
	return strResult;
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:21,代码来源:EPLUtils.java

示例12: isDoubleBroadcast

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
private boolean isDoubleBroadcast(HttpServletRequest request,
		Object responseEntity) throws JsonGenerationException,
		JsonMappingException, IOException {

	String clientId = request.getHeader(HeaderConfig.X_ATMOSPHERE_TRACKING_ID);

	// return false if the X-Atmosphere-tracking-id is not set
	if (clientId == null || clientId.isEmpty()) {
		return false;
	}

	CacheEntry entry = ResourceStateChangeListener.getCachedEntries().put(
			clientId, new CacheEntry(responseEntity));
	// there was an existing cached entry, see if its the same
	if (entry != null) {
		ObjectMapper mapper = new ObjectMapper();
		// cached data
		final String firedResponse = mapper.writeValueAsString(entry.getData());
		// new data
		final String responseValue = mapper.writeValueAsString(responseEntity);
		// the same ?
		return responseValue.equals(firedResponse); 
	}

	return false;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:DuplicateBroadcastProtectionFilter.java

示例13: open

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
/**
 * Open a JSON output file
 * The file output may be derived from many input sources
 *  
 * @param name
 * @param string 
 * @throws XMLStreamException
 * @throws IOException
 */
public void open(File file) throws XMLStreamException, IOException {
	
       // Mapped convention
	JsonFactory f = new JsonFactory();
	try {
		generator = f.createJsonGenerator(new FileWriter(file));
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
		generator.setCodec(mapper);
		generator.useDefaultPrettyPrinter();

		rootNode = mapper.createObjectNode();
		rootNode.put("name", "odfestyles");
		rootArray = rootNode.putArray(CHILDREN_TAG);
		
	} catch (JsonGenerationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} 
}
 
开发者ID:hammyau,项目名称:ODFExplorer,代码行数:30,代码来源:StylesJSONWriter.java

示例14: open

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
public void open(File file) throws XMLStreamException, IOException {
	
       // Mapped convention
	JsonFactory f = new JsonFactory();
	try {
		generator = f.createJsonGenerator(new FileWriter(file));
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
		generator.setCodec(mapper);
		generator.useDefaultPrettyPrinter();

		rootNode = mapper.createObjectNode();
		rootNode.put("name", "odfpaths");
		rootArray = rootNode.putArray(CHILDREN_TAG);
		
	} catch (JsonGenerationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} 
}
 
开发者ID:hammyau,项目名称:ODFExplorer,代码行数:21,代码来源:XPathJSONWriter.java

示例15: list

import org.codehaus.jackson.JsonGenerationException; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
public String list() throws JsonGenerationException, JsonMappingException,
		IOException {
	this.logger.info("list()");

	ObjectWriter viewWriter;
	if (this.isAdmin()) {
		viewWriter = this.mapper.writerWithView(JsonViews.Admin.class);
	} else {
		viewWriter = this.mapper.writerWithView(JsonViews.User.class);
	}
	List<NewsEntry> allEntries = this.newsEntryDao.findAll();

	return viewWriter.writeValueAsString(allEntries);
}
 
开发者ID:davidsan,项目名称:montgomery,代码行数:17,代码来源:NewsEntryResource.java


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