Access a field, either static or in a Java object.
lw-ji
read-java-field full-field-name &optional object => field-value
checked-read-java-field full-field-name &optional object => field-value-or-nil, nil-or-condition
set-java-field full-field-name value &optional object => value
check-java-field full-field-name static-p => result
java-field-class-name-for-setting full-field-name static-p => class-name-or-nil
full-field-name⇩ |
A string. |
object⇩ |
A Java object or nil . |
value⇩ |
A Lisp object that can be converted to a Java value. |
static-p⇩ |
A boolean. |
field-value |
The value of the field. |
field-value-or-nil |
The value of the field or nil . |
nil-or-condition | nil or a cl:error. |
value |
A Lisp object that can be converted to a Java value. |
result⇩ |
A boolean. |
class-name-or-nil |
A string or nil . |
The functions read-java-field
, checked-read-java-field
and set-java-field
access the value of a field in a Java Object or a static field.
The functions check-java-field
and java-field-class-name-for-setting
are used to check whether it is possible to access the value of the field.
full-field-name needs to be a full field name including the package and class, for example "java.io.File.separator"
.
If object is supplied and is non-nil, it must be a Java object from which to read/to which set the value. The field must be non-static in this case. If object is nil
, the field must be static.
read-java-field
returns the value of the field. If it fails to get it, it signals an error. If the class is not found, this is a java-class-error, if the field is not found it is a java-field-error.
checked-read-java-field
returns the value like read-java-field
and another value which is nil
when the read is successful. If the class or the field is not found, checked-read-java-field
returns nil
and a condition specifying the error (java-field-error or java-class-error). Note that it may still signal other errors, for example if full-field-name does not look like a proper field name.
set-java-field
sets the field to value. value must be of an acceptable type (see 15.1 Types and conversion between Lisp and Java) and the field must not be final, otherwise it signals java-field-setting-error.
check-java-field
checks whether the field exists and matches the value of static-p, and returns a boolean result accordingly.
java-field-class-name-for-setting
checks whether the field exists and matches the value of static-p and whether it is not final, and if it is returns the class name of the field. It returns nil
otherwise. java-field-class-name-for-setting
is useful for checking whether set-java-field
can be used on a a field, and whether a value is suitable to be stored in his field, by using jobject-of-class-p.
It is also possible to access fields using accessors defined by define-field-accessor and setup-field-accessor.
java-field-error
java-class-error
java-field-setting-error
define-field-accessor
setup-field-accessor
15 Java interface
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46