| java.lang.Object org.jaffa.util.BeanHelper
BeanHelper | public class BeanHelper (Code) | | This has convenience methods for dealing with Java Beans.
|
Method Summary | |
public static Object | convertDataType(Class beanClass, String propertyName, String propertyValue) This method will introspect the beanClass & get the getter method for the input propertyName.
It will then try & convert the propertyValue to the appropriate datatype.
Parameters: beanClass - The bean class to be introspected. Parameters: propertyName - The Property being searched for. Parameters: propertyValue - The value to be converted. throws: IntrospectionException - if an exception occurs during introspection. throws: IllegalArgumentException - if the propertyValue cannot be converted to the appropriate datatype. | public static Object | getField(Object bean, String field) This will inspect the specified java bean, and extract an Object from the beans
getXxx() method, where 'xxx' is the field name passed in.
A null will be returned in case there is any error in invoking the getter.
Parameters: bean - The Java Bean. Parameters: field - The field. throws: NoSuchMethodException - if there is no getter for the input field. | public static String | getReaderName(String field) Get the name of the reader method for the specified string.
For example 'hello' will return 'getHello'
Parameters: field - The field. | public static boolean | setField(Object bean, String propertyName, String propertyValue) This method will introspect the bean & get the setter method for the input propertyName.
It will then try & convert the propertyValue to the appropriate datatype.
Finally it will invoke the setter.
A true indicates, the property was succesfully set to the passed value. |
convertDataType | public static Object convertDataType(Class beanClass, String propertyName, String propertyValue) throws IntrospectionException, IllegalArgumentException(Code) | | This method will introspect the beanClass & get the getter method for the input propertyName.
It will then try & convert the propertyValue to the appropriate datatype.
Parameters: beanClass - The bean class to be introspected. Parameters: propertyName - The Property being searched for. Parameters: propertyValue - The value to be converted. throws: IntrospectionException - if an exception occurs during introspection. throws: IllegalArgumentException - if the propertyValue cannot be converted to the appropriate datatype. a converted propertyValue compatible with the getter. |
getField | public static Object getField(Object bean, String field) throws NoSuchMethodException(Code) | | This will inspect the specified java bean, and extract an Object from the beans
getXxx() method, where 'xxx' is the field name passed in.
A null will be returned in case there is any error in invoking the getter.
Parameters: bean - The Java Bean. Parameters: field - The field. throws: NoSuchMethodException - if there is no getter for the input field. the output of the getter for the field. |
getReaderName | public static String getReaderName(String field)(Code) | | Get the name of the reader method for the specified string.
For example 'hello' will return 'getHello'
Parameters: field - The field. the name of the reader/getter method for the specified string. |
setField | public static boolean setField(Object bean, String propertyName, String propertyValue) throws IntrospectionException, IllegalAccessException, InvocationTargetException(Code) | | This method will introspect the bean & get the setter method for the input propertyName.
It will then try & convert the propertyValue to the appropriate datatype.
Finally it will invoke the setter.
A true indicates, the property was succesfully set to the passed value. A false indicates the property doesn't exist or the propertyValue passed is not compatible with the setter. Parameters: bean - The bean class to be introspected. Parameters: propertyName - The Property being searched for. Parameters: propertyValue - The value to be set. throws: IntrospectionException - if an exception occurs during introspection. throws: IllegalAccessException - if the underlying method is inaccessible. throws: InvocationTargetException - if the underlying method throws an exception. |
|
|