public final class ClassUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
collectBeanInfo(Class<?> clazz,
Map<String,PropertyDescriptor> name2descriptor)
Collects bean infos from a class and filling a list.
|
static <T> Class<? extends T> |
getClass(String className,
Class<T> baseClass)
Returns the class and casts it to the correct subclass.
It tries to use the thread's current classloader first and, if it does not succeed, uses the classloader of ClassUtil. |
static Object |
instantiate(String className)
Returns an instance of the given class name, by calling the default
constructor.
|
static Object |
instantiate(String className,
boolean returnNull)
Returns an instance of the given class name, by calling the default
constructor.
|
public static <T> Class<? extends T> getClass(String className, Class<T> baseClass) throws ClassNotFoundException
T
- The subclass to use.className
- The name of the class to load.baseClass
- The base class to subclass to.ClassNotFoundException
- If the class has not been found.public static Object instantiate(String className)
className
- The class name to load and to instantiate.CannotInstantiateObjectException
- If something goes wrong during
instantiation.public static Object instantiate(String className, boolean returnNull)
className
- The class name to load and to instantiate.returnNull
- If true
, if the class is not found it
returns true
, otherwise it throws a
TilesException
.CannotInstantiateObjectException
- If something goes wrong during instantiation.public static void collectBeanInfo(Class<?> clazz, Map<String,PropertyDescriptor> name2descriptor)
clazz
- The class to be inspected.name2descriptor
- The map in the form: name of the property ->
descriptor.Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.