com.aliasi.util
Class Reflection

java.lang.Object
  extended by com.aliasi.util.Reflection

public class Reflection
extends Object

Utility classes for handling reflection.

Since:
LingPipe1.0
Version:
3.1
Author:
Bob Carpenter

Method Summary
static Object newInstance(String className)
          Construct a new instance of the class of the specified name with the no-argument constructor.
static Object newInstance(String className, Object[] args)
          Construct a new instance of the class of the specified name with the specified arguments.
static Object newInstance(String className, Object[] args, Class[] argClasses)
          Construct a new instance of the class of the specified name with the specified arguments and argument classes.
static Object newInstance(String className, Object[] args, String[] argClassNames)
          Construct a new instance of the class of the specified name with the specified arguments and argument class names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static Object newInstance(String className)
Construct a new instance of the class of the specified name with the no-argument constructor.

Parameters:
className - Name of class of which to construct an instance.
Throws:
IllegalArgumentException - If there are errors in construction.

newInstance

public static Object newInstance(String className,
                                 Object[] args)
Construct a new instance of the class of the specified name with the specified arguments.

All exceptions arising from reflection are converted to illegal argument exceptions as detailed in the method documentation to newInstance(String,Object[],String[]).

Parameters:
className - Name of class of which to construct an instance.
args - Arguments to supply to constructor.
Throws:
IllegalArgumentException - If there are errors in construction.

newInstance

public static Object newInstance(String className,
                                 Object[] args,
                                 String[] argClassNames)
Construct a new instance of the class of the specified name with the specified arguments and argument class names.

This method converts all exceptions thrown by Class.forName(String) in converting the class names to classes to illegal argument exceptions. All other exceptions documented to be thrown by reflection construction are converted by newInstance(String,Object[],Class[]).

Parameters:
className - Name of class of which to construct an instance.
args - Arguments to supply to constructor.
argClassNames - Classes of argument determining constructor.
Throws:
IllegalArgumentException - If there are errors in construction.

newInstance

public static Object newInstance(String className,
                                 Object[] args,
                                 Class[] argClasses)
Construct a new instance of the class of the specified name with the specified arguments and argument classes.

All exceptions thrown by reflection are converted to illegal argument exceptions; this includes exceptions thrown by Class.forName(String) in getting the constructor's class, by Class.getConstructor(Class[]) in getting the constructor itself, and by Constructor.newInstance(Object[]) in creating the instance.

Parameters:
className - Name of class of which to construct an instance.
args - Arguments to supply to constructor.
argClasses - Classes of argument determining constructor.
Throws:
IllegalArgumentException - If there are errors in construction.