## org.apache.myfaces.util
Class ClassUtils

    java.lang.Object
      org.apache.myfaces.util.ClassUtils

public class ClassUtils
extends java.lang.Object

Version:
  $Revision: 265527 $ $Date: 2005-08-31 12:32:30 -0400 (Wed, 31 Aug 2005) $
Author:
  Manfred Geiler (latest modification by $Author: manolito $), Anton Koinov

Field Summary
`static java.lang.Class` `BOOLEAN_ARRAY_CLASS`
`static java.lang.Class` `BOOLEAN_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `BYTE_ARRAY_CLASS`
`static java.lang.Class` `BYTE_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `CHAR_ARRAY_CLASS`
`static java.lang.Class` `CHARACTER_OBJECT_ARRAY_CLASS`
`static java.util.Map` `COMMON_TYPES`
`static java.lang.Class` `DOUBLE_ARRAY_CLASS`
`static java.lang.Class` `DOUBLE_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `FLOAT_ARRAY_CLASS`
`static java.lang.Class` `FLOAT_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `INT_ARRAY_CLASS`
`static java.lang.Class` `INTEGER_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `LONG_ARRAY_CLASS`
`static java.lang.Class` `LONG_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `OBJECT_ARRAY_CLASS`
`static java.lang.Class` `SHORT_ARRAY_CLASS`
`static java.lang.Class` `SHORT_OBJECT_ARRAY_CLASS`
`static java.lang.Class` `STRING_OBJECT_ARRAY_CLASS`

Method Summary
`static java.lang.Class` `classForName(java.lang.String type)` Tries a Class.forName 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.
`static java.lang.Object` `convertToType(java.lang.Object value, java.lang.Class desiredClass)`
`protected static java.lang.ClassLoader` `getCurrentLoader(java.lang.Object defaultObject)` Gets the ClassLoader associated with the current thread.
`static java.io.InputStream` `getResourceAsStream(java.lang.String resource)`
`static java.util.Iterator` `getResources(java.lang.String resource, java.lang.Object defaultObject)`
`static java.lang.Class` `javaTypeToClass(java.lang.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 java.lang.Object` `newInstance(java.lang.Class clazz)`
`static java.lang.Object` `newInstance(java.lang.String type)`
`static java.lang.Class` `simpleClassForName(java.lang.String type)` Same as `classForName(String)`, but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.
`static java.lang.Class` `simpleJavaTypeToClass(java.lang.String type)` Same as `javaTypeToClass(String)`, but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### BOOLEAN_ARRAY_CLASS

    public static final java.lang.Class BOOLEAN_ARRAY_CLASS

### BYTE_ARRAY_CLASS

    public static final java.lang.Class BYTE_ARRAY_CLASS

### CHAR_ARRAY_CLASS

    public static final java.lang.Class CHAR_ARRAY_CLASS

### SHORT_ARRAY_CLASS

    public static final java.lang.Class SHORT_ARRAY_CLASS

### INT_ARRAY_CLASS

    public static final java.lang.Class INT_ARRAY_CLASS

### LONG_ARRAY_CLASS

    public static final java.lang.Class LONG_ARRAY_CLASS

### FLOAT_ARRAY_CLASS

    public static final java.lang.Class FLOAT_ARRAY_CLASS

### DOUBLE_ARRAY_CLASS

    public static final java.lang.Class DOUBLE_ARRAY_CLASS

### OBJECT_ARRAY_CLASS

    public static final java.lang.Class OBJECT_ARRAY_CLASS

### BOOLEAN_OBJECT_ARRAY_CLASS

    public static final java.lang.Class BOOLEAN_OBJECT_ARRAY_CLASS

### BYTE_OBJECT_ARRAY_CLASS

    public static final java.lang.Class BYTE_OBJECT_ARRAY_CLASS

### CHARACTER_OBJECT_ARRAY_CLASS

    public static final java.lang.Class CHARACTER_OBJECT_ARRAY_CLASS

### SHORT_OBJECT_ARRAY_CLASS

    public static final java.lang.Class SHORT_OBJECT_ARRAY_CLASS

### INTEGER_OBJECT_ARRAY_CLASS

    public static final java.lang.Class INTEGER_OBJECT_ARRAY_CLASS

### LONG_OBJECT_ARRAY_CLASS

    public static final java.lang.Class LONG_OBJECT_ARRAY_CLASS

### FLOAT_OBJECT_ARRAY_CLASS

    public static final java.lang.Class FLOAT_OBJECT_ARRAY_CLASS

### DOUBLE_OBJECT_ARRAY_CLASS

    public static final java.lang.Class DOUBLE_OBJECT_ARRAY_CLASS

### STRING_OBJECT_ARRAY_CLASS

    public static final java.lang.Class STRING_OBJECT_ARRAY_CLASS

### COMMON_TYPES

    public static final java.util.Map COMMON_TYPES

Method Detail

### classForName

    public static java.lang.Class classForName(java.lang.String type)
                                        throws java.lang.ClassNotFoundException

  Tries a Class.forName 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:
    `java.lang.NullPointerException` - if type is null
    `java.lang.ClassNotFoundException`

### simpleClassForName

    public static java.lang.Class simpleClassForName(java.lang.String type)

  Same as `classForName(String)`, but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.

  Returns:
    the corresponding Class
  Throws:
    `java.lang.NullPointerException` - if type is null
    `javax.faces.FacesException` - if class not found

### javaTypeToClass

    public static java.lang.Class javaTypeToClass(java.lang.String type)
                                           throws java.lang.ClassNotFoundException

  Similar as `classForName(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:
    `java.lang.NullPointerException` - if type is null
    `java.lang.ClassNotFoundException`

### simpleJavaTypeToClass

    public static java.lang.Class simpleJavaTypeToClass(java.lang.String type)

  Same as `javaTypeToClass(String)`, but throws a RuntimeException (FacesException) instead of a ClassNotFoundException.

  Returns:
    the corresponding Class
  Throws:
    `java.lang.NullPointerException` - if type is null
    `javax.faces.FacesException` - if class not found

### getResourceAsStream

    public static java.io.InputStream getResourceAsStream(java.lang.String resource)

### getResources

    public static java.util.Iterator getResources(java.lang.String resource,
                                                  java.lang.Object defaultObject)

  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

    public static java.lang.Object newInstance(java.lang.String type)
                                        throws javax.faces.FacesException

  Throws:
    `javax.faces.FacesException`

### newInstance

    public static java.lang.Object newInstance(java.lang.Class clazz)
                                        throws javax.faces.FacesException

  Throws:
    `javax.faces.FacesException`

### convertToType

    public static java.lang.Object convertToType(java.lang.Object value,
                                                 java.lang.Class desiredClass)

### getCurrentLoader

    protected static java.lang.ClassLoader getCurrentLoader(java.lang.Object defaultObject)

  Gets 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