public class ReflectHelper extends Object
| 构造器和说明 |
|---|
ReflectHelper() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
getFieldValue(Object object,
String fieldName)
获取访问对象的成员变量的值
|
static Object |
getObjectByConstructor(String className)
通过无参数的构造函数取得实例
|
static Object |
getObjectByConstructor(String className,
Class[] intArgsClass,
Object[] intArgs)
通过构造器取得实例
|
static Object |
getSupperFieldValue(Object object,
String fieldName)
获取访问对象的父类的成员变量的值
|
static Object |
invokeMethod(Object object,
String methodName)
调用访问对象的无参方法
|
static Object |
invokeMethod(Object object,
String methodName,
Class[] type,
Object[] value)
调用访问对象的方法,包括私有
|
static Object |
invokeSupperMethod(Object object,
String methodName)
调用访问对象的父类的无参方法
|
static Object |
invokeSupperMethod(Object object,
String methodName,
Class[] type,
Class[] value)
调用访问对象的父类的方法,包括私有
|
static void |
setFieldValue(Object object,
String fieldName,
Object fieldValue)
修改成员变量的值
|
static void |
setSupperFieldValue(Object object,
String fieldName,
Object fieldValue)
修改父类的成员变量的值
|
public static Object getObjectByConstructor(String className, Class[] intArgsClass, Object[] intArgs) throws NoSuchMethodException, Exception
className - 类的全路径名称intArgsClass - 构造函数的参数类型intArgs - 构造函数的参数值NoSuchMethodExceptionExceptionpublic static Object getObjectByConstructor(String className) throws NoSuchMethodException, Exception
className - 类的全路径名称NoSuchMethodExceptionExceptionpublic static void setFieldValue(Object object, String fieldName, Object fieldValue) throws NoSuchFieldException, Exception
object - 修改对象fieldName - 成员变量名fieldValue - 成员变量将被设置的值NoSuchFieldExceptionExceptionpublic static void setSupperFieldValue(Object object, String fieldName, Object fieldValue) throws NoSuchFieldException, Exception
object - 修改对象fieldName - 成员变量名fieldValue - 成员变量将被设置的值NoSuchFieldExceptionExceptionpublic static Object getFieldValue(Object object, String fieldName) throws NoSuchFieldException, Exception
object - 访问对象fieldName - 指定成员变量名NoSuchFieldExceptionExceptionpublic static Object getSupperFieldValue(Object object, String fieldName)
object - 访问对象fieldName - 访问对象父类的成员变量名public static Object invokeMethod(Object object, String methodName, Class[] type, Object[] value) throws NoSuchMethodException, Exception
object - 访问对象methodName - 方法名type - 方法参数类型value - 方法参数值NoSuchMethodExceptionExceptionpublic static Object invokeSupperMethod(Object object, String methodName, Class[] type, Class[] value) throws NoSuchMethodException, Exception
object - 访问对象methodName - 方法名type - 方法参数类型value - 方法参数的值NoSuchMethodExceptionExceptionpublic static Object invokeMethod(Object object, String methodName) throws NoSuchMethodException, Exception
object - 访问对象methodName - 方法名NoSuchMethodExceptionExceptionpublic static Object invokeSupperMethod(Object object, String methodName) throws NoSuchMethodException, Exception
object - 访问对象methodName - 方法名NoSuchMethodExceptionExceptionCopyright © 2016–2017. All rights reserved.