| java.lang.Object org.apache.ojb.broker.util.ClassHelper
ClassHelper | public class ClassHelper (Code) | | Helper class with static methods for java class, method, and field handling.
version: $Id: ClassHelper.java,v 1.10.2.3 2005/12/21 22:27:47 tomdz Exp $ |
Method Summary | |
public static Object | buildNewObjectInstance(ClassDescriptor cld) Builds a new instance for the class represented by the given class descriptor. | public static Class | getClass(String className, boolean initialize) Retrieves the class object for the given qualified class name. | public static Class | getClass(String name) | public static ClassLoader | getClassLoader() Returns the class loader currently used by OJB. | public static Field | getField(Class clazz, String fieldName) Determines the field via reflection look-up. | public static Method | getMethod(Class clazz, String methodName, Class[] params) Determines the method with the specified signature via reflection look-up. | public static Method | getMethod(Object object, String methodName, Class[] params) Determines the method with the specified signature via reflection look-up. | public static Method | getMethod(String className, String methodName, Class[] params) Determines the method with the specified signature via reflection look-up. | public static URL | getResource(String name) Determines the url of the indicated resource using the currently set class loader. | public static Object | newInstance(Class target) Returns a new instance of the given class, using the default or a no-arg constructor. | public static Object | newInstance(Class target, boolean makeAccessible) Returns a new instance of the given class, using the default or a no-arg constructor. | public 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. | public 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. | public 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. | public 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. | public static Object | newInstance(Class target, Class type, Object arg) Returns a new instance of the given class using the constructor with the specified parameter. | public 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. | public static void | setClassLoader(ClassLoader loader) Sets the classloader to be used by OJB. |
buildNewObjectInstance | public static Object buildNewObjectInstance(ClassDescriptor cld)(Code) | | Builds a new instance for the class represented by the given class descriptor.
Parameters: cld - The class descriptor The instance |
getClass | public static Class getClass(String className, boolean initialize) throws ClassNotFoundException(Code) | | Retrieves the class object for the given qualified class name.
Parameters: className - The qualified name of the class Parameters: initialize - Whether the class shall be initialized The class object |
getClassLoader | public static ClassLoader getClassLoader()(Code) | | Returns the class loader currently used by OJB. Defaults to the class loader of
the current thread (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.
The classloader used by OJB See Also: ClassHelper.setClassLoader(ClassLoader) |
getField | public static Field getField(Class clazz, String fieldName)(Code) | | Determines the field via reflection look-up.
Parameters: clazz - The java class to search in Parameters: fieldName - The field's name The field object or null if no matching field was found |
getMethod | public static Method getMethod(Class clazz, String methodName, Class[] params)(Code) | | Determines the method with the specified signature via reflection look-up.
Parameters: clazz - The java class to search in Parameters: methodName - The method's name Parameters: params - The parameter types The method object or null if no matching method was found |
getMethod | public static Method getMethod(Object object, String methodName, Class[] params)(Code) | | Determines the method with the specified signature via reflection look-up.
Parameters: object - The instance whose class is searched for the method Parameters: methodName - The method's name Parameters: params - The parameter types A method object or null if no matching method was found |
getMethod | public static Method getMethod(String className, String methodName, Class[] params)(Code) | | Determines the method with the specified signature via reflection look-up.
Parameters: className - The qualified name of the searched class Parameters: methodName - The method's name Parameters: params - The parameter types A method object or null if no matching method was found |
getResource | public static URL getResource(String name)(Code) | | Determines the url of the indicated resource using the currently set class loader.
Parameters: name - The resource name The resource's url |
newInstance | public static Object newInstance(Class target, boolean makeAccessible) throws InstantiationException, IllegalAccessException(Code) | | Returns a new instance of the given class, using the default or a no-arg constructor.
This method can also use private no-arg constructors if makeAccessible
is set to true (and there are no other security constraints).
Parameters: target - The class to instantiate Parameters: makeAccessible - If the constructor shall be made accessible prior to using it The instance |
setClassLoader | public static void setClassLoader(ClassLoader loader)(Code) | | Sets the classloader to be used by OJB. This can be set by external
application that need to pass a specific classloader to OJB.
Parameters: loader - The class loader. If null then OJB will usethe class loader of the current thread |
|
|