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


Java ObjectMapper.convertValue方法代码示例

本文整理汇总了Java中org.codehaus.jackson.map.ObjectMapper.convertValue方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.convertValue方法的具体用法?Java ObjectMapper.convertValue怎么用?Java ObjectMapper.convertValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.map.ObjectMapper的用法示例。


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

示例1: registerBroadcastReceiver

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
private void registerBroadcastReceiver() {
	gameBroadcastReceiver =  new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			Bundle extras = intent.getExtras();
			String destModelId = extras.getString("modelId");
			if (modelId != null && modelId.equals(destModelId)) {
				//gotta handle this message
				Document messageDocument = dataService.loadDocument(extras.getString("id"));
				ObjectMapper mapper = JSONUtils.createObjectMapper();
				final GameMessage message = mapper.convertValue(messageDocument.getProperties(), GameMessage.class);
				intent.putExtra(Intent.EXTRA_DATA_REMOVED, true);
				getActivity().runOnUiThread(new Runnable() {
					@Override
					public void run() {
						controllerFragment.processMessage(message);
					}
				});
			}
		}
	};
	LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
               gameBroadcastReceiver,
               new IntentFilter(GameBoardApplication.INTENT_ACTION_GAME_MSG));
}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:26,代码来源:GameDetailFragment.java

示例2: create

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
@Override
@Transactional
public JpaMedia create(final Map<String, String> mediaDataMap, final Map<String, Object> mediaFileDataMap) {
    final ObjectMapper objectMapper = new ObjectMapper();
    final JpaMedia media = objectMapper.convertValue(mediaDataMap, JpaMedia.class);

    // filename can be the full path or just the name that is why we need to convert it to Paths
    // to extract the base name e.g. c:/jdk.zip -> jdk.zip or jdk.zip -> jdk.zip
    final String filename = FilenameUtils.getName((String) mediaFileDataMap.get("filename"));

    try {
        mediaDao.findByNameAndType(media.getName(), media.getType());
        final String msg = MessageFormat.format("Media already exists with name {0} and type {1}", media.getName(), media.getType());
        LOGGER.error(msg);
        throw new MediaServiceException(msg);
    } catch (NoResultException e) {
        LOGGER.debug("No Media name conflict, ignoring not found exception for creating media ", e);
    }

    final String uploadedFilePath = repositoryService.upload(filename, (BufferedInputStream) mediaFileDataMap.get("content"));
    final List<String> binariesByBasename = repositoryService.getBinariesByBasename(FilenameUtils.removeExtension(filename));
    final String dest = getPathForExistingBinary(uploadedFilePath, binariesByBasename);

    final Set<String> zipRootDirSet = fileUtility.getZipRootDirs(dest);
    if (!zipRootDirSet.isEmpty()) {
        media.setRootDir(Paths.get(StringUtils.join(zipRootDirSet, ",")));
        media.setLocalPath(Paths.get(dest));
        return mediaDao.create(media);
    }
    repositoryService.delete(dest);
    throw new MediaServiceException(MessageFormat.
            format("{0} does not have any root directories! It may not be a valid media file.", filename));
}
 
开发者ID:cerner,项目名称:jwala,代码行数:34,代码来源:MediaServiceImpl.java

示例3: createResponse

import org.codehaus.jackson.map.ObjectMapper; //导入方法依赖的package包/类
/**
 * Creates response object from response map.
 * @param responseMap response map
 * @return response object
 */
private ActionResponseData createResponse(Map<String, Object> responseMap) {
    Class<? extends ActionResponseData> responseClass = actionService.lookupResponseClass((String) responseMap.get("id"));
    ObjectMapper mapper = new ObjectMapper();
    return mapper.convertValue(responseMap, responseClass);
}
 
开发者ID:jhkst,项目名称:dlface,代码行数:11,代码来源:ActionRequests.java


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