List of usage examples for org.apache.commons.beanutils PropertyUtils isReadable
public static boolean isReadable(Object bean, String name)
Return true
if the specified property name identifies a readable property on the specified bean; otherwise, return false
.
For more details see PropertyUtilsBean
.
From source file:see.properties.impl.BeanPropertyResolver.java
@Override public boolean canGet(@Nullable Object target, @Nonnull PropertyAccess propertyAccess) { return isBeanProperty(propertyAccess) && PropertyUtils.isReadable(target, getPropertyName(propertyAccess)); }
From source file:service.ExcelWorkSheetHandler.java
private String getPropertyValue(Object targetObj, String propertyName) { String value = ""; if (null == targetObj || StringUtils.isBlank(propertyName)) { LOG.error("targetObj or propertyName is null, both require to retrieve a value"); return value; }/*from ww w .j a v a 2 s . co m*/ if (PropertyUtils.isReadable(targetObj, propertyName)) { Object v = null; try { v = PropertyUtils.getSimpleProperty(targetObj, propertyName); } catch (IllegalAccessException ex) { Logger.getLogger(ExcelWorkSheetHandler.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(ExcelWorkSheetHandler.class.getName()).log(Level.SEVERE, null, ex); } catch (NoSuchMethodException ex) { Logger.getLogger(ExcelWorkSheetHandler.class.getName()).log(Level.SEVERE, null, ex); } if (null != v && StringUtils.isNotBlank(v.toString())) { value = v.toString(); } } else { LOG.error("Given property (" + propertyName + ") is not readable!"); } return value; }
From source file:ubic.gemma.annotation.reference.BibliographicReferenceServiceException.java
/** * Finds the root cause of the parent exception by traveling up the exception tree *///from w w w . ja v a2s . c om private static Throwable findRootCause(Throwable th) { if (th != null) { // Reflectively get any exception causes. try { Throwable targetException = null; // java.lang.reflect.InvocationTargetException String exceptionProperty = "targetException"; if (PropertyUtils.isReadable(th, exceptionProperty)) { targetException = (Throwable) PropertyUtils.getProperty(th, exceptionProperty); } else { exceptionProperty = "causedByException"; // javax.ejb.EJBException if (PropertyUtils.isReadable(th, exceptionProperty)) { targetException = (Throwable) PropertyUtils.getProperty(th, exceptionProperty); } } if (targetException != null) { th = targetException; } } catch (Exception ex) { // just print the exception and continue ex.printStackTrace(); } if (th.getCause() != null) { th = th.getCause(); th = findRootCause(th); } } return th; }