org.codehaus.jackson.map.util
Class ClassUtil

java.lang.Object
  extended by org.codehaus.jackson.map.util.ClassUtil

public final class ClassUtil
extends Object


Constructor Summary
ClassUtil()
           
 
Method Summary
static String canBeABeanType(Class<?> type)
           
static void checkAndFixAccess(Member member)
          Method called to check if we can use the passed method or constructor (wrt access restriction -- public methods can be called, others usually not); and if not, if there is a work-around for the problem.
static
<T> T
createInstance(Class<T> cls, boolean canFixAccess)
          Method that can be called to try to create an instantiate of specified type.
static List<Class<?>> findSuperTypes(Class<?> cls, Class<?> endBefore)
          Method that will find all sub-classes and implemented interfaces of a given class or interface.
static Throwable getRootCause(Throwable t)
          Method that can be used to find the "root cause", innermost of chained (wrapped) exceptions.
static boolean hasGetterSignature(Method m)
           
static boolean isConcrete(Class<?> type)
          Helper method that checks if given class is a concrete one; that is, not an interface or abstract class.
static String isLocalType(Class<?> type)
           
static boolean isProxyType(Class<?> type)
          Helper method used to weed out dynamic Proxy types; types that do not expose concrete method API that we could use to figure out automatic Bean (property) based serialization.
static void throwAsIAE(Throwable t)
           
static void throwAsIAE(Throwable t, String msg)
           
static void unwrapAndThrowAsIAE(Throwable t)
           
static void unwrapAndThrowAsIAE(Throwable t, String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

findSuperTypes

public static List<Class<?>> findSuperTypes(Class<?> cls,
                                            Class<?> endBefore)
Method that will find all sub-classes and implemented interfaces of a given class or interface. Classes are listed in order of precedence, starting with the immediate super-class, followed by interfaces class directly declares to implemented, and then recursively followed by parent of super-class and so forth. Note that Object.class is not included in the list regardless of whether endBefore argument is defined

Parameters:
endBefore - Super-type to NOT include in results, if any; when encountered, will be ignored (and no super types are checked).

canBeABeanType

public static String canBeABeanType(Class<?> type)
Returns:
Null if class might be a bean; type String (that identifies why it's not a bean) if not

isLocalType

public static String isLocalType(Class<?> type)

isProxyType

public static boolean isProxyType(Class<?> type)
Helper method used to weed out dynamic Proxy types; types that do not expose concrete method API that we could use to figure out automatic Bean (property) based serialization.


isConcrete

public static boolean isConcrete(Class<?> type)
Helper method that checks if given class is a concrete one; that is, not an interface or abstract class.


hasGetterSignature

public static boolean hasGetterSignature(Method m)

getRootCause

public static Throwable getRootCause(Throwable t)
Method that can be used to find the "root cause", innermost of chained (wrapped) exceptions.


throwAsIAE

public static void throwAsIAE(Throwable t)

throwAsIAE

public static void throwAsIAE(Throwable t,
                              String msg)

unwrapAndThrowAsIAE

public static void unwrapAndThrowAsIAE(Throwable t)

unwrapAndThrowAsIAE

public static void unwrapAndThrowAsIAE(Throwable t,
                                       String msg)

createInstance

public static <T> T createInstance(Class<T> cls,
                                   boolean canFixAccess)
                        throws IllegalArgumentException
Method that can be called to try to create an instantiate of specified type. Instantiation is done using default no-argument constructor.

Parameters:
canFixAccess - Whether it is possible to try to change access rights of the default constructor (in case it is not publicly accessible) or not.
Throws:
IllegalArgumentException - If instantiation fails for any reason; except for cases where constructor throws an unchecked exception (which will be passed as is)

checkAndFixAccess

public static void checkAndFixAccess(Member member)
Method called to check if we can use the passed method or constructor (wrt access restriction -- public methods can be called, others usually not); and if not, if there is a work-around for the problem.