List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.discovery.darchrow.bean.BeanUtil.java
/** * <code>bean</code>???/Map. * //from w ww.jav a 2s . c om * <p> * ???classObject??classjava.lang.Object. * </p> * <p> * <span style="color:red">:<br> * ConvertUtils.register(dateTimeConverter, java.util.Date.class)?</span><br> * * , {@link org.apache.commons.beanutils.BeanUtilsBean#getNestedProperty(Object, String)}, ConvertUtilsBean?? <br> * {@link org.apache.commons.beanutils.ConvertUtilsBean#ConvertUtilsBean()} ? * * </p> * * @param bean * Bean whose properties are to be extracted * @return Map of property descriptors * @see org.apache.commons.beanutils.BeanUtils#describe(Object) * @see org.apache.commons.beanutils.PropertyUtils#describe(Object) * @see PropertyUtil#describe(Object) * @see PropertyDescriptor * @see #populate(Object, Map) */ public static Map<String, String> describe(Object bean) { try { //Return the entire set of properties for which the specified bean provides a read method. Map<String, String> propertyMap = BeanUtils.describe(bean); return propertyMap; } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.discovery.darchrow.bean.BeanUtil.java
/** * {@link BeanUtils#setProperty(Object, String, Object)} ?(<b>?</b>). * /* www . j a v a 2 s.c om*/ * <pre> * * BeanUtils.setProperty(pt1, "x", "9"); // 9String * PropertyUtils.setProperty(pt1, "x", 9); // int * // BeanUtilsPropertyUtils,?int?? * </pre> * * * <pre> * {@code * getPropertysetProperty,?2?JavaBean????. * Company c = new Company(); * c.setName("Simple"); * * Simple????? * //Simple * LOGGER.debug(BeanUtils.getProperty(c, "name")); * * Map???key?? * //Map * LOGGER.debug(BeanUtils.getProperty(c, "address (A2)")); * HashMap am = new HashMap(); * am.put("1","234-222-1222211"); * am.put("2","021-086-1232323"); * BeanUtils.setProperty(c,"telephone",am); * LOGGER.debug(BeanUtils.getProperty(c, "telephone (2)")); * * Indexed??[]??ArrayList???. * //index * LOGGER.debug(BeanUtils.getProperty(c, "otherInfo[2]")); * BeanUtils.setProperty(c, "product[1]", "NOTES SERVER"); * LOGGER.debug(BeanUtils.getProperty(c, "product[1]")); * * 3???? * //nest * LOGGER.debug(BeanUtils.getProperty(c, "employee[1].name")); * * } * </pre> * * @param bean * Bean on which setting is to be performed * @param name * Property name (can be nested/indexed/mapped/combo) * @param value * Value to be set * @see org.apache.commons.beanutils.BeanUtils#setProperty(Object, String, Object) * @see org.apache.commons.beanutils.PropertyUtils#setProperty(Object, String, Object) * @see com.baozun.nebulaplus.bean.PropertyUtil#setProperty(Object, String, Object) */ public static void setProperty(Object bean, String name, Object value) { try { // BeanUtils?? // ???(?) BeanUtils.setProperty(bean, name, value); } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.discovery.darchrow.bean.BeanUtil.java
/** * {@link BeanUtils#cloneBean(Object)}.<br> * bean,???bean<br>/* ww w . j a v a2 s .c om*/ * * <p> * {@link BeanUtils#cloneBean(Object)} ?? getPropertyUtils().copyProperties(newBean, bean);<br> * ?<b>? clone</b><br> * </p> * * <p> * ????????clone?,<br> * clone * </p> * * @param <T> * the generic type * @param bean * Bean to be cloned * @return the cloned bean * (? clone) * @see org.apache.commons.beanutils.BeanUtils#cloneBean(Object) * @see org.apache.commons.beanutils.PropertyUtilsBean#copyProperties(Object, Object) * @since 1.0 */ public static <T> T cloneBean(T bean) { try { //Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable. @SuppressWarnings("unchecked") T cloneBean = (T) BeanUtils.cloneBean(bean); return cloneBean; } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.discovery.darchrow.bean.BeanUtil.java
/** * {@link BeanUtils#getProperty(Object, String)} ?. * /*from www.j a va2 s . co m*/ * <h3>{@link BeanUtils#getProperty(Object, String) BeanUtils.getProperty}&{@link PropertyUtils#getProperty(Object, String) * PropertyUtils.getProperty}:</h3> * * <blockquote> * <p> * {@link BeanUtils#getProperty(Object, String)} ?String,<br> * {@link PropertyUtils#getProperty(Object, String)} Object,??? * </p> * </blockquote> * * <h3>:</h3> * * <pre> * {@code * getPropertysetProperty,?2?JavaBean????. * Company c = new Company(); * c.setName("Simple"); * * Simple????? * //Simple * LOGGER.debug(BeanUtils.getProperty(c, "name")); * * Map???key?? * //Map * LOGGER.debug(BeanUtils.getProperty(c, "address (A2)")); * HashMap am = new HashMap(); * am.put("1","234-222-1222211"); * am.put("2","021-086-1232323"); * BeanUtils.setProperty(c,"telephone",am); * LOGGER.debug(BeanUtils.getProperty(c, "telephone (2)")); * * Indexed??[]??ArrayList???. * //index * LOGGER.debug(BeanUtils.getProperty(c, "otherInfo[2]")); * BeanUtils.setProperty(c, "product[1]", "NOTES SERVER"); * LOGGER.debug(BeanUtils.getProperty(c, "product[1]")); * * 3???? * //nest * LOGGER.debug(BeanUtils.getProperty(c, "employee[1].name")); * * } * </pre> * * @param bean * bean * @param name * ?? * @return BeanUtils? * @see org.apache.commons.beanutils.BeanUtils#getProperty(Object, String) * @see org.apache.commons.beanutils.PropertyUtils#getProperty(Object, String) * @see com.baozun.nebulaplus.bean.PropertyUtil#getProperty(Object, String) */ public static String getProperty(Object bean, String name) { // Return the value of the specified property of the specified bean, // no matter which property reference format is used, as a String. try { String propertyValue = BeanUtils.getProperty(bean, name); return propertyValue; } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.discovery.darchrow.bean.BeanUtil.java
/** * Properties?, {@link BeanUtils#copyProperties(Object, Object)}. * // w ww.j a va 2 s .c o m * <p> * ?:?copy???2Bean???ref<br> * ?? . * </p> * * <h3>{@link BeanUtils#copyProperties(Object, Object)} {@link PropertyUtils#copyProperties(Object, Object)}</h3> * * <blockquote> * <ul> * <li>{@link BeanUtils#copyProperties(Object, Object)}??????????</li> * <li>{@link PropertyUtils#copyProperties(Object, Object)} ?????JavaBean???????????.</li> * <li>commons-beanutils v1.9.0? BeanUtils ?? nullPropertyUtils ?? null .<br> * (<b>:</b>commons-beanutils v1.9.0+?,BeanUtilsBean.copyProperties() no longer throws a ConversionException for null properties * of certain data types),?,??commons-beanutils * {@link <a href="http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/RELEASE-NOTES.txt">RELEASE-NOTES.txt</a>}</li> * </ul> * </blockquote> * * @param toObj * * @param fromObj * * @see org.apache.commons.beanutils.BeanUtils#copyProperties(Object, Object) * @see org.apache.commons.beanutils.BeanUtils#copyProperty(Object, String, Object) */ public static void copyProperties(Object toObj, Object fromObj) { if (null == toObj) { throw new NullPointerException("No destination bean/toObj specified"); } if (null == fromObj) { throw new NullPointerException("No origin bean/fromObj specified"); } try { BeanUtils.copyProperties(toObj, fromObj); } catch (Exception e) { LOGGER.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * properties/map?bean./* www. j ava2 s . c o m*/ * * @param bean * JavaBean whose properties are being populated * * @param properties * Map keyed by property name, with the corresponding (String or String[]) value(s) to be set * * @throws BeanUtilException * the bean util exception * @see org.apache.commons.beanutils.BeanUtils#populate(Object, Map) */ public static void populate(Object bean, Map<String, ?> properties) throws BeanUtilException { try { BeanUtils.populate(bean, properties); } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * bean???namevalue<br>/*ww w.ja v a2 s.c om*/ * * <pre> * java.util.Date ?copy, ?? * DateConverter converter = new DateConverter(DatePattern.forToString, Locale.US); * ConvertUtils.register(converter, Date.class); * BeanUtil.copyProperty(b, a, "date"); * </pre> * * <pre> * : BeanUtils.copyProperty(a, "sample.display", "second one"); * * setProperty * * ?bean?,copyProperty()?; * setProperty()BeanUtils.populate()(??),?populate(),?override setProperty(). * ,?,setProperty()???. * * </pre> * * @param bean * bean * @param propertyName * ?Property name (can be nested/indexed/mapped/combo) * @param value * value * @throws BeanUtilException * the bean util exception * @see org.apache.commons.beanutils.BeanUtils#copyProperty(Object, String, Object) */ public static void copyProperty(Object bean, String propertyName, Object value) throws BeanUtilException { try { BeanUtils.copyProperty(bean, propertyName, value); } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * <p>// ww w . ja v a 2 s. co m * <code>bean</code>???/Map. * </p> * * ???classObject??classjava.lang.Object. * <p> * <span style="color:red">:<br> * ConvertUtils.register(dateTimeConverter, java.util.Date.class)?</span><br> * * , {@link org.apache.commons.beanutils.BeanUtilsBean#getNestedProperty(Object, String)}, ConvertUtilsBean?? <br> * {@link org.apache.commons.beanutils.ConvertUtilsBean#ConvertUtilsBean()} ? * * </p> * * @param bean * Bean whose properties are to be extracted * * @return Map of property descriptors * * @throws BeanUtilException * if IllegalAccessException | InvocationTargetException | NoSuchMethodException * @see org.apache.commons.beanutils.BeanUtils#describe(Object) * @see org.apache.commons.beanutils.PropertyUtils#describe(Object) * @see PropertyUtil#describe(Object) * @see PropertyDescriptor * @see #populate(Object, Map) */ public static Map<String, String> describe(Object bean) throws BeanUtilException { try { //Return the entire set of properties for which the specified bean provides a read method. Map<String, String> propertyMap = BeanUtils.describe(bean); return propertyMap; } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * {@link BeanUtils#setProperty(Object, String, Object)} ?(<b>?</b>). * // w w w .j a va 2s . c om * <pre> * * BeanUtils.setProperty(pt1, "x", "9"); // 9String * PropertyUtils.setProperty(pt1, "x", 9); // int * // BeanUtilsPropertyUtils,?int?? * </pre> * * * <pre> * {@code * getPropertysetProperty,?2?JavaBean????. * Company c = new Company(); * c.setName("Simple"); * * Simple????? * //Simple * log.debug(BeanUtils.getProperty(c, "name")); * * Map???key?? * //Map * log.debug(BeanUtils.getProperty(c, "address (A2)")); * HashMap am = new HashMap(); * am.put("1","234-222-1222211"); * am.put("2","021-086-1232323"); * BeanUtils.setProperty(c,"telephone",am); * log.debug(BeanUtils.getProperty(c, "telephone (2)")); * * Indexed??[]??ArrayList???. * //index * log.debug(BeanUtils.getProperty(c, "otherInfo[2]")); * BeanUtils.setProperty(c, "product[1]", "NOTES SERVER"); * log.debug(BeanUtils.getProperty(c, "product[1]")); * * 3???? * //nest * log.debug(BeanUtils.getProperty(c, "employee[1].name")); * * } * </pre> * * @param bean * Bean on which setting is to be performed * @param name * Property name (can be nested/indexed/mapped/combo) * @param value * Value to be set * @throws BeanUtilException * if IllegalAccessException | InvocationTargetException * @see org.apache.commons.beanutils.BeanUtils#setProperty(Object, String, Object) * @see org.apache.commons.beanutils.PropertyUtils#setProperty(Object, String, Object) * @see com.feilong.commons.core.bean.PropertyUtil#setProperty(Object, String, Object) */ public static void setProperty(Object bean, String name, Object value) throws BeanUtilException { try { // BeanUtils?? // ???(?) BeanUtils.setProperty(bean, name, value); } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }
From source file:com.feilong.commons.core.bean.BeanUtil.java
/** * {@link BeanUtils#cloneBean(Object)},<br> * bean,???bean<br>/*from ww w .ja v a2s . co m*/ * * <p> * {@link BeanUtils#cloneBean(Object)} ?? getPropertyUtils().copyProperties(newBean, bean);<br> * ?<b>? clone</b><br> * </p> * * <p> * ????????clone?,<br> * clone * </p> * * @param <T> * the generic type * @param bean * Bean to be cloned * @return the cloned bean * (? clone) * @throws BeanUtilException * if IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException * @see org.apache.commons.beanutils.BeanUtils#cloneBean(Object) * @see org.apache.commons.beanutils.PropertyUtilsBean#copyProperties(Object, Object) * @since 1.0 */ public static <T> T cloneBean(T bean) throws BeanUtilException { try { //Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable. @SuppressWarnings("unchecked") T cloneBean = (T) BeanUtils.cloneBean(bean); return cloneBean; } catch (Exception e) { log.error(e.getClass().getName(), e); throw new BeanUtilException(e); } }