當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。