public class Reflection
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object[] |
emptyParams
Constant for specifying absence of parameters in newInstance() and invoke()
|
static java.lang.String[] |
emptyParamTypes
Constant for specifying absence of parameters in getConstructor() and getMethod()
|
| Constructor and Description |
|---|
Reflection() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?> |
getClass(java.lang.String name)
Returns the Class for a given name, including arrays and primitives
|
static java.lang.reflect.Constructor<? extends java.lang.Object> |
getConstructor(java.lang.String className,
java.lang.String... paramTypes)
Returns the Constructor for a specified Class and parameter signature
|
static java.lang.reflect.Constructor<? extends java.lang.Object> |
getConstructor(java.lang.String className,
java.lang.String paramType)
Returns the Constructor for a specified Class and parameter signature
|
static java.lang.reflect.Field |
getField(java.lang.String className,
java.lang.String fieldName)
Returns the specified Field of a named Class
|
static java.lang.reflect.Method |
getMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String... paramTypes)
Returns the Method for a specified Class, method name and parameter signature
|
static java.lang.reflect.Method |
getMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String paramType)
Returns the Method for a specified Class, method name and parameter signature
|
public static final java.lang.String[] emptyParamTypes
public static final java.lang.Object[] emptyParams
public static java.lang.Class<?> getClass(java.lang.String name)
throws java.lang.Exception
Primitives are specified by their name (e.g., "char", "double")
Arrays are specified as in declarations (e.g., "java.lang.String[]", "int[]")
name - The name of the class, array, or primitivejava.lang.Exceptionpublic static java.lang.reflect.Field getField(java.lang.String className,
java.lang.String fieldName)
throws java.lang.Exception
className - The name of the class from which to get the FieldfieldName - The name of the Field to returnjava.lang.Exceptionpublic static java.lang.reflect.Constructor<? extends java.lang.Object> getConstructor(java.lang.String className,
java.lang.String... paramTypes)
throws java.lang.Exception
className - The name of the class for which to return the ConstructorparamTypes - An array specifying the parameter type names (as used by getClass())java.lang.Exceptionpublic static java.lang.reflect.Constructor<? extends java.lang.Object> getConstructor(java.lang.String className,
java.lang.String paramType)
throws java.lang.Exception
className - The name of the class for which to return the ConstructorparamType - A single parameter type name (as used by getClass())java.lang.Exceptionpublic static java.lang.reflect.Method getMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String... paramTypes)
throws java.lang.Exception
className - The name of the class for which to return the MethodmethodName - The name of the Method to returnparamTypes - An array specifying the parameter type names (as used by getClass())java.lang.Exceptionpublic static java.lang.reflect.Method getMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String paramType)
throws java.lang.Exception
className - The name of the class for which to return the MethodmethodName - The name of the Method to returnparamType - A single parameter type name (as used by getClass())java.lang.Exception