Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » util » [javadoc | source]
org.springframework.util
abstract public class: ReflectionUtils [javadoc | source]
java.lang.Object
   org.springframework.util.ReflectionUtils
Simple utility class for working with the reflection API and handling reflection exceptions.

Only intended for internal use.

Nested Class Summary:
public static interface  ReflectionUtils.MethodCallback  Action to take on each method. 
public static interface  ReflectionUtils.MethodFilter  Callback optionally used to method fields to be operated on by a method callback. 
public static interface  ReflectionUtils.FieldCallback  Callback interface invoked on each field in the hierarchy. 
public static interface  ReflectionUtils.FieldFilter  Callback optionally used to filter fields to be operated on by a field callback. 
Field Summary
public static  ReflectionUtils.FieldFilter COPYABLE_FIELDS    Pre-built FieldFilter that matches all non-static, non-final fields. 
Method from org.springframework.util.ReflectionUtils Summary:
declaresException,   doWithFields,   doWithFields,   doWithMethods,   doWithMethods,   findField,   findField,   findMethod,   findMethod,   getAllDeclaredMethods,   getField,   handleInvocationTargetException,   handleReflectionException,   invokeJdbcMethod,   invokeJdbcMethod,   invokeMethod,   invokeMethod,   isEqualsMethod,   isHashCodeMethod,   isPublicStaticFinal,   isToStringMethod,   makeAccessible,   makeAccessible,   makeAccessible,   rethrowException,   rethrowRuntimeException,   setField,   shallowCopyFieldState
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.util.ReflectionUtils Detail:
 public static boolean declaresException(Method method,
    Class exceptionType) 
    Determine whether the given method explicitly declares the given exception or one of its superclasses, which means that an exception of that type can be propagated as-is within a reflective invocation.
 public static  void doWithFields(Class targetClass,
    ReflectionUtils.FieldCallback fc) throws IllegalArgumentException 
    Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.
 public static  void doWithFields(Class targetClass,
    ReflectionUtils.FieldCallback fc,
    ReflectionUtils.FieldFilter ff) throws IllegalArgumentException 
    Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.
 public static  void doWithMethods(Class targetClass,
    ReflectionUtils.MethodCallback mc) throws IllegalArgumentException 
    Perform the given callback operation on all matching methods of the given class and superclasses.

    The same named method occurring on subclass and superclass will appear twice, unless excluded by a MethodFilter .

 public static  void doWithMethods(Class targetClass,
    ReflectionUtils.MethodCallback mc,
    ReflectionUtils.MethodFilter mf) throws IllegalArgumentException 
    Perform the given callback operation on all matching methods of the given class and superclasses.

    The same named method occurring on subclass and superclass will appear twice, unless excluded by the specified MethodFilter .

 public static Field findField(Class clazz,
    String name) 
    Attempt to find a field on the supplied Class with the supplied name. Searches all superclasses up to Object .
 public static Field findField(Class clazz,
    String name,
    Class type) 
    Attempt to find a field on the supplied Class with the supplied name and/or type . Searches all superclasses up to Object .
 public static Method findMethod(Class clazz,
    String name) 
    Attempt to find a Method on the supplied class with the supplied name and no parameters. Searches all superclasses up to Object.

    Returns null if no Method can be found.

 public static Method findMethod(Class clazz,
    String name,
    Class[] paramTypes) 
    Attempt to find a Method on the supplied class with the supplied name and parameter types. Searches all superclasses up to Object.

    Returns null if no Method can be found.

 public static Method[] getAllDeclaredMethods(Class leafClass) throws IllegalArgumentException 
    Get all declared methods on the leaf class and all superclasses. Leaf class methods are included first.
 public static Object getField(Field field,
    Object target) 
 public static  void handleInvocationTargetException(InvocationTargetException ex) 
    Handle the given invocation target exception. Should only be called if no checked exception is expected to be thrown by the target method.

    Throws the underlying RuntimeException or Error in case of such a root cause. Throws an IllegalStateException else.

 public static  void handleReflectionException(Exception ex) 
    Handle the given reflection exception. Should only be called if no checked exception is expected to be thrown by the target method.

    Throws the underlying RuntimeException or Error in case of an InvocationTargetException with such a root cause. Throws an IllegalStateException with an appropriate message else.

 public static Object invokeJdbcMethod(Method method,
    Object target) throws SQLException 
    Invoke the specified JDBC API Method against the supplied target object with no arguments.
 public static Object invokeJdbcMethod(Method method,
    Object target,
    Object[] args) throws SQLException 
    Invoke the specified JDBC API Method against the supplied target object with the supplied arguments.
 public static Object invokeMethod(Method method,
    Object target) 
    Invoke the specified Method against the supplied target object with no arguments. The target object can be null when invoking a static Method .

    Thrown exceptions are handled via a call to #handleReflectionException .

 public static Object invokeMethod(Method method,
    Object target,
    Object[] args) 
    Invoke the specified Method against the supplied target object with the supplied arguments. The target object can be null when invoking a static Method .

    Thrown exceptions are handled via a call to #handleReflectionException .

 public static boolean isEqualsMethod(Method method) 
    Determine whether the given method is an "equals" method.
 public static boolean isHashCodeMethod(Method method) 
    Determine whether the given method is a "hashCode" method.
 public static boolean isPublicStaticFinal(Field field) 
    Determine whether the given field is a "public static final" constant.
 public static boolean isToStringMethod(Method method) 
    Determine whether the given method is a "toString" method.
 public static  void makeAccessible(Field field) 
    Make the given field accessible, explicitly setting it accessible if necessary. The setAccessible(true) method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).
 public static  void makeAccessible(Method method) 
    Make the given method accessible, explicitly setting it accessible if necessary. The setAccessible(true) method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).
 public static  void makeAccessible(Constructor ctor) 
    Make the given constructor accessible, explicitly setting it accessible if necessary. The setAccessible(true) method is only called when actually necessary, to avoid unnecessary conflicts with a JVM SecurityManager (if active).
 public static  void rethrowException(Throwable ex) throws Exception 
 public static  void rethrowRuntimeException(Throwable ex) 
 public static  void setField(Field field,
    Object target,
    Object value) 
 public static  void shallowCopyFieldState(Object src,
    Object dest) throws IllegalArgumentException 
    Given the source object and the destination, which must be the same class or a subclass, copy all fields, including inherited fields. Designed to work on objects with public no-arg constructors.