.jcastToArray takes a Java object reference of any kind and
returns Java array reference if the given object is a reference to an
Java object reference to cast or a scalar vector
array signature in JNI notation (e.g.
force the result to pose as a particular Java
class. This has the same effect as using
if set to
Sometimes a result of a method is by definition of the class
java.lang.Object, but the acutal referenced object may be an
array. In that case the method returns a Java object reference instead
of an array reference. In order to obtain an array reference, it is
necessary to cast such an object to an array reference - this is done
using the above
The input is an object reference that points to an array. Ususally the
signature should be left at
NULL such that it is determined
from the object's class. This is also a check, because if the object's
class is not an array, then the functions fails either with an error
quiet=FALSE) or by returing the original object (when
quiet=TRUE). If the signature is set to anything else, it is
not verified and the array reference is always created, even if it may
be invalid and unusable.
.jcastToArray also accepts non-references in
which case it simply calls
.jarray, ignoring all other
Returns a Java array reference (
jarrayRef) on success. If
TRUE then the result can also be the original
object in the case of failure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
## Not run: a <- .jarray(1:10) print(a) # let's create an array containing the array aa <- .jarray(list(a)) print(aa) ba <- .jevalArray(aa)[] # it is NOT the inverse, because .jarray works on a list of objects print(ba) # so we need to cast the object into an array b <- .jcastToArray(ba) # only now a and b are the same array reference print(b) # for convenience .jcastToArray behaves like .jarray for non-references print(.jcastToArray(1:10/2)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.