/** * Return the value of the specified property of the specified bean, * no matter which property reference format is used, with no * type conversions. * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return the property value * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found */ public Object getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (getNestedProperty(bean, name)); }
/** * Return the value of the specified property of the specified bean, * no matter which property reference format is used, with no * type conversions. * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return the property value * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found */ public Object getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (getNestedProperty(bean, name)); }
/** * <p>Return the value of the (possibly nested) property of the specified * name, for the specified bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return the nested property value * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws NestedNullException if a nested reference to a * property returns null * @throws InvocationTargetException * if the property accessor method throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getNestedProperty */ public static Object getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getNestedProperty(bean, name); }
/** * <p>Return the value of the (possibly nested) property of the specified * name, for the specified bean, with no type conversions.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return the nested property value * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws NestedNullException if a nested reference to a * property returns null * @throws InvocationTargetException * if the property accessor method throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getNestedProperty */ public static Object getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getNestedProperty(bean, name); }
/** * Return the value of the (possibly nested) property of the specified * name, for the specified bean, as a String. * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return The nested property's value, converted to a String * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * property cannot be found */ public String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { final Object value = getPropertyUtils().getNestedProperty(bean, name); return (getConvertUtils().convert(value)); }
/** * Return the value of the (possibly nested) property of the specified * name, for the specified bean, as a String. * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return The nested property's value, converted to a String * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * property cannot be found */ public String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { final Object value = getPropertyUtils().getNestedProperty(bean, name); return (getConvertUtils().convert(value)); }
NoSuchMethodException { final Object value = getPropertyUtils().getNestedProperty(bean, name); return getLocaleConvertUtils().convert(value, pattern);
NoSuchMethodException { final Object value = getPropertyUtils().getNestedProperty(bean, name); return getLocaleConvertUtils().convert(value, pattern);
public static Map<String, Object> toMap(Object obj) { Map<String, Object> params = new HashMap<String, Object>(0); try { PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean(); PropertyDescriptor[] descriptors = propertyUtilsBean.getPropertyDescriptors(obj); for (int i = 0; i < descriptors.length; i++) { String name = descriptors[i].getName(); if (!"class".equals(name)) { params.put(name, propertyUtilsBean.getNestedProperty(obj, name)); } } } catch (Exception e) { e.printStackTrace(); } return params; }
@Override public Object getNestedProperty(Object bean, String propertyPath) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { // Extract Spring-managed field value in case of SpringBindingActionForm. if (bean instanceof SpringBindingActionForm) { SpringBindingActionForm form = (SpringBindingActionForm) bean; return form.getFieldValue(propertyPath); } // Else fall back to default PropertyUtils behavior. return super.getNestedProperty(bean, propertyPath); } }
public Object getNestedProperty(Object bean, String propertyPath) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { // Extract Spring-managed field value in case of SpringBindingActionForm. if (bean instanceof SpringBindingActionForm) { SpringBindingActionForm form = (SpringBindingActionForm) bean; return form.getFieldValue(propertyPath); } // Else fall back to default PropertyUtils behavior. return super.getNestedProperty(bean, propertyPath); } }
public static Object getValue(Object bean, String name) { try { return propertyUtilsBean.getNestedProperty(bean, name); } catch (Exception e) { return null; } }
@Override public Object getNestedProperty(Object bean, String propertyPath) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { // Extract Spring-managed field value in case of SpringBindingActionForm. if (bean instanceof SpringBindingActionForm) { SpringBindingActionForm form = (SpringBindingActionForm) bean; return form.getFieldValue(propertyPath); } // Else fall back to default PropertyUtils behavior. return super.getNestedProperty(bean, propertyPath); } }
private Object getPropertyValue(Object value) { try { return Binding.propertyUtils.getNestedProperty(value, propertyExpression); } catch (Exception e) { e.printStackTrace(); return "Failed to get " + propertyExpression; } } }
@SuppressWarnings({"unchecked"}) private MODEL_VALUE_TYPE getModelValue() throws ConversionException { try { return (MODEL_VALUE_TYPE) propertyUtils.getNestedProperty(model, propertyExpression); } catch (Exception e) { throw new ConversionException("Failed to retrieve property from object", e); } }
public static Map<String, Object> getObjectAsMap2(Object bean, List<String> fieldList) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException { Map<String, Object> ret = new HashMap<String, Object>(); List<Field> fields = getAllFields(bean.getClass()); for (Field fld : fields) { if ((fieldList == null) || (fieldList.size() == 0) || (fieldList.indexOf(fld.getName()) != -1)) { Annotation[] annotations = fld.getAnnotations(); for (int i=0; i<annotations.length; i++) { if (annotations[i] instanceof Column) { ret.put(fld.getName(), BeanUtilsBean.getInstance().getPropertyUtils().getNestedProperty(bean, fld.getName())); } } } } return ret; }
public static Map<String, Object> getObjectAsMap(Object bean, List<String> fieldList) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Map<String, Object> ret = new HashMap<String, Object>(); List<Field> fields = getAllFields(bean.getClass()); for (Field fld : fields) { if ((fieldList == null) || (fieldList.size() == 0) || (fieldList.indexOf(fld.getName()) != -1)) { Annotation[] annotations = fld.getAnnotations(); for (int i=0; i<annotations.length; i++) { if (annotations[i] instanceof Column) { Column col = (Column)annotations[i]; ret.put(col.name(), BeanUtilsBean.getInstance().getPropertyUtils().getNestedProperty(bean, fld.getName())); } } } } return ret; }
public Object getValue(Object dataObject) { PropertyUtilsBean utils = BeanUtilsBean.getInstance().getPropertyUtils(); try { return utils.getNestedProperty(dataObject, getName()); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new IllegalStateException("cannot access field " + getName() + " for " + dataObject.getClass().getName(), e); } }
/** * Return the value of the (possibly nested) property of the specified * name, for the specified bean, as a String. * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return The nested property's value, converted to a String * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if a nested reference to a * property returns null * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * property cannot be found */ public String getNestedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Object value = getPropertyUtils().getNestedProperty(bean, name); return (getConvertUtils().convert(value)); }
/** * Return the value of the (possibly nested) property of the specified * name, for the specified bean, as a String. * * @param bean Bean whose property is to be extracted * @param name Possibly nested name of the property to be extracted * @return The nested property's value, converted to a String * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * property cannot be found */ public String getNestedProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { final Object value = getPropertyUtils().getNestedProperty(bean, name); return (getConvertUtils().convert(value)); }