Class PrivateAccessor

java.lang.Object
  extended by PrivateAccessor

public class PrivateAccessor
extends Object

Provides access to private members in classes.

Copyright (c) 2005 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
License: http://www.gnu.org/copyleft/lesser.html LGPL

Version:
1.0.003 [2005-12-11]
Author:
Nicola Asuni [www.tecnick.com].

Constructor Summary
PrivateAccessor()
           
 
Method Summary
static Object getPrivateField(Object obj, String fieldName)
          Returns the value of the field named "fieldName", on the specified object.
static void setPrivateField(Object obj, String fieldName, Object value)
          Sets the field named "fieldName" on the specified object argument to the specified new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrivateAccessor

public PrivateAccessor()
Method Detail

getPrivateField

public static Object getPrivateField(Object obj,
                                     String fieldName)
Returns the value of the field named "fieldName", on the specified object. The value is automatically wrapped in an object if it has a primitive type.

Parameters:
obj - object from which the represented field's value is to be extracted
fieldName - name of the field contained on obj object
Returns:
the value of the represented field in object obj; primitive values are wrapped in an appropriate object before being returned

setPrivateField

public static void setPrivateField(Object obj,
                                   String fieldName,
                                   Object value)
Sets the field named "fieldName" on the specified object argument to the specified new value. The new value is automatically unwrapped if the underlying field has a primitive type.

Parameters:
obj - the object whose field should be modified
fieldName - name of the field contained on obj object
value - the new value for the field of obj being modified