Description Usage Arguments Details Value Author(s) References See Also Examples
These functions allow one to create multi-dimensional Java arrays via
R commands using the .Java
function. The get and set
accessors work element-wise and not in the vector fashion common in R
and S. One must create and initialize the Java virtual machine before
calling any of these functions. See .JavaInit
.
1 2 3 4 5 6 7 8 9 10 11 | .JavaArrayConstructor(klass, ..., dim=length(list(...)), .name=NULL,
.convert=FALSE)
.JavaGetArrayElement(jobj,..., .name=NULL, .convert=TRUE)
.JavaSetArrayElement(jobj, value, ..., .dims=list(...), .convert=FALSE)
.JavaArrayLength(jobj)
## S3 method for class 'JavaArrayReference'
x[...]
## S3 replacement method for class 'JavaArrayReference'
x[...] <- value
## S3 method for class 'JavaArrayReference'
length(x)
|
klass |
Typically a string (character vector of length 1)
identifying the name of the class of the element type in the array
to be created. This can also be a foreign reference to a Java class
object obtained via an earlier call to |
... |
In the In the |
dim |
When creating an array in |
.dims |
When setting an array element in
|
jobj, x |
This is the reference to the Java array returned from
an earlier call to |
value |
the object to be inserted as an element in the Java array. This is converted to a Java object using the usual conversion rules and then inserted into the Java array. |
.name |
The name to use to store the result in the omegahat named
reference database. If this is missing, an anonymous reference is
returned or the value converted to an R object. If the result of the
Java method can be converted, this argument can be used to prohibit
this conversion and leave the Java value in Omegahat for use in
future |
.convert |
a logical value that indicates whether the Omegahat
manager should attempt to convert the result of the method
call. This is usually |
This uses the .Java
to call methods in the Omegahat
Evaluator which process the array request.
.JavaArrayConstructor
returns a reference to the newly create
Java array object.
.JavaArrayLength
returns a single integer giving the length of
the top-level dimension of the array.
.JavaGetArrayElement
returns the value of the specified element
of the given array, converted to an R object as usual. Thus it may be
a Java reference.
.JavaSetArrayElement
returns NULL
.
Duncan Temple Lang, John Chambers
http://www.javasoft.com, http://www.omegahat.org
1 2 3 4 5 6 7 8 | if (!isJavaInitialized())
.JavaInit(verbose=TRUE)
a <- .JavaArrayConstructor("java.lang.String", dim=3)
.JavaArrayLength(a)
.JavaSetArrayElement(a, "First", 1)
.JavaSetArrayElement(a, "Second", 2)
.JavaSetArrayElement(a, "Third", 3)
.JavaGetArrayElement(a, 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.