.JavaArray
Java Arrays

Description

Creates or accesses Java arrays.

Usage

.JavaArray(javaClass, length)
.JavaArrayLength(x)
.JavaArrayGet(x, index, SIMPLIFY=TRUE)
.JavaArraySet(x, index, value)

Arguments

javaClass a string specifying a full Java class name of an array class, such as "[I" or "[Ljava/lang/String;".
length an integer giving the length of the array to create.
x a Java object reference pointing to a Java array.
index an integer specifying the index within the array. The first element has the index one, not zero.
value an object set as the array element value. This can be a Java object reference or any object that can be converted to one.
SIMPLIFY A logical. If TRUE (the default), specifies that .JavaArrayGet 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
.JavaArrayreturns a Java object reference to a new Java array with the specified class and length.
.JavaArrayLengthreturns the length of a Java array.
.JavaArrayGetreturns a Java object reference to the retrieved array element value, or a simpler data value (if this is possible, and the SIMPLIFY argument is TRUE).
.JavaArraySetreturns NULL.
See Also
.JavaCall, .JavaClass, .JavaRef, .JavaSimplify
Examples
## create an array of 3 integers
xx <- .JavaArray("[I", 3)

## all values are originally zero .JavaArrayGet(xx,1) ## [1] 0

## set value in array .JavaArraySet(xx, 2, 99L)

## simplify to [1] 0 99 0 .JavaSimplify(xx)

Package terrJava version 6.0.0-69
Package Index