Description Usage Arguments Details Value Author(s) References See Also Examples
To use an R variable as a Java object, one can create a closure or list of functions that implement the methods of that Java class. The template of such a closure can be generated automatically using the reflectance capabilities of both Java and R. This function generates such a template and can be used as an initial step in implementing an R version of a Java class.
1 | interfaceGenerator(name, file="")
|
name |
the name of the Java class or interface whose methods are to be duplicated locally via R functions. This is resolved using the usual Omegahat rules so this can be a partially qualified class name. |
file |
The name of a file to which the template functions are written. This can then be edited to provide an implementation of the Java class via an R object. |
This is useful for allowing an R object to be converted to a proxy
Java object. For example, consider using an R object as a callback
for a Swing button. The object must implement the
actionPerformed()
method of the ActionListener
. This
function calls the Omegahat evaluator's getMethods()
method to
retrieve a list of Java method descriptions and then converts
them to an R closure definition.
This function has the side-effect of writing the definition of a function closure definition to standard output (the console) or to a file. In the future, we will generate the actual function objects. The idea is merely to show the possibilities available to us using reflectance.
Duncan Temple Lang
http://www.omegahat.org/RSJava
1 2 | interfaceGenerator("java.awt.event.ActionListener")
interfaceGenerator("java.awt.event.ActionListener", "MyFile")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.