jd.util
Class ClassUtil

java.lang.Object
  extended byjd.util.ClassUtil

public class ClassUtil
extends Object

A collection of class utility functions.


Constructor Summary
ClassUtil()
           
 
Method Summary
static Class classForName(String className)
          A replacement for Class.forName.
static String getClassName(Class c)
          Return the name of a class without the package prefix.
static String getClassName(Object object)
          Return the name of the class of an object without the package prefix.
static String getPackageName(Class c)
          Return package prefix of a class name.
static String getPackageName(Object object)
          Return package prefix of a class name.
static Object newInstance(Class c, Object parameter)
          Create a new instance of a class calling a constructor with one argument.
static Object newInstance(Class c, Object[] parameters)
          Create a new instance of a class calling a constructor with several arguments.
static Object newInstance(String className)
          Create a new instance of a class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

classForName

public static Class classForName(String className)
                          throws ClassNotFoundException
A replacement for Class.forName. The method using the context class loader to load a class if running under Java2 or higher.

Throws:
ClassNotFoundException

newInstance

public static Object newInstance(String className)
                          throws InstantiationException,
                                 IllegalAccessException,
                                 ClassNotFoundException
Create a new instance of a class.

Parameters:
className - the name of the class
Throws:
InstantiationException - all possible exceptions are converted to a InstantiationException
IllegalAccessException
ClassNotFoundException

newInstance

public static Object newInstance(Class c,
                                 Object parameter)
                          throws InvocationTargetException,
                                 InstantiationException
Create a new instance of a class calling a constructor with one argument.

Parameters:
c - the Class
parameter - the constructor parameter.
Throws:
InvocationTargetException
InstantiationException

newInstance

public static Object newInstance(Class c,
                                 Object[] parameters)
                          throws InstantiationException,
                                 InvocationTargetException
Create a new instance of a class calling a constructor with several arguments.

Parameters:
parameters - an array of constructor parameters.
Throws:
InstantiationException
InvocationTargetException

getClassName

public static String getClassName(Object object)
Return the name of the class of an object without the package prefix.


getClassName

public static String getClassName(Class c)
Return the name of a class without the package prefix.


getPackageName

public static String getPackageName(Object object)
Return package prefix of a class name.


getPackageName

public static String getPackageName(Class c)
Return package prefix of a class name.