ru.biosoft.plugins.jri
Class RServeRObject

java.lang.Object
  extended by org.rosuda.REngine.REngine
      extended by ru.biosoft.plugins.jri.RObjectSupport
          extended by ru.biosoft.plugins.jri.RServeRObject
All Implemented Interfaces:
RObject

public class RServeRObject
extends RObjectSupport

RObject implementation to work with locally installer R application via rserve


Field Summary
static java.lang.String transferCharset
          This static variable specifies the character set used to encode string for transfer.
 
Constructor Summary
RServeRObject()
          make a new local connection on default port (6311)
RServeRObject(java.lang.String host)
          make a new connection to specified host on default port (6311)
RServeRObject(java.lang.String host, int port)
          make a new connection to specified host and given port.
 
Method Summary
 void assign(java.lang.String sym, org.rosuda.REngine.REXP rexp)
          assign a content of a REXP to a symbol in R.
 void assign(java.lang.String symbol, org.rosuda.REngine.REXP value, org.rosuda.REngine.REXP env)
          assign into an environment
 void assign(java.lang.String sym, java.lang.String ct)
           
 boolean close()
          closes current connection
static RObject createObject()
           
 org.rosuda.REngine.REXP createReference(org.rosuda.REngine.REXP ref)
           
 org.rosuda.REngine.REXP eval(org.rosuda.REngine.REXP what, org.rosuda.REngine.REXP where, boolean resolve)
           
 org.rosuda.REngine.REXP eval(java.lang.String cmd)
          Evaluate expression and return result object
 void finalize()
           
 void finalizeReference(org.rosuda.REngine.REXP ref)
           
 org.rosuda.REngine.REXP get(java.lang.String symbol, org.rosuda.REngine.REXP env, boolean resolve)
          get a value from an environment
 org.rosuda.REngine.REXP getParentEnvironment(org.rosuda.REngine.REXP env, boolean resolve)
           
 boolean isAvailable()
           
 org.rosuda.REngine.REXP newEnvironment(org.rosuda.REngine.REXP parent, boolean resolve)
           
 org.rosuda.REngine.REXP parse(java.lang.String text, boolean resolve)
           
 org.rosuda.REngine.REXP parseAndEval(java.lang.String text, org.rosuda.REngine.REXP where, boolean resolve)
           
 org.rosuda.REngine.REXP resolveReference(org.rosuda.REngine.REXP ref)
          fetch the contents of the given reference.
 java.lang.String toString()
           
 void voidEval(java.lang.String cmd)
          Evaluate expression and return messages
 
Methods inherited from class ru.biosoft.plugins.jri.RObjectSupport
assignObject, getREXPObject, help, newSession, openSession, saveSession, setEnvironmentProvider
 
Methods inherited from class org.rosuda.REngine.REngine
assign, assign, assign, assign, engineForClass, getLastEngine, parseAndEval, supportsEnvironemnts, supportsReferences, supportsREPL
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

transferCharset

public static java.lang.String transferCharset
This static variable specifies the character set used to encode string for transfer. Under normal circumstances there should be no reason for changing this variable. The default is UTF-8, which makes sure that 7-bit ASCII characters are sent in a backward-compatible fashion. Currently (Rserve 0.1-7) there is no further conversion on Rserve's side, i.e. the strings are passed to R without re-coding. If necessary the setting should be changed before connecting to the Rserve in case later Rserves will provide a possibility of setting the encoding during the handshake.

Constructor Detail

RServeRObject

public RServeRObject()
              throws RserveException
make a new local connection on default port (6311)

Throws:
RserveException

RServeRObject

public RServeRObject(java.lang.String host)
              throws RserveException
make a new connection to specified host on default port (6311)

Parameters:
host - host name/IP
Throws:
RserveException

RServeRObject

public RServeRObject(java.lang.String host,
                     int port)
              throws RserveException
make a new connection to specified host and given port. Make sure you check #isConnected to ensure the connection was successfully created.

Parameters:
host - host name/IP
port - TCP port
Throws:
RserveException
Method Detail

