Java Code Examples for org.apache.commons.beanutils.PropertyUtils#getNestedProperty()
The following examples show how to use
org.apache.commons.beanutils.PropertyUtils#getNestedProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldUtils.java From rice with Educational Community License v2.0 | 6 votes |
/** * This method verifies that all of the parent objects of propertyName are non-null. * * @param bo * @param propertyName * @return true if all parents are non-null, otherwise false */ static private boolean isObjectTreeNonNullAllTheWayDown(BusinessObject bo, String propertyName) { String[] propertyParts = propertyName.split("\\."); StringBuffer property = new StringBuffer(); for (int i = 0; i < propertyParts.length - 1; i++) { property.append((0 == property.length()) ? "" : ".").append(propertyParts[i]); try { if (null == PropertyUtils.getNestedProperty(bo, property.toString())) { return false; } } catch (Throwable t) { LOG.debug("Either getter or setter not specified for property \"" + property.toString() + "\"", t); return false; } } return true; }
Example 2
Source File: CsvExportTupleImpl.java From yes-cart with Apache License 2.0 | 5 votes |
private Object getObjectValue(final CsvExportColumn column) { final String property = column.getName(); Object rawValue = null; try { rawValue = PropertyUtils.getNestedProperty(getData(), property); } catch (NestedNullException nne) { // do not report, it is just null } catch (Exception exp) { LOG.error("Unable to read property: " + property, exp); } return rawValue; }
Example 3
Source File: PropertyVariable.java From jsqsh with Apache License 2.0 | 5 votes |
@Override public String toString () { try { Object o = getManager().getBean(bean); Object val = PropertyUtils.getNestedProperty(o, property); if (val == null) { return "null"; } return val.toString(); } catch (Throwable e) { if (quiet) { return "null"; } return "Cannot read variable '" + getName() + "': " + e.getMessage() + " (" + e.getClass().getName() + ")"; } }
Example 4
Source File: JavaBeanUtilBenchmark.java From javabeanutil-benchmark with MIT License | 4 votes |
/** * Reference: http://commons.apache.org/proper/commons-beanutils/ */ @Benchmark public Object apacheBeanUtils() throws Exception { return PropertyUtils.getNestedProperty(javaBean, fieldName); }
Example 5
Source File: CourseService.java From tutorials with MIT License | 4 votes |
public static String getNestedValue(Course course, String enrollId, String nestedPropertyName) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return (String) PropertyUtils.getNestedProperty(course, "enrolledStudent(" + enrollId + ")." + nestedPropertyName); }