net.sf.composite.util
Class ClassUtils

java.lang.Object
  extended by net.sf.composite.util.ClassUtils

public abstract class ClassUtils
extends java.lang.Object

Since:
Mar 11, 2005
Author:
Matt Sgarlata

Constructor Summary
ClassUtils()
           
 
Method Summary
static java.lang.Object createArray(java.lang.Class componentType, int length)
          Creates a new array with the specified component type and length.
static java.lang.Class getContainedClass(java.lang.Class arrayClass)
          Returns the type of object that makes up the given array class (for example, converts Long[] to Long)
static java.lang.Class[] getInterfaces(java.lang.Class clazz)
          Return all interfaces implemented by the specified class.
static java.lang.String getUnqualifiedClassName(java.lang.Class clazz)
          Returns a class' name without a package prefix.
static boolean isClassPresent(java.lang.String className)
          Tests whether the given className can be found by the classloader that loaded this class.
static boolean isJdk14OrHigherPresent()
          Indicates whether we are running under JDK 1.4 or higher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

getContainedClass

public static java.lang.Class getContainedClass(java.lang.Class arrayClass)
Returns the type of object that makes up the given array class (for example, converts Long[] to Long)


isClassPresent

public static boolean isClassPresent(java.lang.String className)
Tests whether the given className can be found by the classloader that loaded this class.

Parameters:
className - the class for which we are searching
Returns:
true if the class indicated by className is present or
false, otherwise

isJdk14OrHigherPresent

public static boolean isJdk14OrHigherPresent()
Indicates whether we are running under JDK 1.4 or higher.

Returns:
true if we are running in JDK 1.4 or higher or
false otherwise

createArray

public static java.lang.Object createArray(java.lang.Class componentType,
                                           int length)
Creates a new array with the specified component type and length. Equivalent to calling Array.newInstance(java.lang.Class, int).

Parameters:
componentType - the Class object representing the most general type of object which may be contained in the new array
length - the length of the new array
Returns:
the new array
Throws:
java.lang.NullPointerException - if componentType is null
java.lang.IllegalArgumentException - if componentType is Void.TYPE
java.lang.NegativeArraySizeException - if length is negative

getUnqualifiedClassName

public static java.lang.String getUnqualifiedClassName(java.lang.Class clazz)
Returns a class' name without a package prefix. For example, ClassUtils.getUnqualifiedClassName(ClassUtils.class) would return ClassUtils.

Parameters:
clazz - the class whose name we are to return
Returns:
the class' name
Throws:
java.lang.NullPointerException - if clazz is null.

getInterfaces

public static java.lang.Class[] getInterfaces(java.lang.Class clazz)
Return all interfaces implemented by the specified class.

Parameters:
clazz - a Class.
Returns:
Class[]


Copyright © 2005-2008.