com.sun.xml.bind.v2
Class ClassFactory

java.lang.Object
  extended by com.sun.xml.bind.v2.ClassFactory

public final class ClassFactory
extends java.lang.Object

Creates new instances of classes.

This code handles the case where the class is not public or the constructor is not public.

Since:
2.0

Field Summary
static java.lang.Class[] COLLECTION_IMPL_CLASSES
           
 
Constructor Summary
ClassFactory()
           
 
Method Summary
static
<T> T
create(java.lang.Class<T> clazz)
          The same as create0(java.lang.Class) but with an error handling to make the instanciation error fatal.
static
<T> T
create0(java.lang.Class<T> clazz)
          Creates a new instance of the class but throw exceptions without catching it.
static
<T> java.lang.Class<? extends T>
inferImplClass(java.lang.Class<T> fieldType, java.lang.Class[] knownImplClasses)
          Infers the instanciable implementation class that can be assigned to the given field type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLLECTION_IMPL_CLASSES

public static final java.lang.Class[] COLLECTION_IMPL_CLASSES
Constructor Detail

ClassFactory

public ClassFactory()
Method Detail

create0

public static <T> T create0(java.lang.Class<T> clazz)
                 throws java.lang.IllegalAccessException,
                        java.lang.reflect.InvocationTargetException,
                        java.lang.InstantiationException
Creates a new instance of the class but throw exceptions without catching it.

Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException

create

public static <T> T create(java.lang.Class<T> clazz)
The same as create0(java.lang.Class) but with an error handling to make the instanciation error fatal.


inferImplClass

public static <T> java.lang.Class<? extends T> inferImplClass(java.lang.Class<T> fieldType,
                                                              java.lang.Class[] knownImplClasses)
Infers the instanciable implementation class that can be assigned to the given field type.

Returns:
null if inference fails.