Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.simscomputing.testbed
Class ClearBox  view ClearBox download ClearBox.java

java.lang.Object
  extended bycom.simscomputing.testbed.ClearBox

public class ClearBox
extends java.lang.Object

Provides access to private and protected constructors, methods, and fields in arbitrary classes. Inspired by a similar class written by Creig Smith .

Version:
$Revision: 1.1.1.1 $ $Date: 2000/02/21 21:22:33 $

Constructor Summary
private ClearBox()
          This class is just a collection of static methods.
 
Method Summary
static java.lang.Object createNewInstance(java.lang.String className, java.lang.Class[] constructorParameterTypes, java.lang.Object[] constructorParameters)
          Instantiates an object with a private or protected constructor.
private static java.lang.reflect.Field findField(java.lang.Class c, java.lang.String fieldName)
          Helper method for recursively finding private and protected fields.
private static java.lang.reflect.Method findMethod(java.lang.Class c, java.lang.String methodName, java.lang.Class[] methodParameterTypes)
          Helper method for recursively finding private, protected, and public methods.
static java.lang.Object getField(java.lang.Object object, java.lang.String fieldName)
          Finds a private, protected, or public field in the specified object.
static java.lang.Class getFieldClass(java.lang.Object object, java.lang.String fieldName)
          Finds the class for a private, protected, or public field in the specified object.
static java.lang.reflect.Method getMethod(java.lang.Object object, java.lang.String methodName, java.lang.Class[] methodParameterTypes)
          Finds a private, protected, or public method in the specified object.
static void setField(java.lang.Object object, java.lang.String fieldName, java.lang.Object newValue)
          Sets a private, protected, or public field in the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClearBox

private ClearBox()
This class is just a collection of static methods. No need to instantiate it.

Method Detail

findField

private static java.lang.reflect.Field findField(java.lang.Class c,
                                                 java.lang.String fieldName)
                                          throws java.lang.NoSuchFieldException
Helper method for recursively finding private and protected fields.


getField

public static java.lang.Object getField(java.lang.Object object,
                                        java.lang.String fieldName)
                                 throws java.lang.NoSuchFieldException
Finds a private, protected, or public field in the specified object.


getFieldClass

public static java.lang.Class getFieldClass(java.lang.Object object,
                                            java.lang.String fieldName)
                                     throws java.lang.NoSuchFieldException
Finds the class for a private, protected, or public field in the specified object.


setField

public static void setField(java.lang.Object object,
                            java.lang.String fieldName,
                            java.lang.Object newValue)
                     throws java.lang.NoSuchFieldException
Sets a private, protected, or public field in the specified object.


createNewInstance

public static java.lang.Object createNewInstance(java.lang.String className,
                                                 java.lang.Class[] constructorParameterTypes,
                                                 java.lang.Object[] constructorParameters)
                                          throws java.lang.ClassNotFoundException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.SecurityException,
                                                 java.lang.InstantiationException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.IllegalAccessException
Instantiates an object with a private or protected constructor.


findMethod

private static java.lang.reflect.Method findMethod(java.lang.Class c,
                                                   java.lang.String methodName,
                                                   java.lang.Class[] methodParameterTypes)
                                            throws java.lang.NoSuchMethodException
Helper method for recursively finding private, protected, and public methods.


getMethod

public static java.lang.reflect.Method getMethod(java.lang.Object object,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] methodParameterTypes)
                                          throws java.lang.ClassNotFoundException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.SecurityException,
                                                 java.lang.InstantiationException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.IllegalAccessException
Finds a private, protected, or public method in the specified object.