Package ptolemy.actor.lib.r
Class RConsole
- java.lang.Object
-
- ptolemy.actor.lib.r.RConsole
-
- All Implemented Interfaces:
org.rosuda.JRI.RMainLoopCallbacks
public class RConsole extends java.lang.Object implements org.rosuda.JRI.RMainLoopCallbacks
A simple buffering console that is used to cache the output from an R session and then can be used to return the console output as a string.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Matt Jones
-
-
Constructor Summary
Constructors Constructor Description RConsole()
Construct the R Console class and initialize the buffer containing the text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the console.java.lang.String
getConsoleOutput()
After an R session has ended, get a String representation of the output of the R session.void
rBusy(org.rosuda.JRI.Rengine re, int which)
Print a busy message.java.lang.String
rChooseFile(org.rosuda.JRI.Rengine re, int newFile)
Choose a file.void
rFlushConsole(org.rosuda.JRI.Rengine re)
Flush the console.void
rLoadHistory(org.rosuda.JRI.Rengine re, java.lang.String filename)
Load the history.java.lang.String
rReadConsole(org.rosuda.JRI.Rengine re, java.lang.String prompt, int addToHistory)
Read from the console.void
rSaveHistory(org.rosuda.JRI.Rengine re, java.lang.String filename)
Save history.void
rShowMessage(org.rosuda.JRI.Rengine re, java.lang.String message)
Show a message.void
rWriteConsole(org.rosuda.JRI.Rengine re, java.lang.String text, int oType)
Callback that is called when text is available from the R Engine and should be written to the console.
-
-
-
Method Detail
-
clear
public void clear()
Clear the console.
-
getConsoleOutput
public java.lang.String getConsoleOutput()
After an R session has ended, get a String representation of the output of the R session.- Returns:
- String containing the text of the R session output
-
rWriteConsole
public void rWriteConsole(org.rosuda.JRI.Rengine re, java.lang.String text, int oType)
Callback that is called when text is available from the R Engine and should be written to the console.- Specified by:
rWriteConsole
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginetext
- The text to by written.oType
- Ignored in this method.
-
rBusy
public void rBusy(org.rosuda.JRI.Rengine re, int which)
Print a busy message.- Specified by:
rBusy
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginewhich
- Unknown.
-
rReadConsole
public java.lang.String rReadConsole(org.rosuda.JRI.Rengine re, java.lang.String prompt, int addToHistory)
Read from the console. In this class, null is returned.- Specified by:
rReadConsole
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R engineprompt
- The promptaddToHistory
- unknown- Returns:
- the string read from the console
-
rShowMessage
public void rShowMessage(org.rosuda.JRI.Rengine re, java.lang.String message)
Show a message.- Specified by:
rShowMessage
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginemessage
- The message
-
rChooseFile
public java.lang.String rChooseFile(org.rosuda.JRI.Rengine re, int newFile)
Choose a file. In this class return the empty string.- Specified by:
rChooseFile
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginenewFile
- unused- Returns:
- The file name.
-
rFlushConsole
public void rFlushConsole(org.rosuda.JRI.Rengine re)
Flush the console. In this class, do nothing.- Specified by:
rFlushConsole
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R engine
-
rLoadHistory
public void rLoadHistory(org.rosuda.JRI.Rengine re, java.lang.String filename)
Load the history. In this class, do nothing.- Specified by:
rLoadHistory
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginefilename
- The file that contains the history.
-
rSaveHistory
public void rSaveHistory(org.rosuda.JRI.Rengine re, java.lang.String filename)
Save history. In this class, do nothing.- Specified by:
rSaveHistory
in interfaceorg.rosuda.JRI.RMainLoopCallbacks
- Parameters:
re
- The R enginefilename
- the file in which to save the history.
-
-