jsint
Class JavaField

java.lang.Object
  extended byjsint.Procedure
      extended byjsint.Reflector
          extended byjsint.JavaField
All Implemented Interfaces:
java.lang.Runnable, SchemeProcedure, java.io.Serializable

public class JavaField
extends Reflector

Provides dynamic field access. If the field is static (or a Class is given) we cache the Field. Otherwise, we cache a class-> field map.

Author:
Peter Norvig, Copyright 1998, peter@norvig.com, license subsequently modified by Jscheme project members licensed under zlib licence (see license.txt)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jsint.Reflector
isPrivileged, reflectors
 
Fields inherited from class jsint.Procedure
maxArgs, minArgs, name
 
Constructor Summary
JavaField(java.lang.String name, java.lang.Class c)
           
JavaField(java.lang.String name, java.lang.Class c, boolean isPrivileged)
           
 
Method Summary
 java.lang.Object apply(java.lang.Object[] args)
          Apply the procedure to an argument list, which is represented as a parameter-oriented array.
static java.lang.reflect.Field getField(java.lang.Class c, java.lang.String name, boolean isPrivileged)
          Return the field named name in Class c.
 java.lang.Object getFieldValue(java.lang.Object target, java.lang.reflect.Field f)
           
 java.lang.Object getStaticFieldValue(java.lang.reflect.Field f)
           
 java.lang.reflect.Field getTargetField(java.lang.Object target)
           
 java.lang.Object[] makeArgArray(java.lang.Object[] code, Evaluator eval, LexicalEnvironment lexenv)
          Take the code that represents a call, evaluate arguments in the calling lexical environment and put results into an argument array.
 java.lang.Object[] makeArgArray(Pair args)
          Convert a list of arguments into an array expected by the procedure.
protected  void reset()
          Reset your classpath dependent state.
 java.lang.Object setFieldValue(java.lang.Object target, java.lang.reflect.Field f, java.lang.Object value)
           
 java.lang.Object setStaticFieldValue(java.lang.reflect.Field f, java.lang.Object value)
           
 
Methods inherited from class jsint.Reflector
readResolve, resetAll
 
Methods inherited from class jsint.Procedure
apply, apply, catching, getName, nParms, run, setName, stripExceptionWrapper, synchronize, throwObject, throwRuntimeException, toString, toStringArgs, tryCatch, tryFinally
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaField

public JavaField(java.lang.String name,
                 java.lang.Class c)

JavaField

public JavaField(java.lang.String name,
                 java.lang.Class c,
                 boolean isPrivileged)
Method Detail

getField

public static java.lang.reflect.Field getField(java.lang.Class c,
                                               java.lang.String name,
                                               boolean isPrivileged)
Return the field named name in Class c. Priviledged fields are made accessible if the JVM allows it.

Memoized.


reset

protected void reset()
Description copied from class: Reflector
Reset your classpath dependent state. This method can't be abstract.

Overrides:
reset in class Reflector

makeArgArray

public java.lang.Object[] makeArgArray(java.lang.Object[] code,
                                       Evaluator eval,
                                       LexicalEnvironment lexenv)
Description copied from class: Procedure
Take the code that represents a call, evaluate arguments in the calling lexical environment and put results into an argument array. Note that code[0] is the procedure, not an argument. For example, (p 1 2 3 (+ 2 2)) turns into the code {p, 1, 2, 3, {+, 2, 2}}, and if p has the parameter list (x y . z) then p.makeArgArray(code, lexenv) would return {1, 2, (3 4)}.

Overrides:
makeArgArray in class Procedure

makeArgArray

public java.lang.Object[] makeArgArray(Pair args)
Description copied from class: Procedure
Convert a list of arguments into an array expected by the procedure. (See apply for an explanation of what is expected.)

Overrides:
makeArgArray in class Procedure

apply

public java.lang.Object apply(java.lang.Object[] args)
Description copied from class: Procedure
Apply the procedure to an argument list, which is represented as a parameter-oriented array. That is, if the procedure p has the parameter list (x y . z) and the call is (p 1 2 3 4) then args will be the array {1, 2, (3 4)}.

Specified by:
apply in interface SchemeProcedure
Specified by:
apply in class Procedure

getTargetField

public java.lang.reflect.Field getTargetField(java.lang.Object target)

getFieldValue

public java.lang.Object getFieldValue(java.lang.Object target,
                                      java.lang.reflect.Field f)

setFieldValue

public java.lang.Object setFieldValue(java.lang.Object target,
                                      java.lang.reflect.Field f,
                                      java.lang.Object value)

getStaticFieldValue

public java.lang.Object getStaticFieldValue(java.lang.reflect.Field f)

setStaticFieldValue

public java.lang.Object setStaticFieldValue(java.lang.reflect.Field f,
                                            java.lang.Object value)