站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

ReflectionUtils (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.util
Class ReflectionUtils

java.lang.Object
  extended by org.springframework.util.ReflectionUtils

public abstract class ReflectionUtils
extends Object

Simple utility class for handling reflection exceptions. Only intended for internal use.

Since:
1.2.2
Author:
Juergen Hoeller, Rob Harrop

Constructor Summary
ReflectionUtils()
           
 
Method Summary
static Method findMethod(Class type, String name, Class[] paramTypes)
          Attempt to find a Method on the supplied type with the supplied name and parameter types.
static void handleInvocationTargetException(InvocationTargetException ex)
          Handle the given invocation target exception.
static void handleReflectionException(Exception ex)
          Handle the given reflection exception.
static Object invokeMethod(Method method, Object target)
          Invoke the specified Method against the supplied target object with no arguments.
static Object invokeMethod(Method method, Object target, Object[] args)
          Invoke the specified Method against the supplied target object with the supplied arguments.
static boolean isPublicStaticFinal(Field field)
          Determine whether the given field is a "public static final" constant.
static void makeAccessible(Field field)
          Make the given field accessible, explicitly setting it accessible if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionUtils

public ReflectionUtils()
Method Detail

handleReflectionException

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.

Parameters:
ex - the reflection exception to handle

handleInvocationTargetException

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.

Parameters:
ex - the invocation target exception to handle

findMethod

public static Method findMethod(Class type,
                                String name,
                                Class[] paramTypes)
Attempt to find a Method on the supplied type with the supplied name and parameter types. Searches all superclasses up to Object. Returns null if no Method can be found.


invokeMethod

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(java.lang.Exception).

See Also:
invokeMethod(java.lang.reflect.Method, Object, Object[])

invokeMethod

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(java.lang.Exception).

See Also:
invokeMethod(java.lang.reflect.Method, Object, Object[])

isPublicStaticFinal

public static boolean isPublicStaticFinal(Field field)
Determine whether the given field is a "public static final" constant.

Parameters:
field - the field to check

makeAccessible

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).

Parameters:
field - the field to make accessible
See Also:
AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)


Copyright (c) 2002-2007 The Spring Framework Project.