Dollar: Accessing Java classes, methods and field

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

The $ methods allow one to invoke Java methods in the form jobj$methodName(arg1,arg2,....) The [[ methods allow access to class fields as jobj[["fieldName"]] jobj[["fieldName"]] <- value

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'OmegahatReference'
obj$name
## S3 method for class 'OmegahatReference'
x[[name, ...]]
## S3 replacement method for class 'OmegahatReference'
x[[name, ...]] <- value
## S3 method for class 'OmegahatReference'
print(x, ...)

Arguments

obj

A reference to the Java object.

x

A reference to the Java object.

name

The name of the Java method or field being accessed.

value

The value to be assigned to the field.

...

Additional arguments; ignored for print.

Details

The $ method is equivalent to .Java(obj, name,)

The [[ method is equivalent to .Java(NULL, "getField", name, x).

The [[<- method is equivalent to .Java(NULL, "setField", name, x, value).

Value

The return value of $ is a function which remembers the arguments to this function call and, when called, results in a call to .Java using those arguments.

The return value of [[ is the field value.

print is called for its side effect, i.e., providing a compact represntation of the object.

Author(s)

Duncan Temple Lang

References

http://www.omegahat.org/RSJava

See Also

.Java

Examples

1
2
 p <- .Java("System", "getProperties", .convert=FALSE)
 p$getProperty("java.class.path")

SJava documentation built on Oct. 5, 2016, 4:17 a.m.

Related to Dollar in SJava...