|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jbeans.JavaBeanTools
This class is a library of tools that can be used when working with JavaBeans.
Inner Class Summary | |
static class |
JavaBeanTools.IndexHelper
This class is a small helper class that is used in the beans pacakge for assisting with indexing operations. |
static class |
JavaBeanTools.NameHelper
This class is a small helper class that is used in the beans pacakge for assisting with property names |
Field Summary | |
static String |
GET_STRING
The string that starts standard Java bean retrieval methods get |
static String |
HANDLE_STRING
The string that starts non-standard Java bean handle methods handle |
static String |
IS_STRING
The string that starts standard Java bean boolean retrieval methods is |
static String |
SET_STRING
The string that starts standard Java bean update methods set |
Method Summary | |
static Object |
callGetter(BeanProperty prop,
Object bean)
Another convience method that calls a java bean getter and returns the value. |
static Object |
callGetter(String property,
Object bean)
Another convience method for calling a getter on a java bean. |
static Object |
callIndexedGetter(BeanProperty prop,
Object bean,
int index)
Another convience method that calls an indexed java bean getter and returns the value. |
static void |
callIndexedSetter(BeanProperty prop,
Object bean,
int index,
Object param)
Another convience method for calling a setter on a java bean. |
static void |
callSetter(BeanProperty prop,
Object bean,
Object param)
Another convience method for calling a setter on a java bean. |
static void |
callSetter(String property,
Object bean,
Object param)
Another convience method for calling a setter on a java bean. |
static String |
capitalize(String lowerCase)
Capitalizes the first letter of the given String. |
static JavaBeanTools.IndexHelper |
findIndex(String propertyName)
Given the property name string, the index and property name are extracted and returned in a new IndexHelper. |
static JavaBeanTools.IndexHelper |
findIndex(String propertyName,
JavaBeanTools.IndexHelper indexHelper)
Given the property name string, the index and property name are extracted and returned in the given IndexHelper. |
static Method |
findIndexedReadMethod(String property,
Class beanClass)
Finds a get method in the class given for the given property. |
static Method |
findIndexedWriteMethod(String property,
Class beanClass,
Class type)
Finds a set indexed method for the given property and parameter type |
static Method |
findReadMethod(String property,
Class beanClass)
Finds either a get method or is method in the class given for the given property name. |
static Method |
findWriteMethod(String property,
Class beanClass,
Class type)
Finds a set method for the given property and parameter type |
static String |
getPropertyName(Method method)
Using the given Method, it returns the name of the java bean property. Examples: |
static boolean |
isValidGetter(Method method)
Check if the method is a proper java bean getter-property method. |
static boolean |
isValidGetter(Method method,
boolean checkName)
Does the same check as isValidGetter() is checkName
is true, but does not check the name if checkName is false. |
static boolean |
isValidIndexedGetter(Method method)
Check if the method is a proper java bean indexed getter method. |
static boolean |
isValidIndexedGetter(Method method,
boolean checkName)
Does the same check as isValidIndexedGetter()
if checkName is true, but does not check the name if checkName is false. |
static boolean |
isValidIndexedSetter(Method method)
Check if the method is a proper java bean indexed setter method. |
static boolean |
isValidIndexedSetter(Method method,
boolean checkName)
Does the same check as isValidIndexedSetter()
if checkName is true, but does not check the name if checkName is false. |
static boolean |
isValidSetter(Method method)
Check if the method is a proper java bean setter-property method. |
static boolean |
isValidSetter(Method method,
boolean checkName)
Does the same check as isValidSetter() is checkName
is true, but does not check the name if checkName is false. |
static String |
makeGetter(String propertyName)
Using the propertyName, returns the Java Bean standard getter method name. |
static String |
makeHandle(String propertyName)
Using the propertyName, returns the non-standard Java Bean handle method name. |
static String |
makeIs(String propertyName)
Using the propertyName, returns the Java Bean standard boolean getter method name. |
static String |
makeSetter(String propertyName)
Using the propertyName, returns the Java Bean standard setter method name. |
static JavaBeanTools.IndexHelper |
removeIndices(String propertyName)
This method takes the given property string and removes all the indices from it and stores them in an List. |
static JavaBeanTools.NameHelper |
splitName(String propertyName)
Using the given nested property name, this returns the local property name and the remainder of the nested property name, if any. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String GET_STRING
public static final String SET_STRING
public static final String IS_STRING
public static final String HANDLE_STRING
Method Detail |
public static String getPropertyName(Method method)
getFoo -> foo
getX -> x
getURL -> URL
method
- The method to translatepublic static String capitalize(String lowerCase)
lowerCase
- The string to capitalizeNullPointerException
- If the parameter is nullpublic static String makeGetter(String propertyName)
propertyName
- The property name to make into the name of the getter
methodNullPointerException
- If the parameter is nullpublic static String makeSetter(String propertyName)
propertyName
- The property name to make into the name of the setter
methodNullPointerException
- If the parameter is nullpublic static String makeIs(String propertyName)
propertyName
- The property name to make into the name of the is
methodNullPointerException
- If the parameter is nullpublic static String makeHandle(String propertyName)
propertyName
- The property name to make into the name of the handle
methodNullPointerException
- If the parameter is nullpublic static boolean isValidGetter(Method method)
method
- The method to checkpublic static boolean isValidIndexedGetter(Method method)
method
- The method to checkpublic static boolean isValidGetter(Method method, boolean checkName)
isValidGetter()
is checkName
is true, but does not check the name if checkName is false. The only benefit of
not checking the name is the performance increase. Checking the name is a simple
procedure but requires a number of string comparisons and method calls.method
- The method to checkcheckName
- Whether or not to check the method's namepublic static boolean isValidIndexedGetter(Method method, boolean checkName)
isValidIndexedGetter()
if checkName is true, but does not check the name if checkName is false. The only
benefit of not checking the name is the performance increase. Checking the name
is a simple procedure but requires a number of string comparisons and method calls.method
- The method to checkcheckName
- Whether or not to check the method namepublic static boolean isValidSetter(Method method)
method
- The method to checkpublic static boolean isValidIndexedSetter(Method method)
method
- The method to checkpublic static boolean isValidSetter(Method method, boolean checkName)
isValidSetter()
is checkName
is true, but does not check the name if checkName is false. The only benefit of
not checking the name is the performance increase. Checking the name is a simple
procedure but requires a number of string comparisons and method calls.method
- The method to checkcheckName
- Whether or not to check the method namepublic static boolean isValidIndexedSetter(Method method, boolean checkName)
isValidIndexedSetter()
if checkName is true, but does not check the name if checkName is false. The only
benefit of not checking the name is the performance increase. Checking the name
is a simple procedure but requires a number of string comparisons and method calls.method
- The method to checkcheckName
- Whether or not to check the method namepublic static Method findReadMethod(String property, Class beanClass) throws BeanException
property
- The name of the property to find the write method forbeanClass
- The class object for the beanBeanException
- If the write method can not be foundNullPointerException
- If the property String is nullpublic static Method findIndexedReadMethod(String property, Class beanClass) throws BeanException
property
- The name of the property to find the indexed write method forbeanClass
- The class object for the beanBeanException
- If the write method can not be foundpublic static Method findWriteMethod(String property, Class beanClass, Class type) throws BeanException
property
- The name of the property to findbeanClass
- The class object for the beantype
- The parameter type to use when locating the write methodBeanException
- If the write method can not be foundpublic static Method findIndexedWriteMethod(String property, Class beanClass, Class type) throws BeanException
property
- The name of the property to findbeanClass
- The class object for the beantype
- The parameter type to use when locating the write methodBeanException
- If the write method can not be foundpublic static Object callGetter(String property, Object bean) throws BeanException
property
- The name of the propertybean
- The object to call it onBeanException
- If something goes wrongpublic static Object callGetter(BeanProperty prop, Object bean) throws BeanException
prop
- The BeanProperty object to usebean
- The java bean object to call it onBeanException
- If there was a problem calling the getterpublic static Object callIndexedGetter(BeanProperty prop, Object bean, int index) throws BeanException
prop
- The BeanProperty object to usebean
- The java bean object to call it onindex
- The index to be passed to the getter methodBeanException
- If there was a problem calling the getterpublic static void callSetter(String property, Object bean, Object param) throws BeanException
property
- The name of the property of the setterbean
- The java bean object to call it onparam
- The parameter to the setter (java bean standard)BeanException
- If the property is not a valid property or a read only
property or if the setter called threw an exception or if the param
is the incorrect type for the setter methodpublic static void callSetter(BeanProperty prop, Object bean, Object param) throws BeanException
prop
- The BeanProperty object to use when calling the setterobject
- The object to call it onparam
- The parameter to the setter (java bean standard)BeanException
- If the property a read only property or if the setter
called threw an exception or if the param is the incorrect type for
the setter methodpublic static void callIndexedSetter(BeanProperty prop, Object bean, int index, Object param) throws BeanException
prop
- The BeanProperty object to use when calling the setterobject
- The object to call it onindex
- The index of the property to setparam
- The parameter to the setter (java bean standard)BeanException
- If the property a read only property or if the setter
called threw an exception or if the param is the incorrect type for
the setter methodpublic static JavaBeanTools.NameHelper splitName(String propertyName)
propertyName
- The nested (or local) property name to extract the local
and nested property names from.public static JavaBeanTools.IndexHelper findIndex(String propertyName) throws BeanException
propertyName
- The name of the property to search for the indexBeanException
- If the property name contains an invild index or an
unclosed index notation (i.e. '[1')public static JavaBeanTools.IndexHelper findIndex(String propertyName, JavaBeanTools.IndexHelper indexHelper) throws BeanException
propertyName
- The name of the property to search for the indexindexHelper
- The IndexHelper instance to store the new information in
and the same IndexHelper instance that is returnedBeanException
- If the property name contains an invalid index or an
unclosed index notation (i.e. '[1')public static JavaBeanTools.IndexHelper removeIndices(String propertyName) throws BeanException
propertyName
- The name of the property to extract the indices fromBeanException
- If the property name contains one or invalid indice(s) or an
unclosed index notation (i.e. '[1')
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |