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 boolean |
hasPrivateAttribute(Class c,
String name)
判断对象是否有此变量,从方法用于友好提示,属性无法访问的时候,是否是没有getter方法
|
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)
,关于2.0兼容的一个bug修复protected static Method getGetMethod(Class c, String methodName, Class... paras)
c - 对象methodName - 方法名paras - 参数列表public static ObjectMethodMatchConf match(Method method, Class[] paras)
paras - 输入的参数public static Object invokeStatic(Class target, String methodName, Object[] paras) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
public 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)
public static Class getClassByName(String clsName, ClassLoader loader)
public static Object instance(String clsName, ClassLoader loader)
public static Object tryInstance(String clsName, ClassLoader loader)
public static ObjectInfo getObjectInfo(Class c)
public static String getGetMethod(String attrName)
public static String getSetMethod(String attrName)
public static String getIsMethod(String attrName)
public static ClassLoader getClassLoader()
Copyright © 2020. All rights reserved.