org.omegahat.R.Java
Class ROmegahatInterpreter

java.lang.Object
  |
  +--org.omegahat.Environment.Interpreter.BasicEvaluator
        |
        +--org.omegahat.Environment.Interpreter.UtilityEvaluator
              |
              +--org.omegahat.Environment.Interpreter.UserClassEvaluator
                    |
                    +--org.omegahat.Environment.Interpreter.InteractiveEvaluator
                          |
                          +--org.omegahat.Interfaces.NativeInterface.OmegaInterfaceManager
                                |
                                +--org.omegahat.R.Java.ROmegahatInterpreter
All Implemented Interfaces:
org.omegahat.Environment.Databases.DatabaseCustomer, org.omegahat.Environment.Interpreter.Evaluator, org.omegahat.Environment.IO.InputConsumer, org.omegahat.Environment.Interpreter.ManagedEvaluatorInt, org.omegahat.Environment.IO.PromptSource, java.lang.Runnable, java.io.Serializable

public class ROmegahatInterpreter
extends OmegaInterfaceManager
implements java.lang.Runnable

An Omegahat interpreter that also loads and initializes an embedded R interpreter and that can optionally pass control to it to get the usual R prompt. This is used to bring R into a Java application. One typically invokes this once simply to load and initialize the R session and then create an instance of the REvaluator class to call S functions and evaluate S expressions. This class provides a run() method which causes this Java thread to enter the R internal event loop, effectively running R but from within a Java application. This is especially prudent given the difficulties of matching and loading thread-safe libraries when running Java within R.

See Also:
Serialized Form

Fields inherited from class org.omegahat.Interfaces.NativeInterface.OmegaInterfaceManager
anonymousDatabase, converterFactory, count, db, debug, PublicFlag
 
Fields inherited from class org.omegahat.Environment.Interpreter.InteractiveEvaluator
continuation, continuationPrompt, interrupt, notify_listeners, pendingInput, promptExpression
 
Fields inherited from class org.omegahat.Environment.Interpreter.UserClassEvaluator
classManager
 
Fields inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
allowUnrestrictedAccess, class_lists, currentExpression, data, databases, debugger, DefaultAttachIndex, defaultDatabase, dynamicClassLoader, errorHandler, evaluationEvent, evaluationListeners, initialized, internalFunctionTables, internalPrimitiveClassNames, internalPrimitiveClassTable, lexer, localClasses, manager, options, output, parser, primitive_classes, primitiveClasses, PrimitiveClassNames, primitiveTypeNames, primitiveTypes, reversePrimitiveTypes, ShowMultipleClasses, sourceStack, stderr, stdout, SubEvaluationListeners, taskHistory, toplevelExpression, warningMessages
 
Fields inherited from interface org.omegahat.Environment.Interpreter.Evaluator
ThisVariableName
 
Constructor Summary
ROmegahatInterpreter(java.lang.String[] args)
          Basic constructor for this class which initializes R with the specified command line arguments and runs the R event loop.
ROmegahatInterpreter(java.lang.String[] args, boolean run)
          Constructor that initializes R and optionally runs its event loop.
 
Method Summary
static java.lang.String[] fixArgs(java.lang.String[] args)
          This takes the user's command line arguments and adds the equivalent of argv[0] (the name of the application being invoked) to them so that they can be passed to and correctly understood by the R engine.
 boolean initR(java.lang.String[] args)
          Native method that initializes the R engine and interpreter making it available for evaluating expressions.
