Class 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RConsole

        public RConsole()
        Construct the R Console class and initialize the buffer containing the text.
    • 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        text - 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        which - 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        prompt - The prompt
        addToHistory - 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        message - 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        newFile - 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 interface org.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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        filename - 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 interface org.rosuda.JRI.RMainLoopCallbacks
        Parameters:
        re - The R engine
        filename - the file in which to save the history.