.JavaFieldGet
Access Java Object Fields

Description

Read or write Java object fields.

Usage

.JavaFieldGet(object, field, SIGNATURE=NULL, SIMPLIFY=TRUE)
.JavaFieldSet(object, field, value, SIGNATURE=NULL)

Arguments

object a Java object reference or a string. If it is a string, it should be a Java class name, and these functions read or write a static field on this class.
field A string naming a field within the class.
value an object to be set as the field value. This can be a Java object reference, or any object that can be converted to one.
SIGNATURE A string giving the Java class name of the field. If this is NULL, the appropriate class is found by calling .JavaFindFieldSignature. This must be specified to access non-public fields.
SIMPLIFY A logical. If TRUE (the default), specifies that .JavaFieldGet should should call .JavaSimplify to attempt to convert the return value from a Java object reference to a simpler object, such as converting a Java double array to a double vector.
Value
.JavaFieldGetreturns a Java object reference to the retrieved field value, or a simpler data value (if this is possible, and the SIMPLIFY argument is TRUE).
.JavaFieldSetreturns NULL.
See Also
.JavaCall, .JavaClass, .JavaRef, .JavaArray, .JavaSimplify, .JavaFindFieldSignature
Examples
## read a Java static field returning the value of PI
.JavaFieldGet("java.lang.Math", "PI") ## returns PI as a double

## return Java object ref to PI value .JavaFieldGet("java.lang.Math", "PI", SIMPLIFY=FALSE)

## specify SIGNATURE .JavaFieldGet("java.lang.Math", "PI", SIGNATURE="D")

## gives error, because this field cannot be changed .JavaFieldSet("java.lang.Math", "PI", 3)

Package terrJava version 6.0.0-69
Package Index