|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.ojb.broker.util.ClassHelper
public class ClassHelper
Helper class with static methods for java class, method, and field handling.
| Method Summary | |
|---|---|
static Object |
buildNewObjectInstance(ClassDescriptor cld)
Builds a new instance for the class represented by the given class descriptor. |
static Class |
getClass(String name)
Convenience method for getClass(name, true) |
static Class |
getClass(String className,
boolean initialize)
Retrieves the class object for the given qualified class name. |
static ClassLoader |
getClassLoader()
Returns the class loader currently used by OJB. |
static Field |
getField(Class clazz,
String fieldName)
Determines the field via reflection look-up. |
static Method |
getMethod(Class clazz,
String methodName,
Class[] params)
Determines the method with the specified signature via reflection look-up. |
static Method |
getMethod(Object object,
String methodName,
Class[] params)
Determines the method with the specified signature via reflection look-up. |
static Method |
getMethod(String className,
String methodName,
Class[] params)
Determines the method with the specified signature via reflection look-up. |
static URL |
getResource(String name)
Determines the url of the indicated resource using the currently set class loader. |
static Object |
newInstance(Class target)
Returns a new instance of the given class, using the default or a no-arg constructor. |
static Object |
newInstance(Class target,
boolean makeAccessible)
Returns a new instance of the given class, using the default or a no-arg constructor. |
static Object |
newInstance(Class target,
Class[] types,
Object[] args)
Returns a new instance of the given class, using the constructor with the specified parameter types. |
static Object |
newInstance(Class target,
Class[] types,
Object[] args,
boolean makeAccessible)
Returns a new instance of the given class, using the constructor with the specified parameter types. |
static Object |
newInstance(Class target,
Class type,
Object arg)
Returns a new instance of the given class using the constructor with the specified parameter. |
static Object |
newInstance(String className)
Returns a new instance of the class with the given qualified name using the default or or a no-arg constructor. |
static Object |
newInstance(String className,
Class[] types,
Object[] args)
Returns a new instance of the class with the given qualified name using the constructor with the specified signature. |
static Object |
newInstance(String className,
Class type,
Object arg)
Returns a new instance of the class with the given qualified name using the constructor with the specified parameter. |
static void |
setClassLoader(ClassLoader loader)
Sets the classloader to be used by OJB. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void setClassLoader(ClassLoader loader)
loader - The class loader. If null then OJB will use
the class loader of the current threadpublic static ClassLoader getClassLoader()
Thread.currentThread().getContextClassLoader())
if not set differently. If class loader is not explicitly set and the loader for
the current thread context is null, the JVM default class loader will be used.
setClassLoader(ClassLoader)public static URL getResource(String name)
name - The resource name
public static Class getClass(String className,
boolean initialize)
throws ClassNotFoundException
className - The qualified name of the classinitialize - Whether the class shall be initialized
ClassNotFoundException
public static Object newInstance(Class target)
throws InstantiationException,
IllegalAccessException
target - The class to instantiate
InstantiationException
IllegalAccessException
public static Object newInstance(Class target,
boolean makeAccessible)
throws InstantiationException,
IllegalAccessException
makeAccessible
is set to true (and there are no other security constraints).
target - The class to instantiatemakeAccessible - If the constructor shall be made accessible prior to using it
InstantiationException
IllegalAccessException
public static Object newInstance(Class target,
Class[] types,
Object[] args)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException
target - The class to instantiatetypes - The parameter typesargs - The arguments
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
public static Object newInstance(Class target,
Class[] types,
Object[] args,
boolean makeAccessible)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException
makeAccessible is set to
true (and there are no other security constraints).
target - The class to instantiatetypes - The parameter typesargs - The argumentsmakeAccessible - If the constructor shall be made accessible prior to using it
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
public static Method getMethod(Class clazz,
String methodName,
Class[] params)
clazz - The java class to search inmethodName - The method's nameparams - The parameter types
null if no matching method was found
public static Field getField(Class clazz,
String fieldName)
clazz - The java class to search infieldName - The field's name
null if no matching field was found
public static Class getClass(String name)
throws ClassNotFoundException
getClass(name, true)
name - The qualified class name
ClassNotFoundException
public static Object newInstance(String className)
throws InstantiationException,
IllegalAccessException,
ClassNotFoundException
className - The qualified name of the class to instantiate
InstantiationException
IllegalAccessException
ClassNotFoundException
public static Object newInstance(String className,
Class[] types,
Object[] args)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException,
ClassNotFoundException
className - The qualified name of the class to instantiatetypes - The parameter typesargs - The arguments
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
ClassNotFoundException
public static Object newInstance(Class target,
Class type,
Object arg)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException
target - The class to instantiatetype - The types of the single parameter of the constructorarg - The argument
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
public static Object newInstance(String className,
Class type,
Object arg)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException,
ClassNotFoundException
className - The qualified name of the class to instantiatetype - The types of the single parameter of the constructorarg - The argument
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
ClassNotFoundException
public static Method getMethod(Object object,
String methodName,
Class[] params)
object - The instance whose class is searched for the methodmethodName - The method's nameparams - The parameter types
null if no matching method was found
public static Method getMethod(String className,
String methodName,
Class[] params)
className - The qualified name of the searched classmethodName - The method's nameparams - The parameter types
null if no matching method was foundpublic static Object buildNewObjectInstance(ClassDescriptor cld)
cld - The class descriptor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||