createObject

public static RObject createObject()

isAvailable

public boolean isAvailable()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

close

public boolean close()
closes current connection

Overrides:
close in class org.rosuda.REngine.REngine

parse

public org.rosuda.REngine.REXP parse(java.lang.String text,
                                     boolean resolve)
                              throws org.rosuda.REngine.REngineException
Specified by:
parse in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

eval

public org.rosuda.REngine.REXP eval(org.rosuda.REngine.REXP what,
                                    org.rosuda.REngine.REXP where,
                                    boolean resolve)
                             throws org.rosuda.REngine.REngineException
Specified by:
eval in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

parseAndEval

public org.rosuda.REngine.REXP parseAndEval(java.lang.String text,
                                            org.rosuda.REngine.REXP where,
                                            boolean resolve)
                                     throws org.rosuda.REngine.REngineException
Overrides:
parseAndEval in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

assign

public void assign(java.lang.String symbol,
                   org.rosuda.REngine.REXP value,
                   org.rosuda.REngine.REXP env)
            throws org.rosuda.REngine.REngineException
assign into an environment

Specified by:
assign in class RObjectSupport
Parameters:
symbol - symbol name
value - value to assign
env - environment to assign to
Throws:
org.rosuda.REngine.REngineException

assign

public void assign(java.lang.String sym,
                   java.lang.String ct)
            throws RserveException
Overrides:
assign in class org.rosuda.REngine.REngine
Throws:
RserveException

assign

public void assign(java.lang.String sym,
                   org.rosuda.REngine.REXP rexp)
            throws RserveException
assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already.

Overrides:
assign in class org.rosuda.REngine.REngine
Parameters:
sym - 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
Throws:
RserveException

get

public org.rosuda.REngine.REXP get(java.lang.String symbol,
                                   org.rosuda.REngine.REXP env,
                                   boolean resolve)
                            throws org.rosuda.REngine.REngineException
get a value from an environment

Specified by:
get in class org.rosuda.REngine.REngine
Parameters:
symbol - symbol name
env - environment
resolve - resolve the resulting REXP or just return a reference
Returns:
value
Throws:
org.rosuda.REngine.REngineException

resolveReference

public org.rosuda.REngine.REXP resolveReference(org.rosuda.REngine.REXP ref)
                                         throws org.rosuda.REngine.REngineException
fetch the contents of the given reference. The resulting REXP may never be REXPReference.

Specified by:
resolveReference in class org.rosuda.REngine.REngine
Parameters:
ref - reference to resolve
Returns:
resolved reference
Throws:
org.rosuda.REngine.REngineException

createReference

public org.rosuda.REngine.REXP createReference(org.rosuda.REngine.REXP ref)
                                        throws org.rosuda.REngine.REngineException
Specified by:
createReference in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

finalizeReference

public void finalizeReference(org.rosuda.REngine.REXP ref)
                       throws org.rosuda.REngine.REngineException
Specified by:
finalizeReference in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

getParentEnvironment

public org.rosuda.REngine.REXP getParentEnvironment(org.rosuda.REngine.REXP env,
                                                    boolean resolve)
                                             throws org.rosuda.REngine.REngineException
Specified by:
getParentEnvironment in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

newEnvironment

public org.rosuda.REngine.REXP newEnvironment(org.rosuda.REngine.REXP parent,
                                              boolean resolve)
                                       throws org.rosuda.REngine.REngineException
Specified by:
newEnvironment in class org.rosuda.REngine.REngine
Throws:
org.rosuda.REngine.REngineException

eval

public org.rosuda.REngine.REXP eval(java.lang.String cmd)
Description copied from interface: RObject
Evaluate expression and return result object


voidEval

public void voidEval(java.lang.String cmd)
Description copied from interface: RObject
Evaluate expression and return messages


toString

public java.lang.String toString()
Overrides:
toString in class org.rosuda.REngine.REngine


Copyright © 2001-2009 Biosof.Ru. All Rights Reserved.