org.riotfamily.common.beans
Class PropertyUtils

java.lang.Object
  extended by org.riotfamily.common.beans.PropertyUtils

public final class PropertyUtils
extends Object

Utility class to access bean properties via relection.


Method Summary
static
<T> T
convert(String s, Class<T> targetClass)
           
static String convertToString(Object value)
           
static ObjectWrapper createWrapper(Object obj)
           
static String evaluate(String expression, Object bean)
           
static Method findReadMethod(Class<?> clazz, String property)
           
static Method findWriteMethod(Class<?> clazz, String property)
           
static Class<?> getDeclaringClass(Class<?> clazz, String property)
          Returns the (super-)class where the given property is declared.
static Map<String,Object> getProperties(Object bean)
          Returns a Map containing the bean's properties.
static Map<String,Object> getProperties(Object bean, String[] propertyNames)
          Returns a Map containing the bean's properties.
static Object getProperty(Object bean, String name)
           
static
<T> T
getProperty(Object bean, String name, Class<T> requiredType)
           
static String getPropertyAsString(Object bean, String name)
           
static Class<?> getPropertyType(Class<?> clazz, String propertyPath)
           
static void setProperties(Object bean, Map<String,?> properties)
          Sets properties from the given Map.
static void setProperty(Object bean, String name, Object value)
           
static void setPropertyAsString(Object bean, String name, String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createWrapper

public static ObjectWrapper createWrapper(Object obj)

getProperty

public static Object getProperty(Object bean,
                                 String name)

getProperty

public static <T> T getProperty(Object bean,
                                String name,
                                Class<T> requiredType)

getPropertyAsString

public static String getPropertyAsString(Object bean,
                                         String name)

setProperty

public static void setProperty(Object bean,
                               String name,
                               Object value)

setPropertyAsString

public static void setPropertyAsString(Object bean,
                                       String name,
                                       String s)

getProperties

public static Map<String,Object> getProperties(Object bean)
Returns a Map containing the bean's properties.

Since:
6.4

getProperties

public static Map<String,Object> getProperties(Object bean,
                                               String[] propertyNames)
Returns a Map containing the bean's properties.

Since:
6.4

setProperties

public static void setProperties(Object bean,
                                 Map<String,?> properties)
Sets properties from the given Map.

Since:
8.0
See Also:
MutablePropertyValues.addPropertyValues(Map)

evaluate

public static String evaluate(String expression,
                              Object bean)
Since:
6.4

convert

public static <T> T convert(String s,
                            Class<T> targetClass)

convertToString

public static String convertToString(Object value)
Since:
6.4

getPropertyType

public static Class<?> getPropertyType(Class<?> clazz,
                                       String propertyPath)

findReadMethod

public static Method findReadMethod(Class<?> clazz,
                                    String property)
Since:
6.4

findWriteMethod

public static Method findWriteMethod(Class<?> clazz,
                                     String property)
Since:
6.4

getDeclaringClass

public static Class<?> getDeclaringClass(Class<?> clazz,
                                         String property)
Returns the (super-)class where the given property is declared.