org.apache.ojb.broker.util
Class ClassHelper

java.lang.Object
  extended byorg.apache.ojb.broker.util.ClassHelper

public class ClassHelper
extends java.lang.Object

Version:
$Id: ClassHelper.java,v 1.4 2004/01/24 00:08:58 mattbaird Exp $
Author:
Armin Waibel

Constructor Summary
ClassHelper()
           
 
Method Summary
static java.lang.Class getClass(java.lang.String name)
          Convenience for getClass(name, true)
static java.lang.Class getClass(java.lang.String className, boolean initialize)
          Returns a class object for the given name or null
static java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String fieldName)
          Returns a field via reflection look-up.
static java.lang.reflect.Method getMethod(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] params)
          Returns a method via reflection look-up of the specific signature.
static java.lang.reflect.Method getMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] params)
          Returns a method via reflection look-up of the specific signature.
static java.lang.reflect.Method getMethod(java.lang.String className, java.lang.String methodName, java.lang.Class[] params)
          Returns a method via reflection look-up of the specific signature.
static java.lang.Object newInstance(java.lang.Class target)
          Returns new instance of the given class, using the default constructor.
static java.lang.Object newInstance(java.lang.Class target, java.lang.Class[] types, java.lang.Object[] args)
          Returns new instance of the given class name, using the default constructor.
static java.lang.Object newInstance(java.lang.Class target, java.lang.Class type, java.lang.Object arg)
           
static java.lang.Object newInstance(java.lang.String className)
          Returns new instance of the given class name, using the default constructor.
static java.lang.Object newInstance(java.lang.String className, java.lang.Class[] types, java.lang.Object[] args)
          Returns new instance of the given class name, using the default constructor.
static java.lang.Object newInstance(java.lang.String className, java.lang.Class type, java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassHelper

public ClassHelper()
Method Detail

getClass

public static java.lang.Class getClass(java.lang.String className,
                                       boolean initialize)
                                throws java.lang.ClassNotFoundException
Returns a class object for the given name or null

Throws:
java.lang.ClassNotFoundException

newInstance

public static java.lang.Object newInstance(java.lang.Class target)
                                    throws java.lang.InstantiationException,
                                           java.lang.IllegalAccessException
Returns new instance of the given class, using the default constructor.

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

newInstance

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
Returns new instance of the given class name, using the default constructor.

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class clazz,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] params)
Returns a method via reflection look-up of the specific signature.

Parameters:
clazz - method's java class
methodName - method name
params - method signature
Returns:
method invokable via java.lang.reflect.Method#invoke, or null if no matching method can be found

getField

public static java.lang.reflect.Field getField(java.lang.Class clazz,
                                               java.lang.String fieldName)
Returns a field via reflection look-up.

Parameters:
clazz - fields's java class
fieldName - field name
Returns:
field retrievable via java.lang.reflect.Field#getXXX, or null if no matching field can be found

getClass

public static java.lang.Class getClass(java.lang.String name)
                                throws java.lang.ClassNotFoundException
Convenience for getClass(name, true)

Throws:
java.lang.ClassNotFoundException

newInstance

public static java.lang.Object newInstance(java.lang.String className)
                                    throws java.lang.InstantiationException,
                                           java.lang.IllegalAccessException,
                                           java.lang.ClassNotFoundException
Returns new instance of the given class name, using the default constructor.

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException

newInstance

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
Returns new instance of the given class name, using the default constructor.

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException

newInstance

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
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException

newInstance

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
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Object object,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] params)
Returns a method via reflection look-up of the specific signature.

Parameters:
object - runtime object instance
methodName - method name
params - method signature
Returns:
method invokable via java.lang.reflect.Method#invoke, or null if no matching method can be found

getMethod

public static java.lang.reflect.Method getMethod(java.lang.String className,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] params)
Returns a method via reflection look-up of the specific signature.

Parameters:
className - class name
methodName - method name
params - method signature
Returns:
method invokable via java.lang.reflect.Method#invoke, or null if no matching method can be found


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14