com.jalios.util
Class ReflectUtil

java.lang.Object
  extended by com.jalios.util.ReflectUtil

public class ReflectUtil
extends Object


Field Summary
static String REVISION
           
 
Constructor Summary
ReflectUtil()
           
 
Method Summary
static Object fieldGetter(Object instance, Field field)
          Return the return value of a getter call from a given field on a given instance
static void fieldSetter(Object obj, Field field, Object fieldValue)
           
static Field getField(Class<?> clazz, String attName)
          Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.
static Object getFieldValue(Object instance, Field field)
          Returns the field value corresponding to the field argument
static String getGetterMethodName(Field field)
          Return the name of the getter method for a field.
static String getSetterMethodName(Field field)
          Return the name of the setter method for a field.
static Map introspectFields(Class clazz)
          Introspect a Class to retrieve public fields
static Map introspectFields(Object obj)
          Convenient method to introspect fields of an object
static Map introspectFields(Object instance, Map fields)
          Introspect an Object by calling given fields
static void setFieldValue(Object storable, Field field, Object fieldValue)
          Set a field to a value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Constructor Detail

ReflectUtil

public ReflectUtil()
Method Detail

getGetterMethodName

public static String getGetterMethodName(Field field)
Return the name of the getter method for a field. Field's name is supposed to be conformed with JavaBeans design patterns. Examples:
 int status; -> getStatus()
 boolean isEnabled -> isEnabled();
 

Parameters:
field - the field
Since:
jcms-4.2

getField

public static Field getField(Class<?> clazz,
                             String attName)
Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.

Parameters:
clazz - specifies the class or interface
attName - the name of the desired field

getFieldValue

public static Object getFieldValue(Object instance,
                                   Field field)
Returns the field value corresponding to the field argument

Parameters:
instance - - the instance containing the field
field - - the requested field
Returns:
the value of the field

fieldGetter

public static Object fieldGetter(Object instance,
                                 Field field)
Return the return value of a getter call from a given field on a given instance

Parameters:
instance -
field -
Since:
jcms-4.2

getSetterMethodName

public static String getSetterMethodName(Field field)
Return the name of the setter method for a field. Field's name is supposed to be conformed with JavaBeans design patterns. Examples: Examples:
 int status; -> setStatus()
 

Parameters:
field - the field
Since:
jcms-4.2

setFieldValue

public static void setFieldValue(Object storable,
                                 Field field,
                                 Object fieldValue)
Set a field to a value

Parameters:
storable - - the instance containing the field
field - - the field to set
fieldValue - - the new field value

fieldSetter

public static void fieldSetter(Object obj,
                               Field field,
                               Object fieldValue)

introspectFields

public static Map introspectFields(Object obj)
Convenient method to introspect fields of an object

Parameters:
obj - the object to introspect
Returns:
a Map of FieldName / Value
Since:
jcms-4.2

introspectFields

public static Map introspectFields(Class clazz)
Introspect a Class to retrieve public fields

Parameters:
clazz - the class to introspect
Returns:
a Map of FieldName / Field
Since:
jcms-4.2

introspectFields

public static Map introspectFields(Object instance,
                                   Map fields)
Introspect an Object by calling given fields

Parameters:
instance - the instance to introspect
fields - a Map of FieldName / Field to call
Returns:
a Map of FieldName / Value
Since:
jcms-4.2


Copyright © 2001-2010 Jalios SA. All Rights Reserved.