|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.composite.util.ClassUtils net.sf.morph.util.ClassUtils
public abstract class ClassUtils
Class manipulation utilities. Note that some code was copied from the Spring framework. Some other code was copied from Apache Ant.
Field Summary | |
---|---|
static java.lang.Class[] |
ARRAY_TYPES
All the base array classes. |
Constructor Summary | |
---|---|
ClassUtils()
|
Method Summary | |
---|---|
static java.lang.Class |
convertToClass(java.lang.Object type)
Converts the given object to a Class object. |
static java.lang.Class[] |
getAllClasses()
Returns the set of classes for which any class will match. |
static java.lang.Class |
getArrayClass(java.lang.Class componentType)
Returns an array version of the given class (for example, converts Long to Long[]). |
static java.lang.Class |
getClass(java.lang.Object object)
Returns the class of the given object. |
static java.lang.Class[] |
getImmutableTypes()
Get the known immutable types. |
static java.lang.Class[] |
getPrimitiveTypes()
Get all the primitive classes. |
static java.lang.Class |
getPrimitiveWrapper(java.lang.Class c)
Get the wrapper type for the specified class (if any). |
static java.lang.Class[] |
getWrapperTypes()
Get all the primitive wrapper classes. |
static boolean |
inheritanceContains(java.lang.Class[] typeArray,
java.lang.Class type)
Determines if type is equal to or a subtype of any of the
types in typeArray . |
static boolean |
isBeanUtilsPresent()
Indicates whether the Apache Commons BeanUtils API is available. |
static boolean |
isCommonsCollections3Present()
Indicates whether Commons Collections 3.x is available on the classpath. |
static boolean |
isImmutable(java.lang.Class destinationType)
Determines whether the given destinationType is one of the
primitive immutable types provided by the JDK (i.e. |
static boolean |
isImmutableObject(java.lang.Object o)
Determines whether the given object is an immutable object. |
static boolean |
isJspApiPresent()
Indicates whether the JSP API is available. |
static boolean |
isServletApiPresent()
Indicates whether the Servlet API is available. |
static boolean |
isVelocityPresent()
Indicates whether Velocity is available. |
static java.lang.Object |
newInstance(java.lang.Object type)
Returns a new instance of the class denoted by type . |
Methods inherited from class net.sf.composite.util.ClassUtils |
---|
createArray, getContainedClass, getInterfaces, getUnqualifiedClassName, isClassPresent, isJdk14OrHigherPresent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Class[] ARRAY_TYPES
Constructor Detail |
---|
public ClassUtils()
Method Detail |
---|
public static java.lang.Class getArrayClass(java.lang.Class componentType)
public static java.lang.Object newInstance(java.lang.Object type)
type
. The
type may be expressed as a Class object, a String or a StringBuffer.
type
- an object that specifies the class of the new instance
ReflectionException
- if a new instance of the requested class could not be created
TransformationException
- if the class denoted by the given type could not be retrieved
java.lang.IllegalArgumentException
- if the type parameter is null or not a Class, String or
StringBufferpublic static java.lang.Class convertToClass(java.lang.Object type)
type
- an object that specifies the class
TransformationException
- if the class could not be retrieved for some reason
java.lang.IllegalArgumentException
- if the type parameter is null or not a Class, String or
StringBufferpublic static boolean isServletApiPresent()
true
if the servlet API is available or false
otherwisepublic static boolean isJspApiPresent()
true
if the JSP API is available or false
otherwisepublic static boolean isBeanUtilsPresent()
true
if the BeanUtils API is available or false
otherwisepublic static boolean isVelocityPresent()
true
if Velocity is available or false
otherwisepublic static boolean isCommonsCollections3Present()
true
Commons Collections 3.x is available on the
classpathfalse
otherwisepublic static boolean inheritanceContains(java.lang.Class[] typeArray, java.lang.Class type)
type
is equal to or a subtype of any of the
types in typeArray
.
type
- the type to testtypeArray
- the array of types
true
, if type
if type
is equal to or a subtype of any of the types in
typeArray
or false
, otherwise
java.lang.IllegalArgumentException
- if any of the types in the provided typeArray
are null
public static java.lang.Class getClass(java.lang.Object object)
object
- the object
null
, if type
is null
or public static boolean isImmutable(java.lang.Class destinationType)
destinationType
is one of the
primitive immutable types provided by the JDK (i.e. a Number or a
String). Note that JDK 1.6 adds AtomicLong and AtomicInteger, which
are not immutable.
destinationType
- the type to examine
true
if the destinationType
is an immutable
number or a String or false
, otherwisepublic static boolean isImmutableObject(java.lang.Object o)
o
-
public static java.lang.Class[] getImmutableTypes()
public static java.lang.Class getPrimitiveWrapper(java.lang.Class c)
c
- a (presumably primitive) Class.
c
, if c
is primitive, else null.public static java.lang.Class[] getPrimitiveTypes()
public static java.lang.Class[] getWrapperTypes()
public static java.lang.Class[] getAllClasses()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |