|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.rosuda.REngine.REngine
public abstract class REngine
REngine is an abstract base class for all implementations of R engines. Subclasses can implement interfaces to R in many different ways.
Clients should always use methods this class instead of its direct subclasses in order to maintian compatibility with any R engine implementation.
The canonical way of obtaining a new engine is to call engineForClass(java.lang.String)
. All subclasses must implement createEngine()
method.
Field Summary | |
---|---|
protected static REngine |
lastEngine
last created engine or null if there is none |
Constructor Summary | |
---|---|
REngine()
|
Method Summary | |
---|---|
void |
assign(java.lang.String symbol,
byte[] d)
convenience method equivalent to assign(symbol, new REXPRaw(d), null) (see assign(String, REXP, REXP) ) |
void |
assign(java.lang.String symbol,
double[] d)
convenience method equivalent to assign(symbol, new REXPDouble(d), null) (see assign(String, REXP, REXP) ) |
void |
assign(java.lang.String symbol,
int[] d)
convenience method equivalent to assign(symbol, new REXPInteger(d), null) (see assign(String, REXP, REXP) ) |
void |
assign(java.lang.String symbol,
REXP value)
convenience method equivalent to assign(symbol, value, null) (see assign(String, REXP, REXP) ) |
abstract void |
assign(java.lang.String symbol,
REXP value,
REXP env)
assign into an environment |
void |
assign(java.lang.String symbol,
java.lang.String d)
convenience method equivalent to assign(symbol, new REXPString(d), null) (see assign(String, REXP, REXP) ) |
void |
assign(java.lang.String symbol,
java.lang.String[] d)
convenience method equivalent to assign(symbol, new REXPString(d), null) (see assign(String, REXP, REXP) ) |
boolean |
close()
performs a close operation on engines that support it. |
abstract REXP |
createReference(REXP value)
create a reference by pushing local data to R and returning a reference to the data. |
static REngine |
engineForClass(java.lang.String klass)
this is the designated constructor for REngine classes. |
static REngine |
engineForClass(java.lang.String klass,
java.lang.String[] args,
REngineCallbacks callbacks,
boolean runREPL)
This is the extended constructor for REngine classes. |
abstract REXP |
eval(REXP what,
REXP where,
boolean resolve)
evaluate an expression vector |
abstract void |
finalizeReference(REXP ref)
removes reference from the R side. |
abstract REXP |
get(java.lang.String symbol,
REXP env,
boolean resolve)
get a value from an environment |
static REngine |
getLastEngine()
retrieve the last created engine |
abstract REXP |
getParentEnvironment(REXP env,
boolean resolve)
get the parent environemnt of an environemnt |
int |
lock()
obtains a lock for this R engine, waiting until it becomes available. |
abstract REXP |
newEnvironment(REXP parent,
boolean resolve)
create a new environemnt |
abstract REXP |
parse(java.lang.String text,
boolean resolve)
parse a string into an expression vector |
REXP |
parseAndEval(java.lang.String cmd)
convenince method equivalent to eval(parse(cmd, false), null, true); |
REXP |
parseAndEval(java.lang.String text,
REXP where,
boolean resolve)
convenince method equivalent to eval(parse(text, false), where, resolve); |
abstract REXP |
resolveReference(REXP ref)
fetch the contents of the given reference. |
boolean |
supportsEnvironments()
check whether this engine supports handing of environments (if not, eval(org.rosuda.REngine.REXP, org.rosuda.REngine.REXP, boolean) and assign(java.lang.String, org.rosuda.REngine.REXP, org.rosuda.REngine.REXP) only support the global environment denoted by null ). |
boolean |
supportsLocking()
check whether this engine supports locking ( lock() , tryLock() and unlock(int) ). |
boolean |
supportsReferences()
check whether this engine supports references to R objects |
boolean |
supportsREPL()
check whether this engine supports REPL (Read-Evaluate-Print-Loop) and corresponding callbacks. |
java.lang.String |
toString()
|
int |
tryLock()
attempts to obtain a lock for this R engine synchronously (without waiting for it). |
void |
unlock(int lockValue)
releases a lock previously obtained by lock() or tryLock() . |
REXP |
wrap(java.lang.Object o)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static REngine lastEngine
null
if there is none
Constructor Detail |
---|
public REngine()
Method Detail |
---|
public static REngine engineForClass(java.lang.String klass) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
klass
- fully qualified class-name of a REngine implementation
null
if createEngine
invokation failed
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static REngine engineForClass(java.lang.String klass, java.lang.String[] args, REngineCallbacks callbacks, boolean runREPL) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
klass
- fully qualified class-name of a REngine implementationargs
- arguments to pass to R for initializationcallbacks
- delegate for REngine callbacks or null
if callbacks won't be serviced (engine may not support callbacks)runREPL
- if true
then REPL will be started (if supported by the engine)
null
if createEngine
invokation failed
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static REngine getLastEngine()
null
if no engine was created yetpublic abstract REXP parse(java.lang.String text, boolean resolve) throws REngineException
text
- string to parseresolve
- resolve the resulting REXP (true
) or just return a reference (false
)
REngineException
public abstract REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException
what
- an expression (or vector of such) to evaluatewhere
- environment to evaluate in (use null
for the global environemnt and/or if environments are not supported by the engine)resolve
- resolve the resulting REXP or just return a reference
REngineException
REXPMismatchException
public abstract void assign(java.lang.String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException
symbol
- symbol namevalue
- value to assignenv
- environment to assign to (use null
for the global environemnt and/or if environments are not supported by the engine)
REngineException
REXPMismatchException
public abstract REXP get(java.lang.String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException
symbol
- symbol nameenv
- environment (use null
for the global environemnt and/or if environments are not supported by the engine)resolve
- resolve the resulting REXP or just return a reference
REngineException
REXPMismatchException
public abstract REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException
#REngineException
exception if supportsReferences()
returns false
.
ref
- reference to resolve
REngineException
REXPMismatchException
public abstract REXP createReference(REXP value) throws REngineException, REXPMismatchException
#REngineException
exception if supportsReferences()
returns false
.
value
- to create reference to
REngineException
REXPMismatchException
public abstract void finalizeReference(REXP ref) throws REngineException, REXPMismatchException
REXPReference
and should never be called directly.
ref
- reference to finalize
REngineException
REXPMismatchException
public abstract REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException
env
- environment to queryresolve
- whether to resolve the resulting environment reference
REngineException
REXPMismatchException
public abstract REXP newEnvironment(REXP parent, boolean resolve) throws REngineException, REXPMismatchException
parent
- parent environmentresolve
- whether to resolve the reference to the environemnt (usually false
since the returned environment will be empty)
REngineException
REXPMismatchException
public REXP parseAndEval(java.lang.String text, REXP where, boolean resolve) throws REngineException, REXPMismatchException
eval(parse(text, false), where, resolve);
text
- to parse (see parse(java.lang.String, boolean)
)where
- environment to evaluate in (see eval(org.rosuda.REngine.REXP, org.rosuda.REngine.REXP, boolean)
)resolve
- whether to resolve the resulting reference or not (see eval(org.rosuda.REngine.REXP, org.rosuda.REngine.REXP, boolean)
)
REngineException
REXPMismatchException
public REXP parseAndEval(java.lang.String cmd) throws REngineException, REXPMismatchException
eval(parse(cmd, false), null, true);
cmd
- expression to parse (see parse(java.lang.String, boolean)
)
REngineException
REXPMismatchException
public boolean close()
close()
returned true
. This operation is optional and will always return false
if not implemented.
true
if the close opetaion was successful, false
otherwise.public boolean supportsReferences()
true
if this engine supports references, false/code> otherwise
public boolean supportsEnvironments()
eval(org.rosuda.REngine.REXP, org.rosuda.REngine.REXP, boolean)
and assign(java.lang.String, org.rosuda.REngine.REXP, org.rosuda.REngine.REXP)
only support the global environment denoted by null
).
true
if this engine supports environments, false/code> otherwise
public boolean supportsREPL()
true
if this engine supports REPL, false/code> otherwise
public boolean supportsLocking()
lock()
, tryLock()
and unlock(int)
).
true
if this engine supports REPL, false/code> otherwise
public void assign(java.lang.String symbol, double[] d) throws REngineException
assign(symbol, new REXPDouble(d), null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tod
- values to assign
REngineException
public void assign(java.lang.String symbol, int[] d) throws REngineException
assign(symbol, new REXPInteger(d), null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tod
- values to assign
REngineException
public void assign(java.lang.String symbol, java.lang.String[] d) throws REngineException
assign(symbol, new REXPString(d), null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tod
- values to assign
REngineException
public void assign(java.lang.String symbol, byte[] d) throws REngineException
assign(symbol, new REXPRaw(d), null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tod
- values to assign
REngineException
public void assign(java.lang.String symbol, java.lang.String d) throws REngineException
assign(symbol, new REXPString(d), null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tod
- value to assign
REngineException
public void assign(java.lang.String symbol, REXP value) throws REngineException, REXPMismatchException
assign(symbol, value, null)
(see assign(String, REXP, REXP)
)
symbol
- symbol name to assign tovalue
- values to assign
REngineException
REXPMismatchException
public int tryLock()
supportsLocking()
before relying on this capability. If not implemented, always returns 0.
unlock(int)
.public int lock()
supportsLocking()
before relying on this capability. If not implemented, always returns 0.
unlock(int)
in order to release the lockpublic void unlock(int lockValue)
lock()
or tryLock()
.
supportsLocking()
before relying on this capability. If not implemented, has no effect.
lockValue
- value returned by lock()
or tryLock()
.public java.lang.String toString()
toString
in class java.lang.Object
public REXP wrap(java.lang.Object o)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |