public class ClassUtils extends Object
| Constructor and Description | 
|---|
| ClassUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static <T> Class<T> | 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 Object | convertToTypeNoLogging(FacesContext facesContext,
                      Object value,
                      Class<?> desiredClass) | 
| static Class<?> | forName(String name) | 
| static Class<?> | forNamePrimitive(String name) | 
| static ClassLoader | getContextClassLoader()Gets the ClassLoader associated with the current thread. | 
| static ClassLoader | getCurrentLoader(Class<?> clazz) | 
| static ClassLoader | getCurrentLoader(Object defaultObject)Gets the ClassLoader associated with the current thread. | 
| static URL | getResource(String resource) | 
| static InputStream | getResourceAsStream(String resource) | 
| static Collection<URL> | getResources(String resource,
            Object defaultObject) | 
| static Class | javaDefaultTypeToClass(String type)This method is similar to shared ClassUtils.javaTypeToClass,
 but the default package for the type is java.lang | 
| 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 | simpleClassForName(String type,
                  boolean logException)Same as {link  simpleClassForName(String), but will only
 log the exception and rethrow a RunTimeException if logException is true. | 
| static Class<?> | simpleJavaTypeToClass(String type)Same as  javaTypeToClass(String), but throws a RuntimeException (FacesException) instead of a
 ClassNotFoundException. | 
| static Class<?>[] | toTypeArray(String[] s)Converts an array of Class names to Class types | 
| static String[] | toTypeNameArray(Class<?>[] c)Converts an array of Class types to Class names | 
public static final Class<boolean[]> BOOLEAN_ARRAY_CLASS
public static final Class<byte[]> BYTE_ARRAY_CLASS
public static final Class<char[]> CHAR_ARRAY_CLASS
public static final Class<short[]> SHORT_ARRAY_CLASS
public static final Class<int[]> INT_ARRAY_CLASS
public static final Class<long[]> LONG_ARRAY_CLASS
public static final Class<float[]> FLOAT_ARRAY_CLASS
public static final Class<double[]> DOUBLE_ARRAY_CLASS
protected static final String[] EMPTY_STRING
protected static final String[] PRIMITIVE_NAMES
protected static final Class<?>[] PRIMITIVES
public static <T> Class<T> classForName(String type) throws ClassNotFoundException
type - fully qualified name of a non-primitive non-array classNullPointerException - if type is nullClassNotFoundExceptionpublic 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 simpleClassForName(String type, boolean logException)
simpleClassForName(String), but will only
 log the exception and rethrow a RunTimeException if logException is true.type - logException - - true to log/throw FacesException, false to avoid logging/throwing FacesExceptionFacesException - if class not found and logException is truepublic 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 nullClassNotFoundExceptionpublic 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 Class javaDefaultTypeToClass(String type) throws ClassNotFoundException
type - ClassNotFoundExceptionpublic static InputStream getResourceAsStream(String resource)
public static Collection<URL> 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
FacesExceptionpublic static Object newInstance(String type, Class<?> expectedType) throws FacesException
FacesExceptionpublic static <T> T newInstance(Class<T> clazz) throws FacesException
FacesExceptionpublic static <T> T newInstance(Class<T> clazz, Class<?>[] constructorArgClasses, Object... constructorArgs) throws NoSuchMethodException
NoSuchMethodExceptionpublic static Object convertToTypeNoLogging(FacesContext facesContext, Object value, Class<?> desiredClass) throws Exception
Exceptionpublic 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 getCurrentLoader(Class<?> clazz)
public static ClassLoader getContextClassLoader()
public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException
s - ClassNotFoundExceptionpublic static String[] toTypeNameArray(Class<?>[] c)
c - public static Class<?> forName(String name) throws ClassNotFoundException
ClassNotFoundExceptionCopyright © 2022 The Apache Software Foundation. All rights reserved.