org.omegahat.R.Java
Class REvaluator

java.lang.Object
  |
  +--org.omegahat.Interfaces.NativeInterface.ForeignReference
        |
        +--org.omegahat.R.Java.RForeignReference
              |
              +--org.omegahat.R.Java.REvaluator
All Implemented Interfaces:
ForeignReferenceInt

public class REvaluator
extends RForeignReference

Provides facilities for evaluating R expression and calling R functions from within Java. This acts as a front end to the R interpeter or evaluator. One can evaluate R commands given as strings or, more flexibly, invoke R functions passing them Java objects as arguments. In the future, there will be multiple, separate R evaluators and different instances of this Java class will correspond to different R interpreters.


Fields inherited from class org.omegahat.Interfaces.NativeInterface.ForeignReference
evaluator, name
 
Constructor Summary
REvaluator()
          Default constructor, simply creating an unamed reference to itself.
 
Method Summary
 java.lang.Object call(java.lang.String name)
          Call an S function with no arguments.
 java.lang.Object call(java.lang.String name, java.util.Hashtable namedArgs)
          Call an S function with only named arguments, where the name-value pairs come from the given Hashtable.
 java.lang.Object call(java.lang.String name, java.lang.Object[] args)
          Call an S function with the arguments given in the array of values.
 java.lang.Object call(java.lang.String name, java.lang.Object[] args, java.util.Hashtable namedArgs)
           
 java.lang.Object call(java.lang.String name, java.lang.Object[] args, java.lang.String[] argNames)
          Call the named S function with the specified argument values and the names of the arguments specified argName, which can contain null values for un-named arguments.
 java.lang.Object call(java.lang.String name, java.lang.Object[] args, java.lang.String[] argNames, java.lang.Class toClass)
          Call the named S function with the specified argument values and the names of the arguments specified argName, which can contain null values for un-named arguments and specifying the class to which the return value should be converted.
protected  java.lang.Object call(java.lang.String name, java.lang.Object[] args, java.lang.String[] argNames, java.lang.Class toClass, boolean convert)
          The native method that actually performs the call to the S function given the arguments and their names and the target class for the result.
 java.lang.Object call(java.lang.String name, org.omegahat.Environment.Utils.OrderedTable args)
          Unimplemented!
protected  java.lang.Object[] createArgs(java.util.Hashtable namedArgs, java.lang.String[] names)
           
protected  java.lang.Object[] createArgs(java.util.Hashtable namedArgs, java.lang.String[] names, java.lang.Object[] args, int offset)
           
 java.lang.Object eval(java.lang.String cmd)
          Evaluate the specified S command, given as a string and return the result, having converted it from S to Java.
 java.lang.Object eval(java.lang.String cmd, boolean convert)
          Evaluate the specified S command and control whether the result in S is converted to Java or returned as a reference in Java to that S object.
 java.lang.Object eval(java.lang.String cmd, boolean convert, java.lang.Class returnClass, boolean discardResult)
          A native C method that evaluates an S command given as a string which is used to bridge the interface between Java and S.
 java.lang.Object eval(java.lang.String cmd, java.lang.Class returnClass)
          Evaluate the specified S command, identifying the type of the return value expected.
 java.lang.Object eval(java.lang.String cmd, java.lang.Class returnClass, boolean convert)
          The complete method for evaluating an S command given as a string, allowing control of whether the result is converted to Java or returned as a reference, and also supporting the specification of a return type from the evaluation which controls to what Java type the result is converted.
 java.lang.Object voidEval(java.lang.String cmd)
          Evaluate the specified S command and discard the result, avoiding the conversion to Java.
 
Methods inherited from class org.omegahat.R.Java.RForeignReference
localEval, reval
 
Methods inherited from class org.omegahat.Interfaces.NativeInterface.ForeignReference
convertResult, eval, getEvaluator, getReferenceName, processArg, processArgs, removeTemporaryAnonymousReferences, setEvaluator, setReferenceName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

REvaluator

public REvaluator()
Default constructor, simply creating an unamed reference to itself.
Method Detail

eval

public java.lang.Object eval(java.lang.String cmd)
Evaluate the specified S command, given as a string and return the result, having converted it from S to Java.

voidEval

public java.lang.Object voidEval(java.lang.String cmd)
Evaluate the specified S command and discard the result, avoiding the conversion to Java.

eval

public java.lang.Object eval(java.lang.String cmd,
                             java.lang.Class returnClass)
Evaluate the specified S command, identifying the type of the return value expected.

eval

public java.lang.Object eval(java.lang.String cmd,
                             boolean convert)
Evaluate the specified S command and control whether the result in S is converted to Java or returned as a reference in Java to that S object.
Parameters:
convert - if true, the S value is converted using any registered converters. Alternatively, if it is false, the S value is stored in S and a Java reference to it is returned from this call. That reference is typically an object of class RForeignReference or some derived class and can be used in subsequent computations with some or all of its methods accessing the associated S object.

eval

public java.lang.Object eval(java.lang.String cmd,
                             java.lang.Class returnClass,
                             boolean convert)
The complete method for evaluating an S command given as a string, allowing control of whether the result is converted to Java or returned as a reference, and also supporting the specification of a return type from the evaluation which controls to what Java type the result is converted.

eval

public java.lang.Object eval(java.lang.String cmd,
                             boolean convert,
                             java.lang.Class returnClass,
                             boolean discardResult)
A native C method that evaluates an S command given as a string which is used to bridge the interface between Java and S.

call

public java.lang.Object call(java.lang.String name)
Call an S function with no arguments.
Parameters:
name - the name of the S function to call. This is found by looking for it in the top-level R search path.

call

public java.lang.Object call(java.lang.String name,
                             java.lang.Object[] args)
Call an S function with the arguments given in the array of values.
Parameters:
name - the name of the S function to call, found in the typical fashion in the R search path.
args - an array of Java objects which are to be converted to S objects and passed as arguments to the S function.

call

public java.lang.Object call(java.lang.String name,
                             java.lang.Object[] args,
                             java.lang.String[] argNames)
Call the named S function with the specified argument values and the names of the arguments specified argName, which can contain null values for un-named arguments.

call

public java.lang.Object call(java.lang.String name,
                             java.lang.Object[] args,
                             java.lang.String[] argNames,
                             java.lang.Class toClass)
Call the named S function with the specified argument values and the names of the arguments specified argName, which can contain null values for un-named arguments and specifying the class to which the return value should be converted.

call

protected java.lang.Object call(java.lang.String name,
                                java.lang.Object[] args,
                                java.lang.String[] argNames,
                                java.lang.Class toClass,
                                boolean convert)
The native method that actually performs the call to the S function given the arguments and their names and the target class for the result.
Parameters:
convert - a logical value indicating whether we should attempt to convert the result to a Java object or simply leave it as a foreign reference.

call

public java.lang.Object call(java.lang.String name,
                             java.lang.Object[] args,
                             java.util.Hashtable namedArgs)

call

public java.lang.Object call(java.lang.String name,
                             java.util.Hashtable namedArgs)
Call an S function with only named arguments, where the name-value pairs come from the given Hashtable.

call

public java.lang.Object call(java.lang.String name,
                             org.omegahat.Environment.Utils.OrderedTable args)
Unimplemented!

createArgs

protected java.lang.Object[] createArgs(java.util.Hashtable namedArgs,
                                        java.lang.String[] names)

createArgs

protected java.lang.Object[] createArgs(java.util.Hashtable namedArgs,
                                        java.lang.String[] names,
                                        java.lang.Object[] args,
                                        int offset)