List of usage examples for org.apache.commons.beanutils PropertyUtils getIndexedProperty
public static Object getIndexedProperty(Object bean, String name, int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified indexed property of the specified bean, with no type conversions.
For more details see PropertyUtilsBean
.
From source file:org.apache.shiro.config.ReflectionBuilder.java
private Object getIndexedProperty(Object object, String propertyPath, int index) { try {//from w w w . j a va 2s. com return PropertyUtils.getIndexedProperty(object, propertyPath, index); } catch (Exception e) { throw new ConfigurationException("Unable to acquire array property '" + propertyPath + "'", e); } }
From source file:org.oddjob.framework.WrapDynaBean.java
/** * Return the value of an indexed property with the specified name. * * @param name Name of the property whose value is to be retrieved * @param index Index of the value to be retrieved * * @exception IllegalArgumentException if there is no property * of the specified name/*from w w w . j a va 2 s. c o m*/ * @exception IllegalArgumentException if the specified property * exists, but is not indexed * @exception IndexOutOfBoundsException if the specified index * is outside the range of the underlying property * @exception NullPointerException if no array or List has been * initialized for this property */ public Object get(String name, int index) { if (!dynaClass.isReadable(name)) { return null; } Object value = null; try { value = PropertyUtils.getIndexedProperty(instance, name, index); } catch (IndexOutOfBoundsException e) { throw e; } catch (Throwable t) { throw new IllegalArgumentException("Property '" + name + "' has no indexed read method"); } return (value); }
From source file:org.xaloon.core.jpa.audit.JpaAuditFacade.java
private void createAuditDetails(AuditEntity ae, Object auditObject, Class<?> parentClass) { if (parentClass == null) { return;//from w w w . j a va 2s . com } for (Field field : parentClass.getDeclaredFields()) { Auditable annotation = field.getAnnotation(Auditable.class); if (annotation != null) { String fieldName = field.getName(); try { if (annotation.index() > -1) { Object value = PropertyUtils.getIndexedProperty(auditObject, fieldName, annotation.index()); createAuditDetails(ae, value, value.getClass()); } else { Object value = PropertyUtils.getSimpleProperty(auditObject, fieldName); AuditEntityItem details = newAuditEntityItem(); details.setAuditEntity(ae); details.setCreateDate(new Date()); details.setUpdateDate(new Date()); details.setName(parentClass.getName() + "." + fieldName); if (value != null) { details.setValue(value.toString()); } details.setKey(annotation.key()); ae.getAuditEntityItems().add(details); } } catch (Exception e) { logger.error("Exception while getting audit field value", e); } } } createAuditDetails(ae, auditObject, parentClass.getSuperclass()); }