static void main(java.lang.String[] args)
          The entry point for using this as a top-level, stand-alone application which simply runs R within Java, but getting the low-level C libraries loaded (more) correctly.
 boolean registerNativeConverters()
          User-level (i.e.
 void run()
          A native method that simply runs the R event loop, currently never returning from this call.
 
Methods inherited from class org.omegahat.Interfaces.NativeInterface.OmegaInterfaceManager
anonymousAssign, anonymousDatabase, anonymousDatabase, argsToList, arrayLength, assignArguments, assignResult, assignResult, callConstructor, clearReference, clearReferences, convertable, convertable, createArray, createArray, createArray, createCallFrame, database, database, debug, debug, debug, displayTask, eval, evalConstructor, evalConstructor, evalMethod, evaluate, expandClassName, genericCallMethod, genericCallMethod, genericCallMethod, genericCallMethod, genericCallMethod, getAllClasses, getArrayClasses, getArrayElement, getArrayElement, getArrayElements, getConstructors, getConstructors, getConvertibleClasses, getConvertibleClassifier, getDatabaseID, getDataType, getMethod, getMethod, getMethods, getMethods, getPrimitiveClasses, getReferences, getReferences, getReferenceValue, getReferenceValue, getWrapperClasses, identity, identity, is, is, nativeSetup, objects, remove, remove, remove, remove, remove, setArrayElement, setArrayElement, setConvertible, setConvertible, setConvertibleClassifier, setConvertibleClassifier, setDebug, testBooleanArray, testBooleanArrays, testDoubleArray, testIntArray, testStringArray, testStringArray
 
Methods inherited from class org.omegahat.Environment.Interpreter.InteractiveEvaluator
currentExpression, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, evaluate, inputReady, inputReady, interrupt, notify_listeners, notify_listeners, notifyListeners, parserError, prompt, promptExpression, promptExpression, promptExpression, serialize, serialize, serialize, serialize
 
Methods inherited from class org.omegahat.Environment.Interpreter.UserClassEvaluator
addMethod, classManager, classManager, createInstance, createInstance, createInstance, defineClass, defineClass, defineClass, defineClass, defineClass, defineClass, DefineUserClass, DefineUserClass, DefineUserClass, findUserClass, findUserClass, parseClass, parser
 
Methods inherited from class org.omegahat.Environment.Interpreter.UtilityEvaluator
evaluator, exec, exec, findFile, getEvaluator, setProperty, setProperty
 
Methods inherited from class org.omegahat.Environment.Interpreter.BasicEvaluator
addEvaluationListener, addFunctionTable, addFunctionTable, addSourceInput, addToHistory, allowUnrestrictedAccess, allowUnrestrictedAccess, asObject, asObject, asObject, asObjectName, asPrimitiveClass, assign, assign, assign, asWriter, attach, attach, attach, attach, attach, attach, attach, classInit, classLists, classLists, classPath, classPath, commandLine, convertPrimitive, copy, copy, copyByConstructor, copyBySerialization, createClassLists, currentExpression, data, data, database, database, Debug, Debug, Debug, Debug, Debug, debugger, debugger, defaultDatabase, defaultDatabase, defaultDatabase, defaultErrorHandler, detach, detach, displayTask, displayWarnings, displayWarnings, dynamicClassLoader, dynamicClassLoader, endSource, endSource, endSource, endTaskEvaluation, error, error, errorHandler, errorHandler, evaluate, evaluate, evaluate, evaluationError, evaluationListeners, evaluationListeners, evaluationListeners, exists, exit, exit, expandClassName, expandedClassPathElement, find, findAsField, findClass, findClass, findClass, findClass, findFunction, findFunctionOrMethod, functionTableList, get, get, get, get, get, get, get, get, get, getBaseURL, getEvaluationEvent, getEvaluationListeners, getField, getSubEvaluationListeners, help, Import, Import, Import, init, initialize, initTaskEvaluation, internalFunctionTables, isPrimitive, isPrimitive, javaVersion, lexer, lexer, lexer, localClasses, localClasses, manager, manager, newDatabase, newDatabase, notifyListeners, objects, objects, objects, options, options, output, output, output, parse, parse, parse, parse, primitiveClass, q, q, remove, removeFunctionTable, same, searchForClass, searchPath, searchPath, searchPath, searchPath, setEvaluationEvent, setEvaluationListeners, setSubEvaluationListeners, show, show, show, source, source, source, source, source, source, source, source, source, sourceStack, stderr, stderr, stdout, stdout, taskHistory, taskHistory, toplevelExpression, toplevelExpression, useLazyEvaluation, warning, warning, warning, warnings, warnings, where, which, which
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ROmegahatInterpreter

public ROmegahatInterpreter(java.lang.String[] args)
Basic constructor for this class which initializes R with the specified command line arguments and runs the R event loop.

ROmegahatInterpreter

public ROmegahatInterpreter(java.lang.String[] args,
                            boolean run)
Constructor that initializes R and optionally runs its event loop. A GUI splash screen will be displayed if the system property GUI is non-null.
Method Detail

main

public static void main(java.lang.String[] args)
The entry point for using this as a top-level, stand-alone application which simply runs R within Java, but getting the low-level C libraries loaded (more) correctly.

initR

public boolean initR(java.lang.String[] args)
Native method that initializes the R engine and interpreter making it available for evaluating expressions.

registerNativeConverters

public boolean registerNativeConverters()
User-level (i.e. Java) control for causing the default converters controlling how S objects are converted to Java and vice-versa to be registered and used when passing data across the S-Java interface.

run

public void run()
A native method that simply runs the R event loop, currently never returning from this call.
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class org.omegahat.Environment.Interpreter.BasicEvaluator

fixArgs

public static java.lang.String[] fixArgs(java.lang.String[] args)
This takes the user's command line arguments and adds the equivalent of argv[0] (the name of the application being invoked) to them so that they can be passed to and correctly understood by the R engine.