Class ClassUtils
java.lang.Object
org.apache.myfaces.core.api.shared.lang.ClassUtils
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Class<boolean[]>static final Class<byte[]>static final Class<char[]>static final Class<double[]>protected static final String[]static final Class<float[]>static final Class<int[]>static final Class<long[]>protected static final String[]protected static final Class<?>[]static final Class<short[]>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <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 ObjectconvertToType(Object value, Class<?> desiredClass) static ObjectconvertToTypeNoLogging(FacesContext facesContext, Object value, Class<?> desiredClass) static Class<?>static Class<?>forNamePrimitive(String name) static ClassLoaderGets the ClassLoader associated with the current thread.static ClassLoadergetCurrentLoader(Class<?> clazz) static ClassLoadergetCurrentLoader(Object defaultObject) Gets the ClassLoader associated with the current thread.static URLgetResource(String resource) static InputStreamgetResourceAsStream(String resource) static Collection<URL>getResources(String resource, Object defaultObject) static ClassjavaDefaultTypeToClass(String type) This method is similar to shared ClassUtils.javaTypeToClass, but the default package for the type is java.langstatic Class<?>javaTypeToClass(String type) Similar asclassForName(String), but also supports primitive types and arrays as specified for the JavaType element in the JavaServer Faces Config DTD.static <T> TnewInstance(Class<T> clazz) static <T> TnewInstance(Class<T> clazz, Class<?>[] constructorArgClasses, Object... constructorArgs) static ObjectnewInstance(String type) static ObjectnewInstance(String type, Class<?> expectedType) static ObjectnewInstance(String type, Class<?>[] expectedTypes) static ClasssimpleClassForName(String type) Same asclassForName(String), but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.static ClasssimpleClassForName(String type, boolean logAndThrowException) Same as {linksimpleClassForName(String), but will only log the exception and rethrow a RunTimeException if logAndThrowException is true.static ClasssimpleClassForName(String type, boolean throwException, boolean logException) Same as {linksimpleClassForName(String), but accepts two booleans One to log an exception and another to rethrow a FacesExceptionsstatic Class<?>simpleJavaTypeToClass(String type) Same asjavaTypeToClass(String), but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.static Class<?>[]toTypeArray(String[] s) Converts an array of Class names to Class typesstatic String[]toTypeNameArray(Class<?>[] c) Converts an array of Class types to Class names
- 
Field Details- 
BOOLEAN_ARRAY_CLASS
- 
BYTE_ARRAY_CLASS
- 
CHAR_ARRAY_CLASS
- 
SHORT_ARRAY_CLASS
- 
INT_ARRAY_CLASS
- 
LONG_ARRAY_CLASS
- 
FLOAT_ARRAY_CLASS
- 
DOUBLE_ARRAY_CLASS
- 
OBJECT_ARRAY_CLASS
- 
BOOLEAN_OBJECT_ARRAY_CLASS
- 
BYTE_OBJECT_ARRAY_CLASS
- 
CHARACTER_OBJECT_ARRAY_CLASS
- 
SHORT_OBJECT_ARRAY_CLASS
- 
INTEGER_OBJECT_ARRAY_CLASS
- 
LONG_OBJECT_ARRAY_CLASS
- 
FLOAT_OBJECT_ARRAY_CLASS
- 
DOUBLE_OBJECT_ARRAY_CLASS
- 
STRING_OBJECT_ARRAY_CLASS
- 
EMPTY_STRING
- 
PRIMITIVE_NAMES
- 
PRIMITIVES
- 
COMMON_TYPES
 
- 
- 
Constructor Details- 
ClassUtilspublic ClassUtils()
 
- 
- 
Method Details- 
classForNameTries a Class.loadClass with the context class loader of the current thread first and automatically falls back to the ClassUtils class loader (i.e. the loader of the myfaces.jar lib) if necessary.- Parameters:
- type- fully qualified name of a non-primitive non-array class
- Returns:
- the corresponding Class
- Throws:
- NullPointerException- if type is null
- ClassNotFoundException
 
- 
simpleClassForNameSame asclassForName(String), but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.- Returns:
- the corresponding Class
- Throws:
- NullPointerException- if type is null
- FacesException- if class not found
 
- 
simpleClassForNameSame as {linksimpleClassForName(String), but will only log the exception and rethrow a RunTimeException if logAndThrowException is true.- Parameters:
- type-
- logAndThrowException- - true to log and throw FacesException, false to avoid logging and throwing the FacesException
- Returns:
- the corresponding Class
- Throws:
- FacesException- if class not found and logAndThrowException is true
 
- 
simpleClassForNameSame as {linksimpleClassForName(String), but accepts two booleans One to log an exception and another to rethrow a FacesExceptions- Parameters:
- type-
- logException- - true to log the ClassNotFoundException, false to avoid logging
- throwException- - true to throw a FacesException, false to avoid throwing a FacesException
- Returns:
- the corresponding Class
- Throws:
- FacesException- if class not found and throwException is true
 
- 
javaTypeToClassSimilar asclassForName(String), but also supports primitive types and arrays as specified for the JavaType element in the JavaServer Faces Config DTD.- Parameters:
- type- fully qualified class name or name of a primitive type, both optionally followed by "[]" to indicate an array type
- Returns:
- the corresponding Class
- Throws:
- NullPointerException- if type is null
- ClassNotFoundException
 
- 
simpleJavaTypeToClassSame asjavaTypeToClass(String), but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.- Returns:
- the corresponding Class
- Throws:
- NullPointerException- if type is null
- FacesException- if class not found
 
- 
javaDefaultTypeToClassThis method is similar to shared ClassUtils.javaTypeToClass, but the default package for the type is java.lang- Parameters:
- type-
- Returns:
- Throws:
- ClassNotFoundException
 
- 
getResource
- 
getResourceAsStream
- 
getResources- Parameters:
- resource- Name of resource(s) to find in classpath
- defaultObject- The default object to use to determine the class loader (if none associated with current thread.)
- Returns:
- Iterator over URL Objects
 
- 
newInstance- Throws:
- FacesException
 
- 
newInstance- Throws:
- FacesException
 
- 
newInstance
- 
newInstance- Throws:
- FacesException
 
- 
newInstancepublic static <T> T newInstance(Class<T> clazz, Class<?>[] constructorArgClasses, Object... constructorArgs) throws NoSuchMethodException - Throws:
- NoSuchMethodException
 
- 
convertToType
- 
convertToTypeNoLoggingpublic static Object convertToTypeNoLogging(FacesContext facesContext, Object value, Class<?> desiredClass) throws Exception - Throws:
- Exception
 
- 
getCurrentLoaderGets the ClassLoader associated with the current thread. Returns the class loader associated with the specified default object if no context loader is associated with the current thread.- Parameters:
- defaultObject- The default object to use to determine the class loader (if none associated with current thread.)
- Returns:
- ClassLoader
 
- 
getCurrentLoader
- 
getContextClassLoaderGets the ClassLoader associated with the current thread. Returns the class loader associated with the specified default object if no context loader is associated with the current thread.- Returns:
- ClassLoader
 
- 
forNamePrimitive
- 
toTypeArrayConverts an array of Class names to Class types- Parameters:
- s-
- Returns:
- Throws:
- ClassNotFoundException
 
- 
toTypeNameArrayConverts an array of Class types to Class names- Parameters:
- c-
- Returns:
 
- 
forName- Throws:
- ClassNotFoundException
 
 
-