|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.weld.util.reflection.SecureReflections
public class SecureReflections
| Constructor Summary | |
|---|---|
SecureReflections()
|
|
| Method Summary | ||
|---|---|---|
static
|
ensureAccessible(T accessibleObject)
Makes an object accessible. |
|
static java.lang.Class<?>[] |
extractValues(java.lang.annotation.Annotation annotation)
Helper class for reading the value of an annotation |
|
static java.lang.reflect.Constructor<?> |
getConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>... parameterTypes)
Gets a constructor from a class |
|
static java.lang.reflect.Constructor<?>[] |
getConstructors(java.lang.Class<?> clazz)
Gets all constructors from a class |
|
static java.lang.reflect.Constructor<?> |
getDeclaredConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>... parameterTypes)
Gets a declared constructor from a class |
|
static java.lang.reflect.Constructor<?>[] |
getDeclaredConstructors(java.lang.Class<?> clazz)
Gets all declared constructors from a class |
|
static java.lang.reflect.Field |
getDeclaredField(java.lang.Class<?> clazz,
java.lang.String fieldName)
Returns a named, declared field from a class |
|
static java.lang.reflect.Field[] |
getDeclaredFields(java.lang.Class<?> clazz)
Returns all declared fields of a class |
|
static java.lang.reflect.Method |
getDeclaredMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Returns a named, declared method of a class |
|
static java.lang.reflect.Method[] |
getDeclaredMethods(java.lang.Class<?> clazz)
Returns all declared methods of a class |
|
static java.lang.reflect.Field |
getField(java.lang.Class<?> clazz,
java.lang.String fieldName)
Return a named field from a class |
|
static java.lang.reflect.Field[] |
getFields(java.lang.Class<?> clazz)
Returns all fields of a class |
|
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Returns a named method of a class |
|
static java.lang.reflect.Method[] |
getMethods(java.lang.Class<?> clazz)
Returns all methods of a class |
|
static
|
invoke(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... parameters)
Invokes a given method with given parameters on an instance |
|
static
|
invoke(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object... parameters)
Invokes a given method with given parameters on an instance |
|
static boolean |
isMethodExists(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Checks if a method is found in a class |
|
static java.lang.reflect.Method |
lookupMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Returns a method from the class or any class/interface in the inheritance hierarchy |
|
static java.lang.reflect.Method |
lookupMethod(java.lang.Object instance,
java.lang.reflect.Method method)
Looks up a method in an inheritance hierarchy |
|
static
|
newInstance(java.lang.Class<T> clazz)
Creates a new instance of a class |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SecureReflections()
| Method Detail |
|---|
public static java.lang.reflect.Field getField(java.lang.Class<?> clazz,
java.lang.String fieldName)
throws java.lang.NoSuchFieldException
clazz - The class to operate onfieldName - The name of the field
java.lang.NoSuchFieldException - If the field cannot be foundjava.lang.Class#getField(String))
public static java.lang.reflect.Field getDeclaredField(java.lang.Class<?> clazz,
java.lang.String fieldName)
throws java.lang.NoSuchFieldException
clazz - The class to operate onfieldName - The name of the field
java.lang.NoSuchFieldException - If the field cannot be foundClass.getDeclaredField(String)public static java.lang.reflect.Field[] getFields(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getFields()public static java.lang.reflect.Field[] getDeclaredFields(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getDeclaredFields()
public static java.lang.reflect.Method getMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException
clazz - The class to operate onmethodName - The name of the methodparameterTypes - The method parameter types
java.lang.NoSuchMethodException - If the method cannot be foundClass.getMethod(String, Class...)
public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException
clazz - The class to operate onmethodName - The name of the methodparameterTypes - The method parameter types
java.lang.NoSuchMethodException - If the method cannot be foundClass.getDeclaredMethods()public static java.lang.reflect.Method[] getMethods(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getMethods()public static java.lang.reflect.Method[] getDeclaredMethods(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getDeclaredMethods()
public static java.lang.reflect.Constructor<?> getConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException
clazz - The class to operate onparameterTypes - The constructor parameter types
java.lang.NoSuchMethodException - If the constructor cannot be foundClass.getConstructor(Class...)
public static java.lang.reflect.Constructor<?> getDeclaredConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException
clazz - The class to operate onparameterTypes - The constructor parameter types
java.lang.NoSuchMethodException - If the constructor cannot be foundClass.getDeclaredConstructor(Class...)public static java.lang.reflect.Constructor<?>[] getConstructors(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getConstructors()public static java.lang.reflect.Constructor<?>[] getDeclaredConstructors(java.lang.Class<?> clazz)
clazz - The class to operate on
Class.getDeclaredConstructor(Class...)
public static <T> T invoke(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... parameters)
throws java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
instance - The instance to invoke onmethod - The method to invokeparameters - The method parameters
java.lang.IllegalArgumentException - If there was an illegal argument passed
java.lang.IllegalAccessException - If there was an illegal access attempt
java.lang.reflect.InvocationTargetException - If there was another error invoking the
methodMethod.invoke(Object, Object...)public static <T extends java.lang.reflect.AccessibleObject> T ensureAccessible(T accessibleObject)
accessibleObjects - The object to manipulate
public static <T> T invoke(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object... parameters)
throws java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
instance - The instance to invoke onmethodName - The name of the method to invokeparameters - The method parameters
java.lang.IllegalArgumentException - If there was an illegal argument passed
java.lang.IllegalAccessException - If there was an illegal access attempt
java.lang.reflect.InvocationTargetException - If there was another error invoking the
methodMethod.invoke(Object, Object...)
public static <T> T newInstance(java.lang.Class<T> clazz)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
T - The type of the instanceclazz - The class to construct from
java.lang.InstantiationException - If the instance could not be create
java.lang.IllegalAccessException - If there was an illegal access attemptClass.newInstance()
public static java.lang.reflect.Method lookupMethod(java.lang.Object instance,
java.lang.reflect.Method method)
throws java.lang.NoSuchMethodException
instance - The instance (class) to start frommethod - The method to look up
java.lang.NoSuchMethodException - if the method could not be found
public static java.lang.reflect.Method lookupMethod(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException
clazz - The class to searchmethodName - The method nameparameterTypes - The method parameter types
java.lang.NoSuchMethodException - If the method could not be foundpublic static java.lang.Class<?>[] extractValues(java.lang.annotation.Annotation annotation)
annotation - The annotation to inspect
public static boolean isMethodExists(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
clazz - The class to inspectmethodName - The name of the methodparameterTypes - The parameter types of the method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||