List of usage examples for org.apache.commons.beanutils PropertyUtils getPropertyDescriptor
public static PropertyDescriptor getPropertyDescriptor(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Retrieve the property descriptor for the specified property of the specified bean, or return null
if there is no such descriptor.
For more details see PropertyUtilsBean
.
From source file:us.mn.state.health.lims.common.provider.reports.toplink.QueryResultDataSource.java
public Object getFieldValue(JRField field) throws JRException { Object value = null;//from w ww. j a v a 2 s . com try { Method getter = PropertyUtils .getReadMethod(PropertyUtils.getPropertyDescriptor(currentValue, field.getName())); value = getter.invoke(currentValue, (Object[]) null); } catch (Exception ex) { //bugzilla 2154 LogEvent.logError("QueryResultDataSource", "getFieldValue()", ex.toString()); } return value; }
From source file:us.mn.state.health.lims.reports.valueholder.common.JRHibernateDataSource.java
private Object nestedFieldValue(Object object, String field) { Object value = null;//ww w .jav a 2 s .co m if (field.indexOf("__") > -1) { try { Method nestedGetter = PropertyUtils.getReadMethod( PropertyUtils.getPropertyDescriptor(object, field.substring(0, field.indexOf("__")))); Object nestedObject = nestedGetter.invoke(object, (Object[]) null); value = nestedFieldValue(nestedObject, field.substring(field.indexOf("__") + 2, field.length())); } catch (Exception ex) { //bugzilla 2154 LogEvent.logError("JRHibernateDataSource", "nestedFieldValue()", ex.toString()); } } else { try { Method getter = PropertyUtils.getReadMethod(PropertyUtils.getPropertyDescriptor(object, field)); value = getter.invoke(object, (Object[]) null); if (Collection.class.isAssignableFrom(getter.getReturnType())) { return new JRHibernateDataSource((Collection) value); } if (Map.class.isAssignableFrom(getter.getReturnType())) { return new JRHibernateDataSource((Map) value); } } catch (Exception ex) { //bugzilla 2154 LogEvent.logError("JRHibernateDataSource", "nestedFieldValue()", ex.toString()); } } return value; }