|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectechopointng.util.reflect.ReflectionKit
public class ReflectionKit
ReflectionKit provides methods that help when
using reflection on Java code.
| Nested Class Summary | |
|---|---|
static class |
ReflectionKit.ClassComparator
A Comparator that can be used when comparing and sorting Class objects by class name. |
static class |
ReflectionKit.ClassDerivationComparator
A Comparator that can be used when comparing and sorting Class objects by most specific class order. |
static class |
ReflectionKit.ClassMethodComparator
A Comparator that can be used when comparing and sorting Method objects by most specific declaring class order, then followed by method name. |
static class |
ReflectionKit.MethodComparator
A Comparator that can be used when comparing and sorting Method objects by name, modifier and parameter liist order. |
static interface |
ReflectionKit.MethodSearchCriteria
MethodSearchCriteria is an interface used
to determine if a method matches some search criteria. |
| Method Summary | |
|---|---|
static java.lang.String |
decapitalize(java.lang.String name)
Takes a bean property method name and removes any 'get'/'is'/'set' at the front and then decapitalizes the rest of the name according to the Java Bean Spec. |
static java.lang.reflect.Method[] |
getAllBeanGetterMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing getter Method objects reflecting all the member methods of the class or interface represented by the targetClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces up until stopClass. |
static java.lang.reflect.Method[] |
getAllBeanMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing getter and setter Method objects reflecting all the member methods of the class or interface represented by the targetClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces up until stopClass. |
static java.lang.reflect.Method[] |
getAllBeanSetterMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing setter Method objects reflecting all the member methods of the class or interface represented by the targetClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces up until stopClass. |
static java.lang.reflect.Method[] |
getAllDeclaredMethods(java.lang.Class targetClass)
Shorthand method for ReflectionKit.getAllMethods(targetClass,Object.class); |
static java.lang.reflect.Method[] |
getAllDeclaredMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing Method objects reflecting all the member methods of the class or interface represented by the targetClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces up until stopClass. |
static java.lang.reflect.Method[] |
getAllPublicMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing Method objects reflecting all the member methods of the class or interface represented by the targetClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces up until stopClass. |
static java.lang.reflect.Method |
getBeanGetter(java.lang.reflect.Method beanSetter)
Returns the getter method for a given setter method. |
static java.lang.Class[] |
getClassHierarchy(java.lang.Class targetClass)
|
static java.lang.Class[] |
getClassHierarchy(java.lang.Class targetClass,
java.lang.Class stopClass)
Returns an array containing their hierarchy of class objects for the given class object. |
static java.lang.reflect.Method[] |
getMethods(java.lang.Class targetClass,
java.lang.Class stopClass,
ReflectionKit.MethodSearchCriteria methodSearchCriteria)
This method will returns member methods of the targetClass that meet a specified search criteria. |
static boolean |
hasMethod(java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Class returnType,
java.lang.Object targetObj)
This method can be called to determine whether an object has the specific named method. |
static java.lang.Object |
invokeIfPresent(java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Class returnType,
java.lang.Object targetObj,
java.lang.Object[] params)
This method can be called to invoke a specific named method of an object. |
static boolean |
isGetter(java.lang.reflect.Method method)
Returns true if the method is in fact a Java Bean getter method. |
static boolean |
isSetter(java.lang.reflect.Method method)
Returns true if the method is in fact a Java Bean setter method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isGetter(java.lang.reflect.Method method)
Note that it does check for public access because its valid to have a getter that isnt public.
method - - the method to examine
public static boolean isSetter(java.lang.reflect.Method method)
Note that it does check for public access because its valid to have a setter that isnt public.
method - - the method to examine
public static java.lang.String decapitalize(java.lang.String name)
name - - the name of the method or field name to change
public static java.lang.reflect.Method[] getMethods(java.lang.Class targetClass,
java.lang.Class stopClass,
ReflectionKit.MethodSearchCriteria methodSearchCriteria)
The results are sorted by method name within derived class. The most specific class methods will be returned first.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.methodSearchCriteria - - the MethodSearchCirteria to use
ReflectionKit.MethodSearchCriteria
public static java.lang.reflect.Method[] getAllDeclaredMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
All public, protected, default (package) access, and private methods are returned.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.
public static java.lang.reflect.Method[] getAllDeclaredMethods(java.lang.Class targetClass)
getAllDeclaredMethods(Class, Class)
public static java.lang.reflect.Method[] getAllPublicMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Only public methods are returned.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.
public static java.lang.reflect.Method[] getAllBeanGetterMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Only methods matching the Java Bean specifiction for a getter method are returned.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
The methods are returned in method name order using the MethodComparator comparator.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.
public static java.lang.reflect.Method[] getAllBeanSetterMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Only methods matching the Java Bean specifiction for a setter method are returned.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.
public static java.lang.reflect.Method[] getAllBeanMethods(java.lang.Class targetClass,
java.lang.Class stopClass)
Only methods matching the Java Bean specifiction for a getter or setter method are returned.
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to check for methodsstopClass - - the supertype to stop at.
public static java.lang.reflect.Method getBeanGetter(java.lang.reflect.Method beanSetter)
beanSetter - - a bean setter method of class in question
java.lang.IllegalArgumentException - - if the method passed in is nullpublic static java.lang.Class[] getClassHierarchy(java.lang.Class targetClass)
getClassHierarchy(Class, Class)
public static java.lang.Class[] getClassHierarchy(java.lang.Class targetClass,
java.lang.Class stopClass)
If stopClass is not a superclass or superinterface of targetClass, then Object.class is used.
targetClass - - the class to start the hierarchial search fromstopClass - - the supertype to stop at.
public static boolean hasMethod(java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Class returnType,
java.lang.Object targetObj)
methodName - - the name of the method to invokeparamTypes - - the types of the methods parameters
if this is null then it is deemed Class[0]returnType - - the methods return type,
if this is null then it is deemed Void.TYPEtargetObj - - the object to invoke the method on
ReflectionKit.MethodSearchCriteria - RuntimeException if any bad happens, such as invalid parameters.
public static java.lang.Object invokeIfPresent(java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Class returnType,
java.lang.Object targetObj,
java.lang.Object[] params)
methodName - - the name of the method to invokeparamTypes - - the types of the methods parameters
if this is null then it is deemed Class[0]returnType - - the methods return type,
if this is null then it is deemed Void.TYPEtargetObj - - the object to invoke the method onparams - - the parameters for the method
if this is null then it is deemed Object[0]
ReflectionKit.MethodSearchCriteria - RuntimeException if any bad happens, such as invalid parameters.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||