Learn R Programming

rJava (version 1.0-11)

jsimplify: Converts Java object to a simple scalar if possible

Description

.jsimplify attempts to convert Java objects that represent simple scalars into corresponding scalar representation in R.

Usage

.jsimplify(o, promote=FALSE)

Value

Simple scalar or o unchanged.

Arguments

o

arbitrary object

promote

logical, if TRUE then an ambiguous conversion where the native type value would map to NA (e.g., Java int type with value -2147483648) will be taken to represent an actual value and will be promoted to a larger type that can represent the value (in case of int promoted to double). If FALSE then such values are assumed to represent NAs.

Details

If o is not a Java object reference, o is returned as-is. If o is a reference to a scalar object (such as single integer, number, string or boolean) then the value of that object is returned as R vector of the corresponding type and length one.

This function is used by .jfield to simplify the results of field access if required.

Currently there is no function inverse to this, the usual way to wrap scalar values in Java references is to use .jnew as the corresponding constructor.

See Also

.jfield

Examples

Run this code
if (FALSE) {
i <- .jnew("java/lang/Integer", as.integer(10))
print(i)
print(.jsimplify(i))
}

Run the code above in your browser using DataLab