org.marketcetera.util.misc
Class ReflectUtils

java.lang.Object
  extended by org.marketcetera.util.misc.ReflectUtils

public final class ReflectUtils
extends Object

Utilities for reflection.

Since:
0.6.0
Version:
$Id: ReflectUtils.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Method Summary
static Class<?>[] getAllClasses(Class<?> c)
          Returns all superclasses and interfaces of the given class, incl.
static Field[] getAllFields(Class<?> c)
          Returns all fields of the given class, incl.
static Object getInstance(String cName, Class<?>[] paramTypes, Object[] paramValues)
          Returns an instance of the class by the given name, using its constructor with the given parameter types, and invoked using the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAllClasses

public static Class<?>[] getAllClasses(Class<?> c)
Returns all superclasses and interfaces of the given class, incl. the class itself.

Parameters:
c - The class.
Returns:
The classes and interfaces.

getAllFields

public static Field[] getAllFields(Class<?> c)
Returns all fields of the given class, incl. those in the class itself, its superclasses and interfaces.

Parameters:
c - The class.
Returns:
The fields.

getInstance

public static Object getInstance(String cName,
                                 Class<?>[] paramTypes,
                                 Object[] paramValues)
                          throws ClassNotFoundException,
                                 IllegalAccessException,
                                 InstantiationException,
                                 NoSuchMethodException,
                                 InvocationTargetException
Returns an instance of the class by the given name, using its constructor with the given parameter types, and invoked using the given parameters. It interrupts the current thread if the constructor throws an interruption exception per ExceptUtils.isInterruptException(Throwable).

Parameters:
cName - The class name.
paramTypes - The constructor parameter types.
paramValues - The constructor parameters.
Returns:
The instance.
Throws:
ClassNotFoundException - Thrown if a reflection failure occurs.
IllegalAccessException - Thrown if a reflection failure occurs.
InstantiationException - Thrown if a reflection failure occurs.
NoSuchMethodException - Thrown if a reflection failure occurs.
InvocationTargetException - Thrown if a reflection failure occurs.


Copyright © 2012. All Rights Reserved.