com.aliasi.util
Class Reflection

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

Deprecated. Use java.lang.reflect directly instead, as described on the individual methods.

@Deprecated
public class Reflection
extends Object

Utility classes for handling reflection.

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

Method Summary
static Object newInstance(String className)
          Deprecated. Use Class.forName(className).getConstructor(new Class[0]).newInstance(new Object[0]) instead.
static
<T> T
newInstance(String className, Object[] args)
          Deprecated. Convert args to argClasses using args[i].getClass(), then call Class.forName(className).getConstructor(argClasses).newInstace(args) instead.
static
<T> T
newInstance(String className, Object[] args, Class<?>[] argClasses)
          Deprecated. Use Class.forName(className).getConstructor(argClasses).newInstance(args) instead.
static
<T> T
newInstance(String className, Object[] args, String[] argClassNames)
          Deprecated. Convert argClassNames to argClasses classes using Class.forName(argClassNames[i]), then use Class.forName(className).getConstructor(argClasses).newInstace(args) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

@Deprecated
public static Object newInstance(String className)
Deprecated. Use Class.forName(className).getConstructor(new Class[0]).newInstance(new Object[0]) instead.

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

@Deprecated
public static <T> T newInstance(String className,
                                           Object[] args)
Deprecated. Convert args to argClasses using args[i].getClass(), then call Class.forName(className).getConstructor(argClasses).newInstace(args) instead.

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[]).

Type Parameters:
T - type of object constructed
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.
ClassCastException - If the class name is not of the generic type.

newInstance

@Deprecated
public static <T> T newInstance(String className,
                                           Object[] args,
                                           String[] argClassNames)
Deprecated. Convert argClassNames to argClasses classes using Class.forName(argClassNames[i]), then use Class.forName(className).getConstructor(argClasses).newInstace(args) instead.

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[]).

Type Parameters:
T - type of object constructed
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.
ClassCastException - If the class name is not of the generic type.

newInstance

@Deprecated
public static <T> T newInstance(String className,
                                           Object[] args,
                                           Class<?>[] argClasses)
Deprecated. Use Class.forName(className).getConstructor(argClasses).newInstance(args) instead.

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.

Type Parameters:
T - type of object constructed
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.
ClassCastException - If the class name is not of the generic type.