public class ReflectionUtils extends Object
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
protected static Object |
arrayInfo(Object... objects)
Get array info.
|
static Constructor<?> |
findConstructor(Class<?> clazz,
Class<?>... parameterTypes)
Find the constructor by parameters.
|
static Constructor<?> |
findExactConstructor(Class<?> clazz,
Class<?>... parameterTypes)
Find the constructor by parameters.
|
static Field |
findExactField(Class<?> clazz,
String name)
Find the field by name.
|
static Method |
findExactMethod(Class<?> clazz,
String name,
Class<?>... parameterTypes)
Find the method by name and parameters.
|
static Field |
findField(Class<?> clazz,
String name)
Find the field by name.
|
static Method |
findMethod(Class<?> clazz,
String name,
Class<?>... parameterTypes)
Find the method by name and parameters.
|
static Object |
getField(Field field,
Object target)
Get a field
|
static Throwable |
handleErrors(String context,
Field field,
Object target,
Object value,
Throwable t)
Handle errors
|
static Throwable |
handleErrors(String context,
Object target,
Class<?>[] parameters,
Object[] arguments,
Throwable t)
Handle errors
|
static Object |
invoke(Method method,
Object target,
Object[] arguments)
Invoke on a method
|
static Object |
newInstance(Class<?> clazz)
Create a new instance
|
static Object |
newInstance(Constructor<?> constructor,
Object[] arguments)
Create a new instance
|
static Object |
newInstance(String className)
Create a new instance
|
static Object |
newInstance(String className,
ClassLoader cl)
Create a new instance
|
static Object |
setField(Field field,
Object target,
Object value)
Set a field
|
public static Object invoke(Method method, Object target, Object[] arguments) throws Throwable
method - the methodtarget - the targetarguments - the argumentsThrowable - for any errorpublic static Object newInstance(Class<?> clazz) throws Throwable
clazz - the classThrowable - for any errorpublic static Object newInstance(String className, ClassLoader cl) throws Throwable
className - the class namecl - the classloaderThrowable - for any errorpublic static Object newInstance(String className) throws Throwable
className - the class nameThrowable - for any errorpublic static Object newInstance(Constructor<?> constructor, Object[] arguments) throws Throwable
constructor - the constructorarguments - the argumentsThrowable - for any errorpublic static Object getField(Field field, Object target) throws Throwable
field - the fieldtarget - the targetThrowable - for any errorpublic static Object setField(Field field, Object target, Object value) throws Throwable
field - the fieldtarget - the targetvalue - the valueThrowable - for any errorprotected static Object arrayInfo(Object... objects)
objects - the array of objectspublic static Method findMethod(Class<?> clazz, String name, Class<?>... parameterTypes)
clazz - the class to look for methodname - the nameparameterTypes - the typespublic static Method findExactMethod(Class<?> clazz, String name, Class<?>... parameterTypes) throws NoSuchMethodException
clazz - the class to look for methodname - the nameparameterTypes - the typesNoSuchMethodException - for no such methodpublic static Field findField(Class<?> clazz, String name)
clazz - the class to look for fieldname - the namepublic static Field findExactField(Class<?> clazz, String name) throws NoSuchFieldException
clazz - the class to look for fieldname - the nameNoSuchFieldException - for no such fieldpublic static Constructor<?> findConstructor(Class<?> clazz, Class<?>... parameterTypes)
clazz - the class to look for constructorparameterTypes - the typespublic static Constructor<?> findExactConstructor(Class<?> clazz, Class<?>... parameterTypes) throws NoSuchMethodException
clazz - the class to look for constructorparameterTypes - the typesNoSuchMethodException - for no such methodpublic static Throwable handleErrors(String context, Object target, Class<?>[] parameters, Object[] arguments, Throwable t) throws Throwable
context - the contexttarget - the targetparameters - the parametersarguments - the argumentst - the errorThrowable - alwaysCopyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.