public class ObjectUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Map<Class,ObjectInfo> |
cachedClassInfoMap |
static Object[] |
EMPTY_OBJECT_ARRAY |
static Map<Class,Map<String,MethodInvoker>> |
methodInvokerCache |
| 构造器和说明 |
|---|
ObjectUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected static PropertyDescriptor |
find(PropertyDescriptor[] pd,
String name) |
protected static PropertyDescriptor |
findIsMethod(PropertyDescriptor[] pd,
String methodName) |
static ObjectMethodMatchConf |
findMethod(Class target,
String methodName,
Class[] parameterType)
找到某个类的某个方法,方法名是methodName,参数是parameterType。
|
static Class |
getClassByName(String clsName,
ClassLoader loader)
针对Class.forName的一个简单封装,根据类名获得类
|
static ClassLoader |
getClassLoader() |
protected static Method |
getGetMethod(Class c,
String methodName,
Class... paras)
获取对象的某个方法,如果无此方法,则仅仅返回null
|
static String |
getGetMethod(String attrName)
已过时。
并不遵循java规范
|
static MethodInvoker |
getInvokder(Class c,
String name)
得到一个可供调用get属性的invoker,invoker用于封装对对象的属性读取
|
static String |
getIsMethod(String attrName)
已过时。
并不遵循java规范
|
static ObjectInfo |
getObjectInfo(Class c)
获取一个ObjectInfo
|
static String |
getSetMethod(String attrName)
已过时。
并不遵循java规范
|
static Object |
instance(String clsName,
ClassLoader loader)
针对Class.forName(clsname).newInstance()的一个简单封装
|
static Object |
invoke(Object o,
ObjectMethodMatchConf conf,
Object[] paras) |
static Object |
invokeObject(Object o,
String methodName,
Object[] paras) |
static Object |
invokeStatic(Class target,
String methodName,
Object[] paras)
调用类的静态方法,只知道方法名和参数,beetl将自动匹配到能调用的方法
|
static ObjectMethodMatchConf |
match(Method method,
Class[] paras)
看给定的参数是否匹配给定方法的参数
|
protected static PropertyDescriptor[] |
propertyDescriptors(Class<?> c) |
static Object |
tryInstance(String clsName,
ClassLoader loader)
实例化一个类,如果不成功,返回null
|
public static final Map<Class,Map<String,MethodInvoker>> methodInvokerCache
public static Map<Class,ObjectInfo> cachedClassInfoMap
public static Object[] EMPTY_OBJECT_ARRAY
protected static PropertyDescriptor[] propertyDescriptors(Class<?> c) throws IntrospectionException
protected static PropertyDescriptor find(PropertyDescriptor[] pd, String name)
protected static PropertyDescriptor findIsMethod(PropertyDescriptor[] pd, String methodName)
public static MethodInvoker getInvokder(Class c, String name)
c - name - ,关于2.0兼容的一个bug修复protected static Method getGetMethod(Class c, String methodName, Class... paras)
c - 对象methodName - 方法名paras - 参数列表public static ObjectMethodMatchConf match(Method method, Class[] paras)
method - paras - 输入的参数public static Object invokeStatic(Class target, String methodName, Object[] paras) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
target - methodName - paras - IllegalAccessExceptionIllegalArgumentExceptionInvocationTargetExceptionpublic static Object invokeObject(Object o, String methodName, Object[] paras) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Object invoke(Object o, ObjectMethodMatchConf conf, Object[] paras) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static ObjectMethodMatchConf findMethod(Class target, String methodName, Class[] parameterType)
target - methodName - parameterType - public static Class getClassByName(String clsName, ClassLoader loader)
clsName - public static Object instance(String clsName, ClassLoader loader)
clsName - public static Object tryInstance(String clsName, ClassLoader loader)
clsName - public static ObjectInfo getObjectInfo(Class c)
c - public static String getGetMethod(String attrName)
attrName - public static String getSetMethod(String attrName)
attrName - public static String getIsMethod(String attrName)
attrName - public static ClassLoader getClassLoader()
Copyright © 2019. All rights reserved.