org.springframework.richclient.widget.table
Class ClassUtils

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.widget.table.ClassUtils

public class ClassUtils
extends Object

A number of helper classes to retrieve getter and setter methods.

Since:
0.5.0
Author:
Jan Hoskens

Method Summary
static String capitalize(String s)
          Small helper method to capitalize the first character of the given string.
static Accessor getAccessorForProperty(Class<?> clazz, String propertyName)
          Create an Accessor for the given property.
static Method getReadMethod(Class<?> clazz, String propertyName)
          Lookup the getter method for the given property.
static Class<?> getTypeForProperty(Method getter)
          Returns the type of the property checking if it actually does return something and wrapping primitives if needed.
static Method getWriteMethod(Class<?> clazz, String propertyName, Class<?> propertyType)
          Lookup the setter method for the given property.
static Writer getWriterForProperty(Class<?> beanClass, String propertyName)
          Create a Writer for the given property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getReadMethod

public static Method getReadMethod(Class<?> clazz,
                                   String propertyName)
                            throws NoSuchMethodError
Lookup the getter method for the given property. This can be a getXXX() or a isXXX() method.

Parameters:
clazz - type which contains the property.
propertyName - name of the property.
Returns:
a Method with read-access for the property.
Throws:
NoSuchMethodError

getTypeForProperty

public static Class<?> getTypeForProperty(Method getter)
Returns the type of the property checking if it actually does return something and wrapping primitives if needed.

Parameters:
getter - the method to access the property.
Returns:
the type of the property.
Throws:
IllegalArgumentException - if the method has a Void return type.

getWriteMethod

public static final Method getWriteMethod(Class<?> clazz,
                                          String propertyName,
                                          Class<?> propertyType)
Lookup the setter method for the given property.

Parameters:
clazz - type which contains the property.
propertyName - name of the property.
propertyType - type of the property.
Returns:
a Method with write-access for the property.

capitalize

public static String capitalize(String s)
Small helper method to capitalize the first character of the given string.

Parameters:
s - string to capitalize
Returns:
a string starting with a capital character.

getAccessorForProperty

public static Accessor getAccessorForProperty(Class<?> clazz,
                                              String propertyName)
Create an Accessor for the given property. A property may be nested using the dot character.

Parameters:
clazz - the type containing the property.
propertyName - the name of the property.
Returns:
an Accessor for the property.

getWriterForProperty

public static Writer getWriterForProperty(Class<?> beanClass,
                                          String propertyName)
Create a Writer for the given property. A property may be nested using the dot character.

Parameters:
clazz - the type containing the property.
propertyName - the name of the property.
Returns:
a Writer for the property.


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.