org.codehaus.plexus.util
Class ReflectionUtils

java.lang.Object
  extended byorg.codehaus.plexus.util.ReflectionUtils

public final class ReflectionUtils
extends java.lang.Object

Version:
$Id: ReflectionUtils.java 3086 2006-03-22 20:06:03Z jesse $
Author:
Michal Maczka, Jesse McConnell

Method Summary
static java.lang.reflect.Field getFieldByNameIncludingSuperclasses(java.lang.String fieldName, java.lang.Class clazz)
           
static java.lang.reflect.Method getSetter(java.lang.String fieldName, java.lang.Class clazz)
          Finds a setter in the given class for the given field.
static java.lang.Object getValueIncludingSuperclasses(java.lang.String variable, java.lang.Object object)
          Generates a map of the fields and values on a given object, also pulls from superclasses
static java.util.Map getVariablesAndValuesIncludingSuperclasses(java.lang.Object object)
          Generates a map of the fields and values on a given object, also pulls from superclasses
static void setVariableValueInObject(java.lang.Object object, java.lang.String variable, java.lang.Object value)
          attempts to set the value to the variable in the object passed in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFieldByNameIncludingSuperclasses

public static java.lang.reflect.Field getFieldByNameIncludingSuperclasses(java.lang.String fieldName,
                                                                          java.lang.Class clazz)

getSetter

public static java.lang.reflect.Method getSetter(java.lang.String fieldName,
                                                 java.lang.Class clazz)
Finds a setter in the given class for the given field. It searches interfaces and superclasses too.

Parameters:
fieldName - the name of the field (i.e. 'fooBar'); it will search for a method named 'setFooBar'.
clazz - The class to find the method in.
Returns:
null or the method found.

setVariableValueInObject

public static void setVariableValueInObject(java.lang.Object object,
                                            java.lang.String variable,
                                            java.lang.Object value)
                                     throws java.lang.IllegalAccessException
attempts to set the value to the variable in the object passed in

Parameters:
object -
variable -
value -
Throws:
java.lang.IllegalAccessException

getValueIncludingSuperclasses

public static java.lang.Object getValueIncludingSuperclasses(java.lang.String variable,
                                                             java.lang.Object object)
                                                      throws java.lang.IllegalAccessException
Generates a map of the fields and values on a given object, also pulls from superclasses

Parameters:
object - the object to generate the list of fields from
Returns:
map containing the fields and their values
Throws:
java.lang.IllegalAccessException

getVariablesAndValuesIncludingSuperclasses

public static java.util.Map getVariablesAndValuesIncludingSuperclasses(java.lang.Object object)
                                                                throws java.lang.IllegalAccessException
Generates a map of the fields and values on a given object, also pulls from superclasses

Parameters:
object - the object to generate the list of fields from
Returns:
map containing the fields and their values
Throws:
java.lang.IllegalAccessException


Copyright © 2001-2006 Codehaus. All Rights Reserved.