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