@Override public T fromHash(Map<String, String> hash) { T instance = org.springframework.beans.BeanUtils.instantiateClass(type); try { BeanUtils.populate(instance, hash); return instance; } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * 将Map转换为javabean * @param map * @param clazz * @param <T> * @return */ public static <T> T map2Bean(Map<String, Object> map, Class<T> clazz) { if (map == null || clazz == null) { return null; } T bean = null; try { bean = clazz.newInstance(); BeanUtils.populate(bean, map); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return bean; }
BeanUtils.populate(metaDO, content);
BeanUtils.populate(top, values);
BeanUtils.populate(snapshotDO, content); metaSnapshotDAO.insert(snapshotDO); } catch (Throwable e) {
public static StreamingApplication setApplicationProperties(StreamingApplication application, Map<String, String> properties) { try { BeanUtils.populate(application, properties); return application; } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalArgumentException("Error setting application properties", e); } }
@Override public T fromHash(Map<String, String> hash) { T instance = org.springframework.beans.BeanUtils.instantiateClass(type); try { BeanUtils.populate(instance, hash); return instance; } catch (Exception ex) { throw new RuntimeException(ex); } }
public void copySettings(Map<String, Object> settings) throws IllegalAccessException, InvocationTargetException { if (settings.get("maxProcessCount") != null) { settings.remove("maxProcessCount"); } BeanUtils.populate(this, settings); }
public static <T> T bean2Object(Map bean, T target) { try { BeanUtils.populate(target, bean); return target; } catch (Exception e) { throw new TinySysRuntimeException(e); } }
private RemoteVersion makeRemoteVersion(Hashtable versionStruct) throws IllegalAccessException, InvocationTargetException { RemoteVersion version = new RemoteVersion(); BeanUtils.populate(version, versionStruct); return version; } }
@SuppressWarnings("rawtypes") public static <T> T bean2Object(Map bean, Class<T> type) { try { T target = type.newInstance(); BeanUtils.populate(target, bean); return target; } catch (Exception e) { throw new TinySysRuntimeException(e); } }
private RemoteComponent makeRemoteComponent(Hashtable componentStruct) throws IllegalAccessException, InvocationTargetException { RemoteComponent component = new RemoteComponent(); BeanUtils.populate(component, componentStruct); return component; }
public static <T> T bean2Object(Map bean, T target) { try { BeanUtils.populate(target, bean); return target; } catch (Exception e) { throw new TinySysRuntimeException(e); } }
@SuppressWarnings("rawtypes") public static <T> T bean2Object(Map bean, Class<T> type) { try { T target = type.newInstance(); BeanUtils.populate(target, bean); return target; } catch (Exception e) { throw new TinySysRuntimeException(e); } }
public static void populate(Object bean, Map properties) { try { org.apache.commons.beanutils.BeanUtils.populate(bean, properties); } catch (Exception e) { handleReflectionException(e); } }
public void loadSettings(String resourcePath, String defaultResourcePath, Object bean) { try { Map properties = loadSettings(resourcePath, defaultResourcePath); BeanUtils.populate(bean, properties); } catch (IllegalAccessException | InvocationTargetException | IOException e) { throw new IllegalStateException(e); } }
public void loadSettings(String resourcePath, Object bean) { try { Map properties = loadSettings(null, resourcePath); BeanUtils.populate(bean, properties); } catch (IllegalAccessException | InvocationTargetException | IOException e) { throw new IllegalStateException(e); } }
public T mapToDomainObject(Case ccCase) { T instance = null; try { instance = clazz.newInstance(); BeanUtils.copyProperties(instance, ccCase); BeanUtils.populate(instance, ccCase.getFieldValues()); } catch (Exception e) { e.printStackTrace(); } return instance; }
private void populate(ActionContext actionContext, ActionForm actionForm) throws ServletException { Map parameters = getCheckBoxParameters(actionContext.getActionConfig(), actionContext.getParameterMap()); if (!parameters.isEmpty()) { try { BeanUtils.populate(actionForm, parameters); } catch (IllegalAccessException e) { throw new ServletException("BeanUtils.populate", e); } catch (InvocationTargetException e) { throw new ServletException("BeanUtils.populate", e); } } }
protected void populateFromRequest(Object bean) { RequestFormUtil requestFormUtil = new RequestFormUtil(this.getRequest()); Map parameters = new HashMap(); // needed, can't directly modify the map returned by request.getParameterMap() parameters.putAll(requestFormUtil.getParameters()); parameters.putAll(requestFormUtil.getDocuments()); // handle uploaded files too try { // TODO : we could filter the parameters BeanUtils.populate(bean, parameters); } catch (Exception e) { log.error("can't set properties on the handler", e); } }