|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.jbeans.ReflectionTools
This class is a toolkit to help in reflection. All JavaBean related methods and toolkit methods can be found in the com.bp.beans package
| Constructor Summary | |
ReflectionTools()
|
|
| Method Summary | |
static Class |
convertToWrapper(Class type)
Converts the type given to the correct wrapper class for that type. |
static Class |
findClass(String className,
String packageName)
Convience method that returns class given the package name and className |
static Method |
getMethod(Class klass,
String method,
Class[] params)
Returns the given class' method with the name method and the parameters params. |
static Method |
getMethod(Object object,
String method,
Class[] params)
Returns the given objects method with the name method and the parameters params. |
static Method[] |
getMethods(Object object)
Gets all the methods for an object and handles all the nasty exceptions that Java reflection can throw. |
static Object |
instantiate(Class objectClass)
Yep, another convience method that instantiates an object from a class and this is just like all the others and wraps the exceptions into one nice exception |
static Object |
instantiate(String className)
A convience method so that a class can be instantiated by name stored in a string without all the exceptions having to be caught. |
static Object |
invokeMethod(Method method,
Object object,
Object[] params)
Another convience method because invoking a reflected method is a really pain in the butt. |
static boolean |
isSimpleReturnType(Method method)
This method makes a really big blanket statement by stating that all simple types (wrapper classe and string) are in java.lang package. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ReflectionTools()
| Method Detail |
public static Class findClass(String className,
String packageName)
throws ReflectionException
className - The name of the class (ie Foo)packageName - (Optional) The name of the package (ie com.xor.util)ReflectionException - If the class name is invalid
public static Method getMethod(Object object,
String method,
Class[] params)
throws ReflectionException
obejct - The object to get the method frommethod - The name of the method to fetchparams - The params to the method (can be null if the method does
not take any parameters)ReflectionException - If anything went wrong in the reflection,
like wrong arguments to the method or invalid method name. This
exception has a very good message body that tells exactly what
the hell you screwed up
public static Method getMethod(Class klass,
String method,
Class[] params)
throws ReflectionException
klass - The class object to get the method frommethod - The name of the method to fetchparams - The params to the method (can be null if the method does
not take any parameters)ReflectionException - If anything went wrong in the reflection,
like wrong arguments to the method or invalid method name. This
exception has a very good message body that tells exactly what
the hell you screwed up
public static Method[] getMethods(Object object)
throws ReflectionException
object - The object to get the methods from (only the public ones)ReflectionException - If anything bad happened during reflection
public static Object invokeMethod(Method method,
Object object,
Object[] params)
throws ReflectionException,
RuntimeException,
Error
method - The method to invokeobject - The object to invoke the method onparams - The params to the methodReflectionException - If any mishap occurred whilst Reflecting sire.
All the exceptions that could be thrown whilst invoking will be
wrapped inside the ReflectionExceptionRuntimeException - If the target of the InvocationTargetException is
a RuntimeException, in which case, it is re-thrownError - If the target of the InvocationTargetException is an Error,
in which case, it is re-thrown
public static Object instantiate(Class objectClass)
throws ReflectionException
objectClass - The class to instantiateReflectionException - If you did something really dumb like put
a security restriction on the class or tried to call a class
that doesn't have a default constructor of something lame like
that.
public static Object instantiate(String className)
throws ReflectionException
className - The name of the class to instantiateReflectionException - if something went wrong during name lookup
or instantiationpublic static boolean isSimpleReturnType(Method method)
method - The method to checkpublic static Class convertToWrapper(Class type)
type - The type of convert to its wrapper class
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||