org.jtheque.utils.bean
Class ReflectionUtils

java.lang.Object
  extended by org.jtheque.utils.bean.ReflectionUtils

public final class ReflectionUtils
extends Object

An utility class for Reflection.

Author:
Baptiste Wicht

Method Summary
static String getGetter(String property)
          Return the name of the getter for the specified property name.
static Method getGetterMethod(Object bean, String property)
          Return the getter method for the property of the specified bean.
static PropertyDescriptor[] getProperties(Object bean)
          Return all the properties of a bean.
static Object getProperty(Object bean, PropertyDescriptor property)
          Return the value of a property.
static Object getProperty(Object bean, String property)
          Return the value of a property.
static Object getPropertyValue(Object bean, String property)
          Return the value of the property of the specified bean.
static String getSetter(String property)
          Return the name of the setter for the specified property name.
static Method getSetterMethod(Object bean, String property)
          Return the setter method for the property of the specified bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGetter

public static String getGetter(String property)
Return the name of the getter for the specified property name.

Parameters:
property - The property name.
Returns:
The name of the getter for the specified property.

getGetterMethod

public static Method getGetterMethod(Object bean,
                                     String property)
Return the getter method for the property of the specified bean.

Parameters:
bean - The bean to get the property from.
property - The property name.
Returns:
The getter Method object or null if there is no getter for this property.

getSetter

public static String getSetter(String property)
Return the name of the setter for the specified property name.

Parameters:
property - The property name.
Returns:
The name of the setter for the specified property.

getSetterMethod

public static Method getSetterMethod(Object bean,
                                     String property)
Return the setter method for the property of the specified bean.

Parameters:
bean - The bean to set the property to.
property - The property name.
Returns:
The setter Method object or null if there is no setter for this property.

getPropertyValue

public static Object getPropertyValue(Object bean,
                                      String property)
Return the value of the property of the specified bean.

Parameters:
bean - The bean to get the value from.
property - The property name.
Returns:
The value of the property or null if there is no getter method.

getProperty

public static Object getProperty(Object bean,
                                 PropertyDescriptor property)
Return the value of a property.

Note : The properties of the Object class are not retrieved.

Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.

getProperties

public static PropertyDescriptor[] getProperties(Object bean)
Return all the properties of a bean. The results are cached using the Introspector class.

Note : The properties of the Object class are not retrieved.

Parameters:
bean - The bean to extract the properties from.
Returns:
An array containing all the properties of the bean or an empty array if there was an error during the property retrieving process.

getProperty

public static Object getProperty(Object bean,
                                 String property)
Return the value of a property.

Note : The properties of the Object class are not retrieved.

Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.


Copyright © 2010 JTheque. All Rights Reserved.