interfaceGenerator: Generates a template "closure" to represent a Java interface/class.
Description
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.
Usage
interfaceGenerator(name, file="")
Arguments
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.
Value
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.
Details
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.