public final class ClassUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Class |
BOOLEAN_ARRAY_CLASS |
static Class |
BOOLEAN_OBJECT_ARRAY_CLASS |
static Class |
BYTE_ARRAY_CLASS |
static Class |
BYTE_OBJECT_ARRAY_CLASS |
static Class |
CHAR_ARRAY_CLASS |
static Class |
CHARACTER_OBJECT_ARRAY_CLASS |
static ClassLoaderExtension[] |
classLoadingExtensions |
static Map |
COMMON_TYPES |
static Class |
DOUBLE_ARRAY_CLASS |
static Class |
DOUBLE_OBJECT_ARRAY_CLASS |
static Class |
FLOAT_ARRAY_CLASS |
static Class |
FLOAT_OBJECT_ARRAY_CLASS |
static Class |
INT_ARRAY_CLASS |
static Class |
INTEGER_OBJECT_ARRAY_CLASS |
static Class |
LONG_ARRAY_CLASS |
static Class |
LONG_OBJECT_ARRAY_CLASS |
static Class |
OBJECT_ARRAY_CLASS |
static Class |
SHORT_ARRAY_CLASS |
static Class |
SHORT_OBJECT_ARRAY_CLASS |
static Class |
STRING_OBJECT_ARRAY_CLASS |
Modifier and Type | Method and Description |
---|---|
static void |
addClassLoadingExtension(ClassLoaderExtension extension,
boolean top) |
static <T> T |
buildApplicationObject(Class<T> interfaceClass,
Class<? extends T> extendedInterfaceClass,
Class<? extends T> extendedInterfaceWrapperClass,
Collection<String> classNamesIterator,
T defaultObject)
Creates ApplicationObjects like NavigationHandler or StateManager and creates
the right wrapping chain of the ApplicationObjects known as the decorator pattern.
|
static <T> T |
buildApplicationObject(Class<T> interfaceClass,
Collection<String> classNamesIterator,
T defaultObject)
Creates ApplicationObjects like NavigationHandler or StateManager and creates
the right wrapping chain of the ApplicationObjects known as the decorator pattern.
|
static Class |
classForName(String type)
Tries a Class.loadClass with the context class loader of the current thread first and
automatically falls back to the ClassUtils class loader (i.e.
|
static Object |
convertToType(Object value,
Class desiredClass) |
static ClassLoader |
getContextClassLoader()
Gets the ClassLoader associated with the current thread.
|
protected static ClassLoader |
getCurrentLoader(Object defaultObject)
Gets the ClassLoader associated with the current thread.
|
static URL |
getResource(String resource) |
static InputStream |
getResourceAsStream(String resource) |
static Iterator |
getResources(String resource,
Object defaultObject) |
static Class |
javaTypeToClass(String type)
Similar as
classForName(String) , but also supports primitive types
and arrays as specified for the JavaType element in the JavaServer Faces Config DTD. |
static <T> T |
newInstance(Class<T> clazz) |
static <T> T |
newInstance(Class<T> clazz,
Class<?>[] constructorArgClasses,
Object... constructorArgs) |
static Object |
newInstance(String type) |
static Object |
newInstance(String type,
Class expectedType) |
static Object |
newInstance(String type,
Class[] expectedTypes) |
static Class |
simpleClassForName(String type)
Same as
classForName(String) , but throws a RuntimeException
(FacesException) instead of a ClassNotFoundException. |
static Class |
simpleJavaTypeToClass(String type)
Same as
javaTypeToClass(String) , but throws a RuntimeException
(FacesException) instead of a ClassNotFoundException. |
public static final Class BOOLEAN_ARRAY_CLASS
public static final Class BYTE_ARRAY_CLASS
public static final Class CHAR_ARRAY_CLASS
public static final Class SHORT_ARRAY_CLASS
public static final Class INT_ARRAY_CLASS
public static final Class LONG_ARRAY_CLASS
public static final Class FLOAT_ARRAY_CLASS
public static final Class DOUBLE_ARRAY_CLASS
public static final Class OBJECT_ARRAY_CLASS
public static final Class BOOLEAN_OBJECT_ARRAY_CLASS
public static final Class BYTE_OBJECT_ARRAY_CLASS
public static final Class CHARACTER_OBJECT_ARRAY_CLASS
public static final Class SHORT_OBJECT_ARRAY_CLASS
public static final Class INTEGER_OBJECT_ARRAY_CLASS
public static final Class LONG_OBJECT_ARRAY_CLASS
public static final Class FLOAT_OBJECT_ARRAY_CLASS
public static final Class DOUBLE_OBJECT_ARRAY_CLASS
public static final Class STRING_OBJECT_ARRAY_CLASS
public static ClassLoaderExtension[] classLoadingExtensions
public static final Map COMMON_TYPES
public static void addClassLoadingExtension(ClassLoaderExtension extension, boolean top)
public static Class classForName(String type) throws ClassNotFoundException
type
- fully qualified name of a non-primitive non-array classNullPointerException
- if type is nullClassNotFoundException
public static Class simpleClassForName(String type)
classForName(String)
, but throws a RuntimeException
(FacesException) instead of a ClassNotFoundException.NullPointerException
- if type is nullFacesException
- if class not foundpublic static Class javaTypeToClass(String type) throws ClassNotFoundException
classForName(String)
, but also supports primitive types
and arrays as specified for the JavaType element in the JavaServer Faces Config DTD.type
- fully qualified class name or name of a primitive type, both optionally
followed by "[]" to indicate an array typeNullPointerException
- if type is nullClassNotFoundException
public static Class simpleJavaTypeToClass(String type)
javaTypeToClass(String)
, but throws a RuntimeException
(FacesException) instead of a ClassNotFoundException.NullPointerException
- if type is nullFacesException
- if class not foundpublic static InputStream getResourceAsStream(String resource)
public static Iterator getResources(String resource, Object defaultObject)
resource
- Name of resource(s) to find in classpathdefaultObject
- The default object to use to determine the class loader (if none associated with current thread.)public static Object newInstance(String type) throws FacesException
FacesException
public static Object newInstance(String type, Class expectedType) throws FacesException
FacesException
public static <T> T newInstance(Class<T> clazz) throws FacesException
FacesException
public static <T> T newInstance(Class<T> clazz, Class<?>[] constructorArgClasses, Object... constructorArgs) throws NoSuchMethodException
NoSuchMethodException
protected static ClassLoader getCurrentLoader(Object defaultObject)
defaultObject
- The default object to use to determine the class loader (if none associated with current thread.)public static ClassLoader getContextClassLoader()
public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject)
T
- interfaceClass
- The class from which the implementation has to inherit from.classNamesIterator
- All the class names of the actual ApplicationObject implementations
from the faces-config.xml.defaultObject
- The default implementation for the given ApplicationObject.public static <T> T buildApplicationObject(Class<T> interfaceClass, Class<? extends T> extendedInterfaceClass, Class<? extends T> extendedInterfaceWrapperClass, Collection<String> classNamesIterator, T defaultObject)
T
- interfaceClass
- The class from which the implementation has to inherit from.extendedInterfaceClass
- A subclass of interfaceClass which specifies a more
detailed implementation.extendedInterfaceWrapperClass
- A wrapper class for the case that you have an ApplicationObject
which only implements the interfaceClass but not the
extendedInterfaceClass.classNamesIterator
- All the class names of the actual ApplicationObject implementations
from the faces-config.xml.defaultObject
- The default implementation for the given ApplicationObject.Copyright © 2016 The Apache Software Foundation. All Rights Reserved.