com.generationjava.lang
Class ClassW

java.lang.Object
  extended by com.generationjava.lang.ClassW

public final class ClassW
extends java.lang.Object

A set of static utilities for use with Classes.

Author:
bayard@generationjava.com

Constructor Summary
ClassW()
           
 
Method Summary
static void callMain(java.lang.String[] args)
           
static void callMain(java.lang.String classname, java.lang.String[] args)
           
static void callStatic(java.lang.String classname, java.lang.String methodName, java.lang.Class[] types, java.lang.Object[] args)
          Runs a static method on a class.
static boolean classExists(java.lang.String classname)
          Is this Class in the CLASSPATH
static boolean classExtends(java.lang.Class clss, java.lang.String exts)
          Does this Class extend a superclass with this name.
static boolean classImplements(java.lang.Class clss, java.lang.String exts)
          Does this Class implement an interface with this name.
static boolean classInstanceOf(java.lang.Class clss, java.lang.String inst)
          Is this Class object an instance of the class with this name.
static java.lang.Object createObject(java.lang.Class clss)
          Create an object from a class.
static java.lang.Object createObject(java.lang.String classname)
          Create an object from the classname.
static java.lang.Class getClass(java.lang.String classname)
          Get the Class object for a classname.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassW

public ClassW()
Method Detail

createObject

public static java.lang.Object createObject(java.lang.String classname)
Create an object from the classname. Must have an empty constructor.

Parameters:
classname - String name of the class
Returns:
Object instance of the class or null

createObject

public static java.lang.Object createObject(java.lang.Class clss)
Create an object from a class.

Parameters:
clss - Class object to instantiate
Returns:
Object instance of the class or null

classExists

public static boolean classExists(java.lang.String classname)
Is this Class in the CLASSPATH

Parameters:
classname - String of the class
Returns:
boolean exists or not.

getClass

public static java.lang.Class getClass(java.lang.String classname)
Get the Class object for a classname.

Parameters:
classname - String of the class
Returns:
Class instance for the class.

classInstanceOf

public static boolean classInstanceOf(java.lang.Class clss,
                                      java.lang.String inst)
Is this Class object an instance of the class with this name.

Parameters:
clss - Class instance
inst - String name of potential supertype
Returns:
boolean was it an instanceof

classImplements

public static boolean classImplements(java.lang.Class clss,
                                      java.lang.String exts)
Does this Class implement an interface with this name.

Parameters:
clss - Class instance
exts - String name of potential interface
Returns:
boolean was it an implementor

classExtends

public static boolean classExtends(java.lang.Class clss,
                                   java.lang.String exts)
Does this Class extend a superclass with this name.

Parameters:
clss - Class instance
exts - String name of potential superclass
Returns:
boolean was it a superclass

callMain

public static void callMain(java.lang.String[] args)

callMain

public static void callMain(java.lang.String classname,
                            java.lang.String[] args)

callStatic

public static void callStatic(java.lang.String classname,
                              java.lang.String methodName,
                              java.lang.Class[] types,
                              java.lang.Object[] args)
Runs a static method on a class.

Parameters:
classname - String name of class to invoke on.
method - String name of method to call.
args - Object[] arguments to method.