protected boolean propertyInScope(Object obj, String property, Set<Object> scope) { if (null == obj) { return false; } try { Object value = BeanUtilsBean.getInstance().getProperty(obj, property); if (null != value) { return scope.contains(value); } } catch (Exception ignore) { logger.warn("can not get property {} from {},{}", property, obj, ignore.getMessage()); } return true; }
public static <P> Properties getProperties(P bean, Properties properties) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { synchronized (beanUtils) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, null)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { properties.put(descriptor.getName(), value); } } } } return properties; }
public static String getData(List<String> ignored, Object... beans) throws Exception { StringBuilder sb = new StringBuilder(); boolean empty = true; synchronized (beanUtils) { for (Object bean : beans) { if (bean != null) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { if (!empty) { sb.append("&"); } empty = false; sb.append(descriptor.getName()).append("=").append(encodeURI(value)); } } } } } } return sb.toString(); }
/** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, as a String.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return The property's value, converted to a String * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * property cannot be found * @see BeanUtilsBean#getProperty */ public static String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return BeanUtilsBean.getInstance().getProperty(bean, name); }
for (DynaProperty descriptor : descriptors) { final String name = descriptor.getName(); description.put(name, getProperty(bean, name)); final String name = descriptor.getName(); if (getPropertyUtils().getReadMethod(clazz, descriptor) != null) { description.put(name, getProperty(bean, name));
/** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, as a String.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return The property's value, converted to a String * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * property cannot be found * @see BeanUtilsBean#getProperty */ public static String getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return BeanUtilsBean.getInstance().getProperty(bean, name); }
for (DynaProperty descriptor : descriptors) { final String name = descriptor.getName(); description.put(name, getProperty(bean, name)); final String name = descriptor.getName(); if (getPropertyUtils().getReadMethod(clazz, descriptor) != null) { description.put(name, getProperty(bean, name));
/** * Return a map where key is the foreign key and value is the entity. */ private Map<String, Object> buildMap(final List<?> list, final String property) throws ReflectiveOperationException { final Map<String, Object> result = new HashMap<>(); for (final Object item : list) { final Object value = beanUtilsBean.getProperty(item, property); if (value != null) { result.put(String.valueOf(value), item); } } return result; } }
public static <P> Properties getProperties(P bean, Properties properties) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { synchronized (beanUtils) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, null)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { properties.put(descriptor.getName(), value); } } } } return properties; }
protected boolean propertyInScope(Object obj, String property, Set<Object> scope) { if (null == obj) { return false; } try { Object value = BeanUtilsBean.getInstance().getProperty(obj, property); if (null != value) { return scope.contains(value); } } catch (Exception ignore) { logger.warn("can not get property {} from {},{}", property, obj, ignore.getMessage()); } return true; }
public static <P> Properties getProperties(P bean, Properties properties) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { synchronized (beanUtils) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, null)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { properties.put(descriptor.getName(), value); } } } } return properties; }
/** * Write a field */ private void writeField(final Object o, final String header) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException { final String value = BeanUtilsBean.getInstance().getProperty(o, header); if (value != null) { writer.write(StringEscapeUtils.escapeCsv(value)); } }
public static <P> Properties getProperties(P bean, Properties properties) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { synchronized (beanUtils) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, null)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { properties.put(descriptor.getName(), value); } } } } return properties; }
/** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, as a String.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return The property's value, converted to a String * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * property cannot be found * @see BeanUtilsBean#getProperty */ public static String getProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return BeanUtilsBean.getInstance().getProperty(bean, name); }
public static String getData(List<String> ignored, Object... beans) throws Exception { StringBuilder sb = new StringBuilder(); boolean empty = true; synchronized (beanUtils) { for (Object bean : beans) { if (bean != null) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { if (!empty) { sb.append("&"); } empty = false; sb.append(descriptor.getName()).append("=").append(encodeURI(value)); } } } } } } return sb.toString(); }
/** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, as a String.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return The property's value, converted to a String * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * property cannot be found * @see BeanUtilsBean#getProperty */ public static String getProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return BeanUtilsBean.getInstance().getProperty(bean, name); }
public static String getData(List<String> ignored, Object... beans) throws Exception { StringBuilder sb = new StringBuilder(); boolean empty = true; synchronized (beanUtils) { for (Object bean : beans) { if (bean != null) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { if (!empty) { sb.append("&"); } empty = false; sb.append(descriptor.getName()).append("=").append(encodeURI(value)); } } } } } } return sb.toString(); }
/** * <p>Return the value of the specified property of the specified bean, * no matter which property reference format is used, as a String.</p> * * <p>For more details see <code>BeanUtilsBean</code>.</p> * * @param bean Bean whose property is to be extracted * @param name Possibly indexed and/or nested name of the property * to be extracted * @return The property's value, converted to a String * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * property cannot be found * @see BeanUtilsBean#getProperty */ public static String getProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return BeanUtilsBean.getInstance().getProperty(bean, name); }
public static String getData(List<String> ignored, Object... beans) throws Exception { StringBuilder sb = new StringBuilder(); boolean empty = true; synchronized (beanUtils) { for (Object bean : beans) { if (bean != null) { PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored)) { String value = beanUtils.getProperty(bean, descriptor.getName()); if (value != null) { if (!empty) { sb.append("&"); } empty = false; sb.append(descriptor.getName()).append("=").append(encodeURI(value)); } } } } } } return sb.toString(); }
private static void checkEquals(Object factory, Object factory2) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { BeanUtilsBean bean = new BeanUtilsBean(); PropertyDescriptor[] descriptors = bean.getPropertyUtils().getPropertyDescriptors(factory); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getWriteMethod() != null && descriptor.getReadMethod() != null) { Assert.assertEquals(descriptor.getName() + " incorrect", bean.getProperty(factory, descriptor.getName()), bean.getProperty(factory2, descriptor.getName())); } } }