org.barracudamvc.plankton
Class Classes

java.lang.Object
  extended byorg.barracudamvc.plankton.Classes

public class Classes
extends Object

Simple Class utilities


Field Summary
protected static Map clCache
           
protected static org.apache.log4j.Logger logger
           
protected static String NULL_STR
           
 
Constructor Summary
Classes()
           
 
Method Summary
static List getAllInterfaces(Class cl)
           
static List getAllInterfaces(Object obj)
          Get a List of all interfaces that are implemented by an object
static Class getClass(String clName)
          This method provides a cached interface to get a class.
static String getShortClassName(Class cl)
          Get a short version of a class name
static Object newInstance(Class cl)
          Get a new instance of the class, without throwing an InstantiationException.
static Object newInstance(String clName)
          Get a new instance of the class, without throwing an InstantiationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

clCache

protected static Map clCache

NULL_STR

protected static final String NULL_STR
See Also:
Constant Field Values
Constructor Detail

Classes

public Classes()
Method Detail

getClass

public static Class getClass(String clName)
This method provides a cached interface to get a class. If the class exists in the cache, it is simply returned; if it does not, it is created via Class.forName() and then returned (saving a copy in the cache of course). If there is a problem creating the class the exception will be logged and a null value will be returned (which means its up to you to handle it).

Parameters:
clName - the fully qualified class name
Returns:
a reference to the Class

newInstance

public static Object newInstance(Class cl)
Get a new instance of the class, without throwing an InstantiationException. If there is a problem creating the class the exception will be logged and a null value will be returned (which means its up to you to handle it). Note that this means the class must provide a no-args constructor

Parameters:
cl - the class we wish to obtain an instance from
Returns:
a new instance of the class

newInstance

public static Object newInstance(String clName)
Get a new instance of the class, without throwing an InstantiationException. This is a convenience method which takes a String version of the class name, looks up the class via getClass(), and then tries to get an instance of it via newInstance().

Parameters:
clName - the fully qualified class name
Returns:
a new instance of the class

getAllInterfaces

public static List getAllInterfaces(Object obj)
Get a List of all interfaces that are implemented by an object


getAllInterfaces

public static List getAllInterfaces(Class cl)

getShortClassName

public static String getShortClassName(Class cl)
Get a short version of a class name



Copyright © 2004 BarracudaMVC.org All Rights Reserved.