|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rosuda.REngine.REngine
org.rosuda.REngine.Rserve.RConnection
public class RConnection
class providing TCP/IP connection to an Rserve
| Field Summary | |
|---|---|
static int |
AT_crypt
authorization type: unix crypt |
static int |
AT_plain
authorization type: plain text |
protected int |
rsrvVersion
version of the server (as reported in IDstring just after Rsrv) |
static String |
transferCharset
This static variable specifies the character set used to encode string for transfer. |
| Fields inherited from class org.rosuda.REngine.REngine |
|---|
lastEngine |
| Constructor Summary | |
|---|---|
RConnection()
make a new local connection on default port (6311) |
|
RConnection(Socket sock)
create a connection based on a previously obtained socket. |
|
RConnection(String host)
make a new connection to specified host on default port (6311) |
|
RConnection(String host,
int port)
make a new connection to specified host and given port. |
|
| Method Summary | |
|---|---|
void |
assign(String sym,
org.rosuda.REngine.REXP rexp)
assign a content of a REXP to a symbol in R. |
void |
assign(String symbol,
org.rosuda.REngine.REXP value,
org.rosuda.REngine.REXP env)
assign into an environment |
void |
assign(String sym,
String ct)
assign a string value to a symbol in R. |
boolean |
close()
closes current connection |
RFileOutputStream |
createFile(String fn)
create a file on the Rserve for writing |
org.rosuda.REngine.REXP |
createReference(org.rosuda.REngine.REXP ref)
|
RSession |
detach()
detaches the session and closes the connection (requires Rserve 0.4+). |
org.rosuda.REngine.REXP |
eval(org.rosuda.REngine.REXP what,
org.rosuda.REngine.REXP where,
boolean resolve)
|
org.rosuda.REngine.REXP |
eval(String cmd)
evaluates the given command and retrieves the result |
void |
finalize()
|
void |
finalizeReference(org.rosuda.REngine.REXP ref)
|
org.rosuda.REngine.REXP |
get(String symbol,
org.rosuda.REngine.REXP env,
boolean resolve)
get a value from an environment |
String |
getLastError()
get last error string |
org.rosuda.REngine.REXP |
getParentEnvironment(org.rosuda.REngine.REXP env,
boolean resolve)
|
int |
getServerVersion()
get server version as reported during the handshake. |
boolean |
isConnected()
check connection state. |
void |
login(String user,
String pwd)
login using supplied user/pwd. |
boolean |
needLogin()
check authentication requirement sent by server |
org.rosuda.REngine.REXP |
newEnvironment(org.rosuda.REngine.REXP parent,
boolean resolve)
|
RFileInputStream |
openFile(String fn)
open a file on the Rserve for reading |
org.rosuda.REngine.REXP |
parse(String text,
boolean resolve)
|
org.rosuda.REngine.REXP |
parseAndEval(String text,
org.rosuda.REngine.REXP where,
boolean resolve)
|
void |
removeFile(String fn)
remove a file on the Rserve |
org.rosuda.REngine.REXP |
resolveReference(org.rosuda.REngine.REXP ref)
fetch the contents of the given reference. |
void |
serverEval(String cmd)
evaluates the given command in the master server process asynchronously (control command). |
void |
serverShutdown()
attempt to shut down the server process cleanly. |
void |
serverSource(String serverFile)
sources the given file (the path must be local to the server!) in the master server process asynchronously (control command). |
void |
setSendBufferSize(long sbs)
Sets send buffer size of the Rserve (in bytes) for the current connection. |
void |
setStringEncoding(String enc)
set string encoding for this session. |
void |
shutdown()
shutdown remote Rserve. |
void |
voidEval(String cmd)
evaluates the given command, but does not fetch the result (useful for assignment operations) |
RSession |
voidEvalDetach(String cmd)
evaluates the given command, detaches the session (see @link{detach()}) and closes connection while the command is being evaluted (requires Rserve 0.4+). |
| Methods inherited from class org.rosuda.REngine.REngine |
|---|
assign, assign, assign, assign, engineForClass, engineForClass, getLastEngine, lock, parseAndEval, supportsEnvironments, supportsLocking, supportsReferences, supportsREPL, toString, tryLock, unlock, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static String transferCharset
public static final int AT_plain
public static final int AT_crypt
protected int rsrvVersion
| Constructor Detail |
|---|
public RConnection()
throws RserveException
RserveException
public RConnection(String host)
throws RserveException
host - host name/IP
RserveException
public RConnection(String host,
int port)
throws RserveException
isConnected() to ensure the connection was successfully created.
host - host name/IPport - TCP port
RserveException
public RConnection(Socket sock)
throws RserveException
sock - connected socket
RserveException| Method Detail |
|---|
public void finalize()
finalize in class Objectpublic int getServerVersion()
public boolean close()
close in class org.rosuda.REngine.REngine
public void voidEval(String cmd)
throws RserveException
cmd - command/expression string
RserveException
public RSession voidEvalDetach(String cmd)
throws RserveException
cmd - command/expression string
RserveException
public org.rosuda.REngine.REXP eval(String cmd)
throws RserveException
cmd - command/expression string
null if an error occured
RserveException
public void assign(String sym,
String ct)
throws RserveException
assign in class org.rosuda.REngine.REnginesym - symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo").ct - contents
RserveException
public void assign(String sym,
org.rosuda.REngine.REXP rexp)
throws RserveException
assign in class org.rosuda.REngine.REnginesym - symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo").rexp - contents
RserveException
public RFileInputStream openFile(String fn)
throws IOException
fn - file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory.
IOException
public RFileOutputStream createFile(String fn)
throws IOException
fn - file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory.
IOException
public void removeFile(String fn)
throws RserveException
fn - file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory.
RserveException
public void shutdown()
throws RserveException
RserveException
public void setSendBufferSize(long sbs)
throws RserveException
sbs - send buffer size (in bytes) min=32k, max=1GB
RserveException
public void setStringEncoding(String enc)
throws RserveException
encoding option in the server or by calling
setStringEncoding("utf8") at the beginning of a session (but
after login).
enc - name of the encoding as defined by Rserve - as of
Rserve version 0.5-3 valid values are "utf8", "latin1" and
"native" (case-sensitive)
RserveException
public void login(String user,
String pwd)
throws RserveException
user - usernamepwd - password
RserveException
public RSession detach()
throws RserveException
RserveExceptionpublic boolean isConnected()
true if this connection is alivepublic boolean needLogin()
true is server requires authentication. In such case first
command after connecting must be login(java.lang.String, java.lang.String).public String getLastError()
public void serverEval(String cmd)
throws RserveException
cmd - command/expression string
RserveException
public void serverSource(String serverFile)
throws RserveException
#serverEval() for details on control commands.
serverFile - path to a file on the server (it is recommended to always use full paths, because the server process has a different working directory than the client child process!).
RserveException
public void serverShutdown()
throws RserveException
shutdown() method and this method: serverShutdown() is a proper control command and thus fully authentication controllable, whereas shutdown() is a client-side command sent to the client child process and thus relying on the ability of the client to signal the server process which may be disabled. Therefore serverShutdown() is preferred and more reliable for Rserve 0.6-0 and higher.
RserveException
public org.rosuda.REngine.REXP parse(String text,
boolean resolve)
throws org.rosuda.REngine.REngineException
parse in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP eval(org.rosuda.REngine.REXP what,
org.rosuda.REngine.REXP where,
boolean resolve)
throws org.rosuda.REngine.REngineException
eval in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP parseAndEval(String text,
org.rosuda.REngine.REXP where,
boolean resolve)
throws org.rosuda.REngine.REngineException
parseAndEval in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public void assign(String symbol,
org.rosuda.REngine.REXP value,
org.rosuda.REngine.REXP env)
throws org.rosuda.REngine.REngineException
assign in class org.rosuda.REngine.REnginesymbol - symbol namevalue - value to assignenv - environment to assign to
org.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP get(String symbol,
org.rosuda.REngine.REXP env,
boolean resolve)
throws org.rosuda.REngine.REngineException
get in class org.rosuda.REngine.REnginesymbol - symbol nameenv - environmentresolve - resolve the resulting REXP or just return a reference
org.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP resolveReference(org.rosuda.REngine.REXP ref)
throws org.rosuda.REngine.REngineException
resolveReference in class org.rosuda.REngine.REngineref - reference to resolve
org.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP createReference(org.rosuda.REngine.REXP ref)
throws org.rosuda.REngine.REngineException
createReference in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public void finalizeReference(org.rosuda.REngine.REXP ref)
throws org.rosuda.REngine.REngineException
finalizeReference in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP getParentEnvironment(org.rosuda.REngine.REXP env,
boolean resolve)
throws org.rosuda.REngine.REngineException
getParentEnvironment in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
public org.rosuda.REngine.REXP newEnvironment(org.rosuda.REngine.REXP parent,
boolean resolve)
throws org.rosuda.REngine.REngineException
newEnvironment in class org.rosuda.REngine.REngineorg.rosuda.REngine.REngineException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||