本文整理汇总了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());
}
}
示例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();
}
示例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));
}
示例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));
}
示例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()));
}
}
示例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));
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}