org.nuiton.j2r.net
Class RNetEngine

java.lang.Object
  extended by org.nuiton.j2r.REngineAbstract
      extended by org.nuiton.j2r.net.RNetEngine
All Implemented Interfaces:
REngine

public class RNetEngine
extends REngineAbstract
implements REngine

This class represents the network engine to access R. By default, it tries to connect on address 127.0.0.1 and port 6311. Meanwhile, it is possible to parametrize it. You only need to replace the launch option -DR.type=net by -DR.type=net://192.168.99.122:6312 where 192.168.99.122 is the distant machine adress and 6312 the port on which the server is running.


Field Summary
static java.lang.String DEFAULT_HOST
           
static int DEFAULT_PORT
           
 
Constructor Summary
RNetEngine()
           
 
Method Summary
 void commit()
          Method to commit all the R expressions stored while in non-autocommit mode
 java.lang.Object eval(java.lang.String expr)
          Method to send a R instruction to the engine and get back the result.
 boolean init()
          Initialize the engine.
 boolean init(java.lang.String host, int port)
          Method to initialize the connection with specified host and port.
 void terminate()
          Terminate the connection with the server.
 void voidEval(java.lang.String expr)
          Method to send a R instruction to the engine without getting back the result.
 
Methods inherited from class org.nuiton.j2r.REngineAbstract
clearSession, cp, dget, dget, dput, dput, getwd, isAutoCommit, loadRData, loadRData, ls, mv, remove, saveRData, saveRData, setAutoCommit, setwd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuiton.j2r.REngine
clearSession, cp, dget, dget, dput, dput, getwd, isAutoCommit, loadRData, loadRData, ls, mv, remove, saveRData, saveRData, setAutoCommit, setwd
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_HOST

public static final java.lang.String DEFAULT_HOST
See Also:
Constant Field Values
Constructor Detail

RNetEngine

public RNetEngine()
Method Detail

init

public boolean init()
Initialize the engine.

Specified by:
init in interface REngine
Returns:
true/false to indicate if the initialization was succesful.
See Also:
REngine.init()

init

public boolean init(java.lang.String host,
                    int port)
Method to initialize the connection with specified host and port.

Parameters:
host - Adress of the Rserve instance
port - Port on which the Rserve instance is listening.
Returns:
true if initialized false otherwise.

eval

public java.lang.Object eval(java.lang.String expr)
                      throws RException
Method to send a R instruction to the engine and get back the result.

Specified by:
eval in interface REngine
Parameters:
expr - the R expression to evaluate.
Returns:
the result of the R expression.
Throws:
RException - if an error occur while evaluating the R expression.
See Also:
REngine.eval(java.lang.String)

terminate

public void terminate()
               throws RException
Terminate the connection with the server.

Specified by:
terminate in interface REngine
Throws:
RException
See Also:
REngine.terminate()

voidEval

public void voidEval(java.lang.String expr)
              throws RException
Method to send a R instruction to the engine without getting back the result. If not into autocommit mode, instructions are stored and sent to R after a call of the commit method.

Specified by:
voidEval in interface REngine
Parameters:
expr - The R expression to evaluate.
Throws:
RException
See Also:
REngine.voidEval(java.lang.String), commit()

commit

public void commit()
            throws RException
Method to commit all the R expressions stored while in non-autocommit mode

Specified by:
commit in interface REngine
Throws:
RException - if an error occur while evaluating one expression.


Copyright © 2006-2009 CodeLutin. All Rights Reserved.