|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.muse.util.ReflectUtils
public class ReflectUtils
ReflectUtils is a collection of utilities that allows you to leverage Java reflection without all of the checked exceptions (they are converted to runtime exceptions or return values). This class was created to get around the fact that the classes in java.lang.reflect.* turn every event into an exception, which is often cumbersome or inaccurate.
Constructor Summary | |
---|---|
ReflectUtils()
|
Method Summary | |
---|---|
static boolean |
exists(String className)
|
static boolean |
exists(String className,
ClassLoader classLoader)
|
static Class |
getArrayClassFromClass(Class theClass)
|
static Class |
getClass(String className)
This method calls getClass(Class, ClassLoader) with this class' ClassLoader. |
static Class |
getClass(String className,
ClassLoader classLoader)
|
static Class |
getClassFromArrayClass(Class arrayClass)
|
static Method |
getFirstMethod(Class theClass,
String name)
|
static String |
getPackageName(Class theClass)
|
static String |
getPackageName(String qualifiedName)
|
static String |
getShortName(Class type)
|
static String |
getShortName(String qualifiedName)
|
static Object |
newInstance(Class theClass)
Invokes the Class.newInstance() method on the given Class. |
static Object |
newInstance(String className)
This is a convenience method that invokes newInstance(Class) with a Class object representing the given type. |
static Object |
newInstance(String className,
ClassLoader classLoader)
This is a convenience method that invokes newInstance(Class) with a Class object loaded by the given ClassLoader |
static void |
setHelper(ReflectUtilHelper helper)
This is a setter for the helper object |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectUtils()
Method Detail |
---|
public static boolean exists(String className)
className
- The qualified name of the class to search for.
public static boolean exists(String className, ClassLoader classLoader)
className
- The qualified name of the class to search for.classLoader
- The class loader to use in the class lookup.
public static Class getArrayClassFromClass(Class theClass)
theClass
- A "normal", non-array type.
getClassFromArrayClass(Class)
public static Class getClass(String className)
className
- The name of the class to load.
exists(String)
public static Class getClass(String className, ClassLoader classLoader)
className
- The name of the class to load.classLoader
- The class loader to use for class lookup.
exists(String)
public static Class getClassFromArrayClass(Class arrayClass)
arrayClass
- The array version of a given type (YourType[].class)
getArrayClassFromClass(Class)
public static Method getFirstMethod(Class theClass, String name)
public static String getPackageName(Class theClass)
theClass
-
public static String getPackageName(String qualifiedName)
qualifiedName
-
public static String getShortName(Class type)
type
-
public static String getShortName(String qualifiedName)
qualifiedName
-
public static Object newInstance(Class theClass)
theClass
- The type to instantiate.
public static Object newInstance(String className)
getClass(String, ClassLoader)
,
newInstance(Class)
public static Object newInstance(String className, ClassLoader classLoader)
getClass(String, ClassLoader)
,
newInstance(Class)
public static void setHelper(ReflectUtilHelper helper)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |