com.fernsroth.easyio.util
Class BeanUtils

java.lang.Object
  extended by com.fernsroth.easyio.util.BeanUtils

public final class BeanUtils
extends java.lang.Object

Author:
Joseph M. Ferner (Near Infinity Corporation)

Method Summary
static java.lang.reflect.Method findGetterMethod(java.lang.Class<?> clazz, java.lang.String name)
          finds a getter method in a class.
static java.lang.reflect.Method findSetterMethod(java.lang.Class<?> clazz, java.lang.String name)
          finds a setter method in the class.
static java.util.List<java.lang.reflect.Field> getAllFields(java.lang.Class<?> clazz)
          gets a list of all the fields including base classes.
static java.lang.Object getValue(java.lang.Object obj, java.lang.reflect.Field field)
          gets a named value from an object.
static void setValue(java.lang.Object obj, java.lang.reflect.Field field, java.lang.Object val)
          sets a value into an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValue

public static java.lang.Object getValue(java.lang.Object obj,
                                        java.lang.reflect.Field field)
                                 throws GetterNotFoundException
gets a named value from an object.

Parameters:
obj - the object to get the value from.
field - the field to set.
Returns:
the value of the named field.
Throws:
GetterNotFoundException

findGetterMethod

public static java.lang.reflect.Method findGetterMethod(java.lang.Class<?> clazz,
                                                        java.lang.String name)
finds a getter method in a class.

Parameters:
clazz - the class to get the metter method from.
name - the name of the field.
Returns:
the getter method. null, if not found.

getAllFields

public static java.util.List<java.lang.reflect.Field> getAllFields(java.lang.Class<?> clazz)
gets a list of all the fields including base classes.

Parameters:
clazz - the class to read.
Returns:
the fields.

setValue

public static void setValue(java.lang.Object obj,
                            java.lang.reflect.Field field,
                            java.lang.Object val)
                     throws SetterNotFoundException
sets a value into an object.

Parameters:
obj - the object to the value into.
field - the field name.
val - the value.
Throws:
SetterNotFoundException

findSetterMethod

public static java.lang.reflect.Method findSetterMethod(java.lang.Class<?> clazz,
                                                        java.lang.String name)
finds a setter method in the class.

Parameters:
clazz - the class to search.
name - the name of the field.
Returns:
the setter method.


Copyright © 2006 null. All Rights Reserved.