setJavaConverter {Java}R Documentation

Add a converter from Java to an R object

Description

Register a C routine which converts a Java object to an R object. This occurs when a value is returned from a Java method (or constructor) call via .Java or .JavaConstructor.

Usage

setJavaConverter(handler, matcher=-1, autoArray=T, description=NULL, userObject=NULL)

Arguments

handler The name of a C routine that performs the conversion from the Java object to the R object. This is given the Java object, the class of that object, the JNI environment and the element in the converter object is to be called when the the matcher determines that
matcher The name of a routine that is used to determine whether this converter can handle a specific object. This can also be specified as an element of the vector .javaMatchFunctions, either as (part of) a name of an element or the integer value. These are then used to identify one of the built-in converter matching functions.
autoArray A logical value indicating whether this converter routine can be called element-wise for an array of the class type it matches (TRUE) , or whether it wishes to defer the handling of such an array to another converter or deal with it all in one step.
description A string that describes the action of the converter (e.g. the type of source Java class and target R object on which it operates). This is stored with the internal converter and accessible to users via the getJavaConverterDescriptions.
userObject If the matcher argument identifies one of the built-in matching routines (i.e. assignable from, instance of, equals) this is interpreted as a Java class identifier. That is either a class name (which is resoloved, and expanded as necessary, by Omegahat) and used to parameterize the particular use matching routine.
register a logical value indicating whether this call should also notify Java that the specified class (i.e. that given in userObject is convertible. This calls setJavaConvertible with the class and matching mechanism specified for this function.

Note

In the near future, we will re-establish the mechanism for specifying R functions or closure instances for the handler and matcher. This has become more complicated than intended and will probably be restricted to work only for C routines. All of the cases have not been tested entirely.

Author(s)

Duncan Temple Lang

References

http://www.omegahat.org, http://www.javasoft.com

See Also

getJavaConverterDescriptions getNumJavaConverters setJavaConvertible

Examples

 setJavaConverter(.RSJava.symbol("RealVariableConverter"),
                   matcher="AssignableFrom",
                   autoArray=T, description="Omegahat RealVariable to numeric vector",
                     userObject="RealVariable")