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


Java JsonMappingException类代码示例

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


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

示例1: build

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
public String build(String script) throws JsonParseException, JsonMappingException, IOException{
	
	//if no dependencies just return itself.
	if(!script.contains(IMPORT_PREFIX)){
		return script;
	}
	
	//add the initial script.
	sb.append(script);
	
	//build the set of dependencies.
	this.resolveDependencies(script);
	
	//with all the script files build one big script.
	for(String path : this.dependencies){
		sb.append(this.resolveScript(path));
		sb.append("\n\n");
	}
	
	return sb.toString();
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:22,代码来源:ScriptAggregator.java

示例2: fromResource

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
/**
 * Convert from a JSON file
 * @param resource input file
 * @return the parsed JSON
 * @throws IOException IO problems
 * @throws JsonMappingException failure to map from the JSON to this class
 */
@SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
public synchronized T fromResource(String resource)
    throws IOException, JsonParseException, JsonMappingException {
  InputStream resStream = null;
  try {
    resStream = this.getClass().getResourceAsStream(resource);
    if (resStream == null) {
      throw new FileNotFoundException(resource);
    }
    return mapper.readValue(resStream, classType);
  } catch (IOException e) {
    LOG.error("Exception while parsing json resource {}: {}", resource, e);
    throw e;
  } finally {
    IOUtils.closeStream(resStream);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:JsonSerDeser.java

示例3: processHttpRequest

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
public static <T, R> R processHttpRequest(String completeURL,
                                          Class<R> responseType,
                                          T request,
                                          Map<String, String> headers,
                                          HttpMethod method) {

    final Map<String, Object> parameters = getParams(request);
    try {
        return mapper.readValue(
                processHttpRequest(completeURL,
                        parameters,
                        headers,
                        method),
                responseType);
    } catch (JsonParseException | JsonMappingException je) {
        throw new ServiceException(CommonExceptionCodes.HTTP_CLIENT_EXCEPTION.code(),
                "Could not parse response into specified response type. " + "Error: " + je);
    } catch (IOException ioe) {
        throw new InternalServerException();
    }
}
 
开发者ID:dixantmittal,项目名称:scalable-task-scheduler,代码行数:22,代码来源:HttpUtils.java

示例4: testBucketCache

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的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

示例5: testLruBlockCache

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的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

示例6: logPerFile

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的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

示例7: output

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的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

示例8: readList

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
/**
 * Reads a collection of FileTrackingStatus.<br/>
 * If plain text is a list of line separated plain text.<br/>
 * If json this should be a json array.<br/>
 * 
 * @param format
 * @param reader
 * @return
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public Collection<FileTrackingStatus> readList(FORMAT format, Reader reader)
		throws JsonParseException, JsonMappingException, IOException {

	Collection<FileTrackingStatus> coll = null;

	if (format.equals(FORMAT.JSON)) {
		coll = (Collection<FileTrackingStatus>) mapper.readValue(reader,
				new TypeReference<Collection<FileTrackingStatus>>() { });
	} else {
		BufferedReader buff = new BufferedReader(reader);
		coll = new ArrayList<FileTrackingStatus>();

		String line = null;
		while ((line = buff.readLine()) != null) {
			coll.add(read(FORMAT.TXT, line));
		}

	}

	return coll;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:35,代码来源:FileTrackingStatusFormatter.java

示例9: CommandImpl

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的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

示例10: resolveDependencies

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
public void resolveDependencies(String script) throws JsonParseException, JsonMappingException, IOException{
	String[] parsed = script.split("\n");
	for(String str : parsed){
		if(str.contains(IMPORT_PREFIX)){
			str = StrUtils.rightBack(str, IMPORT_PREFIX);
			String[] references = str.split(StringCache.COMMA);
			for(String path : references){
				path = path.trim();
				if(!dependencies.contains(path)){
					dependencies.add(path);
					String newScript = this.resolveScript(path);
					
					//recurse to pull in all the script files.
					this.resolveDependencies(newScript);
				}
			}
		}
	}
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:20,代码来源:ScriptAggregator.java

示例11: createDocument

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
public static SolrInputDocument createDocument(String dataStr)
    throws JsonParseException, JsonMappingException, IOException {
  Map<String, Object> dataMap =
      new ObjectMapper().readValue(dataStr, new TypeReference<HashMap<String, Object>>() {
      });

  SolrInputDocument document = new SolrInputDocument();

  for (Iterator<String> i = dataMap.keySet().iterator(); i.hasNext();) {
    String fieldName = i.next();
    Object fieldValue = dataMap.get(fieldName);
    document.addField(fieldName, fieldValue);
  }

  return document;
}
 
开发者ID:mosuka,项目名称:solrj-example,代码行数:17,代码来源:SolrJExampleUtil.java

示例12: testCreateDocument

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
public void testCreateDocument() throws JsonParseException, JsonMappingException, IOException {
  String data =
      "{\"id\":\"1\",\"title_txt_en\":\"SolrJ\",\"description_txt_en\":\"SolrJ is an API that makes it easy for Java applications to talk to Solr.\"}";

  SolrInputDocument document = SolrJExampleUtil.createDocument(data);

  String expectedId = "1";
  String actualId = document.getFieldValue("id").toString();
  assertEquals(expectedId, actualId);

  String expectedTitle = "SolrJ";
  String actualTitle = document.getFieldValue("title_txt_en").toString();
  assertEquals(expectedTitle, actualTitle);

  String expectedDescription =
      "SolrJ is an API that makes it easy for Java applications to talk to Solr.";
  String actualDescription = document.getFieldValue("description_txt_en").toString();
  assertEquals(expectedDescription, actualDescription);
}
 
开发者ID:mosuka,项目名称:solrj-example,代码行数:20,代码来源:SolrJExampleUtilTest.java

示例13: mapException

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Status mapException(JsonMappingException exception) {
    LOGGER.error(exception.getMessage(), exception);
    List<Reference> references = exception.getPath();
    if (references != null) {
        String message = new String("Wrong elements: ");
        for (Reference reference : references) {
            message += reference.getFieldName() + ", ";
        }
        message = message.substring(0, message.length() - 2);
        message += ".";
        return new Status("error.rest.badrequest", null, BAD_REQUEST, new Reason(
                new StaticLocalizedMessage(message), null, null));
    }
    return new Status("error.rest.badrequest", null, BAD_REQUEST);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:JsonMappingExceptionMapper.java

示例14: handle

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
/**
 * Handle messages of {@link JsonMappingException}
 * 
 * @param exception
 *            {@link JsonMappingException}
 * @param apiResult
 *            error result
 * @return {@link ApiResult} with error messages
 */
@Override
public ApiResult<Object> handle(JsonMappingException exception, ApiResult<Object> apiResult) {
    apiResult.setMessage(getErrorMessage(exception));
    List<Reference> references = exception.getPath();
    List<ApiResultError> apiResultErrors = new ArrayList<ApiResultError>();
    if (references != null) {
        ApiResultError error = new ApiResultError();
        error.setCause("Exception");
        String message = new String("wrong elements: ");
        for (Reference reference : references) {
            message += reference.getFieldName() + ", ";
        }
        message = message.substring(0, message.length() - 2);
        message += ".";
        error.setMessage(message);
        apiResultErrors.add(error);
    }
    apiResult.setErrors(apiResultErrors);
    return apiResult;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:30,代码来源:JsonMappingExceptionMapper.java

示例15: testConvertToCNTMessage

import org.codehaus.jackson.map.JsonMappingException; //导入依赖的package包/类
/**
 * Test convert to cnt message.
 * 
 * @throws MessageParsingException
 *             in case parsing went wrong
 * @throws JsonParseException
 *             the json parse exception
 * @throws JsonMappingException
 *             the json mapping exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
@Test
public void testConvertToCNTMessage() throws MessageParsingException, JsonParseException,
        JsonMappingException, IOException {
    TransferMessage tm = new TransferMessage();
    String testContent = "Test Content";
    tm.setContentType(TMContentType.JSON);
    tm.setContent(testContent);
    TestMessage testMessage = new TestMessage();
    EasyMock.expect(mockObjectMapper.readValue(testContent, TestMessage.class))
            .andReturn(testMessage);
    mockObjectMapper.registerSubtypes(new Class[0]);
    EasyMock.replay(mockObjectMapper);
    converter.setMapper(mockObjectMapper);
    TestMessage res = converter.convertToCommunoteMessage(tm,
            TestMessage.class);
    Assert.assertEquals(res, testMessage);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:30,代码来源:MessagesConverterTest.java


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