|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alibaba.dubbo.common.utils.ReflectUtils
public final class ReflectUtils
ReflectUtils
Field Summary | |
---|---|
static String |
ARRAY_DESC
|
static String |
CLASS_DESC
|
static Pattern |
DESC_PATTERN
|
static String |
DESC_REGEX
|
static Class<?>[] |
EMPTY_CLASS_ARRAY
|
static Pattern |
GETTER_METHOD_DESC_PATTERN
|
static Pattern |
IS_HAS_CAN_METHOD_DESC_PATTERN
|
static String |
JAVA_IDENT_REGEX
|
static String |
JAVA_NAME_REGEX
|
static char |
JVM_BOOLEAN
boolean(Z). |
static char |
JVM_BYTE
byte(B). |
static char |
JVM_CHAR
char(C). |
static char |
JVM_DOUBLE
double(D). |
static char |
JVM_FLOAT
float(F). |
static char |
JVM_INT
int(I). |
static char |
JVM_LONG
long(J). |
static char |
JVM_SHORT
short(S). |
static char |
JVM_VOID
void(V). |
static Pattern |
METHOD_DESC_PATTERN
|
static String |
METHOD_DESC_REGEX
|
static Pattern |
SETTER_METHOD_DESC_PATTERN
|
Method Summary | |
---|---|
static Class<?> |
desc2class(String desc)
desc to class. |
static Class<?>[] |
desc2classArray(String desc)
get class array instance. |
static String |
desc2name(String desc)
desc to name. |
static Constructor<?> |
findConstructor(Class<?> clazz,
Class<?> paramType)
|
static Method |
findMethodByMethodName(Class<?> clazz,
String methodName)
|
static Method |
findMethodByMethodSignature(Class<?> clazz,
String methodName,
String[] parameterTypes)
根据方法签名从类中找出方法。 |
static Class<?> |
forName(String name)
|
static Map<String,Field> |
getBeanPropertyFields(Class cl)
|
static Map<String,Method> |
getBeanPropertyReadMethods(Class cl)
|
static Class<?> |
getBoxedClass(Class<?> c)
|
static String |
getCodeBase(Class<?> cls)
|
static String |
getDesc(Class<?> c)
get class desc. |
static String |
getDesc(Class<?>[] cs)
get class array desc. |
static String |
getDesc(Constructor<?> c)
get constructor desc. |
static String |
getDesc(javassist.CtClass c)
get class desc. |
static String |
getDesc(javassist.CtConstructor c)
get constructor desc. |
static String |
getDesc(javassist.CtMethod m)
get method desc. |
static String |
getDesc(Method m)
get method desc. |
static String |
getDescWithoutMethodName(javassist.CtMethod m)
get method desc. |
static String |
getDescWithoutMethodName(Method m)
get method desc. |
static Object |
getEmptyObject(Class<?> returnType)
|
static Class<?> |
getGenericClass(Class<?> cls)
|
static Class<?> |
getGenericClass(Class<?> cls,
int i)
|
static String |
getName(Class<?> c)
get name. |
static String |
getName(Constructor<?> c)
get constructor name. |
static String |
getName(Method m)
get method name. |
static String |
getPropertyNameFromBeanReadMethod(Method method)
|
static String |
getPropertyNameFromBeanWriteMethod(Method method)
|
static String |
getSignature(String methodName,
Class<?>[] parameterTypes)
|
static boolean |
isBeanPropertyReadMethod(Method method)
|
static boolean |
isBeanPropertyWriteMethod(Method method)
|
static boolean |
isCompatible(Class<?>[] cs,
Object[] os)
is compatible. |
static boolean |
isCompatible(Class<?> c,
Object o)
is compatible. |
static boolean |
isInstance(Object obj,
String interfaceClazzName)
检查对象是否是指定接口的实现。 |
static boolean |
isPrimitive(Class<?> cls)
|
static boolean |
isPrimitives(Class<?> cls)
|
static boolean |
isPublicInstanceField(Field field)
|
static Class<?> |
name2class(String name)
name to class. |
static String |
name2desc(String name)
name to desc. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char JVM_VOID
public static final char JVM_BOOLEAN
public static final char JVM_BYTE
public static final char JVM_CHAR
public static final char JVM_DOUBLE
public static final char JVM_FLOAT
public static final char JVM_INT
public static final char JVM_LONG
public static final char JVM_SHORT
public static final Class<?>[] EMPTY_CLASS_ARRAY
public static final String JAVA_IDENT_REGEX
public static final String JAVA_NAME_REGEX
public static final String CLASS_DESC
public static final String ARRAY_DESC
public static final String DESC_REGEX
public static final Pattern DESC_PATTERN
public static final String METHOD_DESC_REGEX
public static final Pattern METHOD_DESC_PATTERN
public static final Pattern GETTER_METHOD_DESC_PATTERN
public static final Pattern SETTER_METHOD_DESC_PATTERN
public static final Pattern IS_HAS_CAN_METHOD_DESC_PATTERN
Method Detail |
---|
public static boolean isPrimitives(Class<?> cls)
public static boolean isPrimitive(Class<?> cls)
public static Class<?> getBoxedClass(Class<?> c)
public static boolean isCompatible(Class<?> c, Object o)
c
- class.o
- instance.
public static boolean isCompatible(Class<?>[] cs, Object[] os)
cs
- class array.os
- object array.
public static String getCodeBase(Class<?> cls)
public static String getName(Class<?> c)
c
- class.
public static Class<?> getGenericClass(Class<?> cls)
public static Class<?> getGenericClass(Class<?> cls, int i)
public static String getName(Method m)
m
- method.
public static String getSignature(String methodName, Class<?>[] parameterTypes)
public static String getName(Constructor<?> c)
c
- constructor.
public static String getDesc(Class<?> c)
c
- class.
javassist.NotFoundException
public static String getDesc(Class<?>[] cs)
cs
- class array.
javassist.NotFoundException
public static String getDesc(Method m)
m
- method.
public static String getDesc(Constructor<?> c)
c
- constructor.
public static String getDescWithoutMethodName(Method m)
m
- method.
public static String getDesc(javassist.CtClass c) throws javassist.NotFoundException
c
- class.
javassist.NotFoundException
public static String getDesc(javassist.CtMethod m) throws javassist.NotFoundException
m
- method.
javassist.NotFoundException
public static String getDesc(javassist.CtConstructor c) throws javassist.NotFoundException
c
- constructor.
javassist.NotFoundException
public static String getDescWithoutMethodName(javassist.CtMethod m) throws javassist.NotFoundException
m
- method.
javassist.NotFoundException
public static String name2desc(String name)
name
- name.
public static String desc2name(String desc)
desc
- desc.
public static Class<?> forName(String name)
public static Class<?> name2class(String name) throws ClassNotFoundException
name
- name.
ClassNotFoundException
public static Class<?> desc2class(String desc) throws ClassNotFoundException
desc
- desc.
ClassNotFoundException
public static Class<?>[] desc2classArray(String desc) throws ClassNotFoundException
desc
- desc.
ClassNotFoundException
public static Method findMethodByMethodSignature(Class<?> clazz, String methodName, String[] parameterTypes) throws NoSuchMethodException, ClassNotFoundException
clazz
- 查找的类。methodName
- 方法签名,形如method1(int, String)。也允许只给方法名不参数只有方法名,形如method2。
NoSuchMethodException
ClassNotFoundException
IllegalStateException
- 给定的方法签名找到多个方法(方法签名中没有指定参数,又有有重载的方法的情况)public static Method findMethodByMethodName(Class<?> clazz, String methodName) throws NoSuchMethodException, ClassNotFoundException
NoSuchMethodException
ClassNotFoundException
public static Constructor<?> findConstructor(Class<?> clazz, Class<?> paramType) throws NoSuchMethodException
NoSuchMethodException
public static boolean isInstance(Object obj, String interfaceClazzName)
不会触发到指定接口的Class
,所以如果ClassLoader中没有指定接口类时,也不会出错。
obj
- 要检查的对象interfaceClazzName
- 指定的接口名
true
,如果对象实现了指定接口;否则返回false
。public static Object getEmptyObject(Class<?> returnType)
public static boolean isBeanPropertyReadMethod(Method method)
public static String getPropertyNameFromBeanReadMethod(Method method)
public static boolean isBeanPropertyWriteMethod(Method method)
public static String getPropertyNameFromBeanWriteMethod(Method method)
public static boolean isPublicInstanceField(Field field)
public static Map<String,Field> getBeanPropertyFields(Class cl)
public static Map<String,Method> getBeanPropertyReadMethods(Class cl)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |