pnuts.ext
Class PublicMemberAccessor

java.lang.Object
  extended by pnuts.lang.Configuration
      extended by pnuts.ext.ConfigurationAdapter
          extended by pnuts.ext.PublicMemberAccessor
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NonPublicMemberAccessor

public class PublicMemberAccessor
extends ConfigurationAdapter

when -p option is given to the pnuts command, this class is used so that public members can be accessed.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class pnuts.ext.ConfigurationAdapter
base
 
Fields inherited from class pnuts.lang.Configuration
_add, _add1, _and, _divide, _eq, _ge, _gt, _le, _lt, _mod, _multiply, _negate, _not, _or, _shiftArithmetic, _shiftLeft, _shiftRight, _subtract, _subtract1, _xor, normalConfiguration
 
Constructor Summary
PublicMemberAccessor()
           
PublicMemberAccessor(Configuration conf)
           
 
Method Summary
 java.lang.reflect.Constructor[] getConstructors(java.lang.Class cls)
          Get all public constructors of the specified class.
protected  java.lang.reflect.Field getField(java.lang.Class cls, java.lang.String name)
           
 java.lang.Object getField(Context context, java.lang.Object target, java.lang.String name)
          Gets a field value of the target object.
 java.lang.reflect.Method[] getMethods(java.lang.Class cls)
          Get all public methods of the specified class.
protected  java.lang.Object getObjectField(Context context, java.lang.Object target, java.lang.String name)
           
 java.lang.Object getStaticField(Context context, java.lang.Class clazz, java.lang.String name)
          Get the value of a static field.
 void putField(Context context, java.lang.Object target, java.lang.String name, java.lang.Object expr)
          Sets a field value of the specified object.
protected  void putObjectField(Context context, java.lang.Object target, java.lang.String name, java.lang.Object value)
           
 void putStaticField(Context context, java.lang.Class clazz, java.lang.String name, java.lang.Object value)
          Sets a field of the specified class.
 
Methods inherited from class pnuts.ext.ConfigurationAdapter
callConstructor, callMethod, createMap, formatObject, getElement, getParent, getRange, handleUndefinedSymbol, makeArray, setElement, setRange, toCallable, toEnumeration
 
Methods inherited from class pnuts.lang.Configuration
createList, getDefault, getDefaultImports, getInitialClassLoader, initializeOperators, invokeMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PublicMemberAccessor

public PublicMemberAccessor()

PublicMemberAccessor

public PublicMemberAccessor(Configuration conf)
Method Detail

getField

public java.lang.Object getField(Context context,
                                 java.lang.Object target,
                                 java.lang.String name)
Gets a field value of the target object.

Overrides:
getField in class ConfigurationAdapter
Parameters:
context - the context in which the field is read
target - the target object
name - the field name
Returns:
the field value

putField

public void putField(Context context,
                     java.lang.Object target,
                     java.lang.String name,
                     java.lang.Object expr)
Sets a field value of the specified object.

Overrides:
putField in class ConfigurationAdapter
Parameters:
context - the context in which the field is written.
target - the target object
name - the field name
expr - the field value

getObjectField

protected java.lang.Object getObjectField(Context context,
                                          java.lang.Object target,
                                          java.lang.String name)

putObjectField

protected void putObjectField(Context context,
                              java.lang.Object target,
                              java.lang.String name,
                              java.lang.Object value)

getStaticField

public java.lang.Object getStaticField(Context context,
                                       java.lang.Class clazz,
                                       java.lang.String name)
Description copied from class: ConfigurationAdapter
Get the value of a static field.

Overrides:
getStaticField in class ConfigurationAdapter
Parameters:
context - the context in which the field is accessed
clazz - the class in which the static field is defined
name - the name of the static field
Returns:
the value

putStaticField

public void putStaticField(Context context,
                           java.lang.Class clazz,
                           java.lang.String name,
                           java.lang.Object value)
Description copied from class: ConfigurationAdapter
Sets a field of the specified class.

Overrides:
putStaticField in class ConfigurationAdapter
Parameters:
context - the context in which the field is written.
clazz - the class in which the static field is defined
name - the field name
value - the field value

getMethods

public java.lang.reflect.Method[] getMethods(java.lang.Class cls)
Description copied from class: ConfigurationAdapter
Get all public methods of the specified class.

Overrides:
getMethods in class ConfigurationAdapter
Parameters:
cls - the class
Returns:
an array of Method objects

getConstructors

public java.lang.reflect.Constructor[] getConstructors(java.lang.Class cls)
Description copied from class: ConfigurationAdapter
Get all public constructors of the specified class.

Overrides:
getConstructors in class ConfigurationAdapter
Parameters:
cls - the class
Returns:
an array of Constructor objects

getField

protected java.lang.reflect.Field getField(java.lang.Class cls,
                                           java.lang.String name)
                                    throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException