List of usage examples for org.apache.commons.beanutils NestedNullException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.kuali.rice.kns.web.struts.form.pojo.PojoPropertyUtilsBean.java
public Class getPropertyType(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { if (bean == null) { throw new IllegalArgumentException("No bean specified"); }/* w w w . ja va 2 s.c o m*/ if (name == null) { throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'"); } // Resolve nested references while (getResolver().hasNested(name)) { String next = getResolver().next(name); Object nestedBean = getProperty(bean, next); if (nestedBean == null) { Class<?>[] paramTypes = {}; Method method = null; try { method = bean.getClass().getMethod( "get" + next.substring(0, 1).toUpperCase() + next.substring(1), (Class[]) null); } catch (NoSuchMethodException e) { method = bean.getClass().getMethod( "is" + next.substring(0, 1).toUpperCase() + next.substring(1), (Class[]) null); } try { nestedBean = ObjectUtils.createNewObjectFromClass(method.getReturnType()); } catch (RuntimeException e) { NestedNullException nne = new NestedNullException( "Null property value for '" + next + "' on bean class '" + bean.getClass() + "'"); nne.initCause(e); throw nne; } } bean = nestedBean; name = getResolver().remove(name); } // Remove any subscript from the final name value name = getResolver().getProperty(name); // Special handling for DynaBeans if (bean instanceof DynaBean) { DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name); if (descriptor == null) { return (null); } Class type = descriptor.getType(); if (type == null) { return (null); } else if (type.isArray()) { return (type.getComponentType()); } else { return (type); } } PropertyDescriptor descriptor = getPropertyDescriptor(bean, name); if (descriptor == null) { return (null); } else if (descriptor instanceof IndexedPropertyDescriptor) { return (((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType()); } else if (descriptor instanceof MappedPropertyDescriptor) { return (((MappedPropertyDescriptor) descriptor).getMappedPropertyType()); } else { return (descriptor.getPropertyType()); } }