|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.onemind.commons.java.lang.reflect.ReflectUtils
Reflection related utilities
Method Summary | |
static int |
computeCompatibalityScore(java.lang.Class[] methodTypes,
java.lang.Class[] argTypes)
Return whether the types of arguments is compatible with the argument type spec of a method |
static java.lang.Class |
getClass(java.lang.String name)
Get the class |
static java.lang.reflect.Constructor |
getConstructor(java.lang.Class type,
java.lang.Object[] args)
Get the constructor of the type given the arguments to the constructor |
static java.lang.reflect.Method |
getInterfaceMethod(java.lang.Class[] c,
java.lang.String methodName,
java.lang.Class[] argTypes)
Resolve the method from the interfaces |
static java.lang.reflect.Method |
getMethod(java.lang.Class type,
java.lang.String methodName,
java.lang.Class[] argTypes)
Get a named method of class type with the argument type compatible with the argument passed in. |
static java.lang.reflect.Method |
getMethod(java.lang.Class type,
java.lang.String methodName,
java.lang.Object[] args)
Get a named method of class type with the argument type compatible with the argument passed in. |
static java.lang.Object |
invoke(java.lang.Object o,
java.lang.String methodName,
java.lang.Object[] args)
Invoke a named method on the object using the arguments |
static boolean |
isCompatible(java.lang.Class[] types,
java.lang.Class[] argTypes)
|
static boolean |
isCompatible(java.lang.Class[] types,
java.lang.Object[] args)
Return whether the argument objects is compatible with the argument types specification |
static boolean |
isPrimitiveCompatible(java.lang.Class primitiveClass,
java.lang.Class clazz)
Return true if primitiveClass and clazz is both primitive and clazz is primitive compatible with primitiveClass using java rules (unwrapping or widening) |
static boolean |
isPrimitiveInstance(java.lang.Class primitiveClass,
java.lang.Object obj)
Return whether a given object is a primitive or compatible (through unwrapping and widening) instance of primitiveClass |
static java.lang.Object |
newInstance(java.lang.Class type,
java.lang.Object[] args)
Create a new instance of the class type with the arguments to constructor |
static java.lang.reflect.Constructor |
searchConstructor(java.lang.Class type,
java.lang.Class[] argTypes)
Search for a particular constructor based on arg types classes |
protected static void |
setClassCaching(boolean caching)
Set the classCaching |
protected static void |
setMethodCaching(boolean caching)
Set the _methodCaching |
static java.lang.Class[] |
toArgTypes(java.lang.Object[] args)
Construct the argument type class array from a list of arg objects |
static java.lang.String |
toMethodString(java.lang.String methodName,
java.lang.Object[] args)
To the method representation string e.g. toString() |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final java.lang.Class[] toArgTypes(java.lang.Object[] args)
args
- the arguments
public static final java.lang.Class getClass(java.lang.String name) throws java.lang.ClassNotFoundException
name
- the name of the class
java.lang.ClassNotFoundException
- if the class cannot be foundpublic static final java.lang.reflect.Constructor getConstructor(java.lang.Class type, java.lang.Object[] args) throws java.lang.NoSuchMethodException
type
- the typeargs
- the arguments
java.lang.NoSuchMethodException
- if the constructor cannot be foundpublic static final java.lang.String toMethodString(java.lang.String methodName, java.lang.Object[] args)
methodName
- the methodargs
- the arguments
public static final java.lang.reflect.Constructor searchConstructor(java.lang.Class type, java.lang.Class[] argTypes)
type
- the typeargTypes
- the argument types
public static final boolean isCompatible(java.lang.Class[] types, java.lang.Object[] args)
types
- the argument typesargs
- the arguments
public static final boolean isCompatible(java.lang.Class[] types, java.lang.Class[] argTypes)
public static final int computeCompatibalityScore(java.lang.Class[] methodTypes, java.lang.Class[] argTypes)
methodTypes
- the argument type spec of a methodargTypes
- the argument type
public static final java.lang.Object newInstance(java.lang.Class type, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
type
- the typeargs
- the argument
java.lang.IllegalAccessException
- if there's access problem
java.lang.InstantiationException
- if there's instantiation problem
java.lang.reflect.InvocationTargetException
- if there's target exception
java.lang.NoSuchMethodException
- if there's no such constructorpublic static final java.lang.Object invoke(java.lang.Object o, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
o
- the objectmethodName
- the name of the methodargs
- the arguments
java.lang.NoSuchMethodException
- if there's no such method
java.lang.IllegalAccessException
- if there's access problem
java.lang.reflect.InvocationTargetException
- if there's target problempublic static final java.lang.reflect.Method getInterfaceMethod(java.lang.Class[] c, java.lang.String methodName, java.lang.Class[] argTypes)
c
- the classmethodName
- the methodargTypes
- the arg types
public static final java.lang.reflect.Method getMethod(java.lang.Class type, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException
type
- the classmethodName
- the method nameargs
- the arguments
java.lang.NoSuchMethodException
- if the method cannot be foundpublic static final java.lang.reflect.Method getMethod(java.lang.Class type, java.lang.String methodName, java.lang.Class[] argTypes) throws java.lang.NoSuchMethodException
type
- the classmethodName
- the method name
java.lang.NoSuchMethodException
- if the method cannot be foundprotected static final void setClassCaching(boolean caching)
caching
- true to turn on class cachingprotected static final void setMethodCaching(boolean caching)
caching
- true to turn on method cachingpublic static final boolean isPrimitiveInstance(java.lang.Class primitiveClass, java.lang.Object obj)
primitiveClass
- the primitive classobj
- the object
public static final boolean isPrimitiveCompatible(java.lang.Class primitiveClass, java.lang.Class clazz)
primitiveClass
- clazz
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |