Interface CommandSession

  • All Superinterfaces:
    java.lang.AutoCloseable
    All Known Implementing Classes:
    CommandSessionImpl

    public interface CommandSession
    extends java.lang.AutoCloseable
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  CommandSession.Utils
      Return the current session.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String OPTION_NO_GLOB  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.ClassLoader classLoader()  
      void classLoader​(java.lang.ClassLoader classLoader)  
      void close()
      Close this command session.
      java.lang.Object convert​(java.lang.Class<?> type, java.lang.Object instance)
      Convert an object to another type.
      java.nio.file.Path currentDir()  
      void currentDir​(java.nio.file.Path path)  
      java.lang.Object execute​(java.lang.CharSequence commandline)
      Execute a program in this session.
      Job foregroundJob()
      Get the current foreground job or null.
      java.lang.CharSequence format​(java.lang.Object target, int level)
      Convert an object to string form (CharSequence).
      java.lang.Object get​(java.lang.String name)
      Get the value of a variable.
      java.io.PrintStream getConsole()
      Return the PrintStream for the console.
      java.io.InputStream getKeyboard()
      Return the input stream that is the first of the pipeline.
      java.util.List<Job> jobs()
      List jobs.
      java.lang.Object put​(java.lang.String name, java.lang.Object value)
      Set the value of a variable.
      void setJobListener​(JobListener listener)
      Set the job listener for this session.
    • Method Detail

      • currentDir

        java.nio.file.Path currentDir()
      • currentDir

        void currentDir​(java.nio.file.Path path)
      • classLoader

        java.lang.ClassLoader classLoader()
      • classLoader

        void classLoader​(java.lang.ClassLoader classLoader)
      • execute

        java.lang.Object execute​(java.lang.CharSequence commandline)
                          throws java.lang.Exception
        Execute a program in this session.
        Parameters:
        commandline - the commandline
        Returns:
        the result of the execution
        Throws:
        java.lang.Exception - on exception
      • close

        void close()
        Close this command session. After the session is closed, it will throw IllegalStateException when it is used.
        Specified by:
        close in interface java.lang.AutoCloseable
      • getKeyboard

        java.io.InputStream getKeyboard()
        Return the input stream that is the first of the pipeline. This stream is sometimes necessary to communicate directly to the end user. For example, a "less" or "more" command needs direct input from the keyboard to control the paging.
        Returns:
        InpuStream used closest to the user or null if input is from a file.
      • getConsole

        java.io.PrintStream getConsole()
        Return the PrintStream for the console. This must always be the stream "closest" to the user. This stream can be used to post messages that bypass the piping. If the output is piped to a file, then the object returned must be null.
        Returns:
        PrintStream the console print stream
      • get

        java.lang.Object get​(java.lang.String name)
        Get the value of a variable.
        Parameters:
        name - the name
        Returns:
        Object
      • put

        java.lang.Object put​(java.lang.String name,
                             java.lang.Object value)
        Set the value of a variable.
        Parameters:
        name - Name of the variable.
        value - Value of the variable
        Returns:
        Object
      • format

        java.lang.CharSequence format​(java.lang.Object target,
                                      int level)
        Convert an object to string form (CharSequence). The level is defined in the Converter interface, it can be one of INSPECT, LINE, PART. This function always returns a non null value. As a last resort, toString is called on the Object.
        Parameters:
        target - the target
        level - the level
        Returns:
        CharSequence
      • convert

        java.lang.Object convert​(java.lang.Class<?> type,
                                 java.lang.Object instance)
        Convert an object to another type.
        Parameters:
        type - the type
        instance - the instance
        Returns:
        Object
      • jobs

        java.util.List<Job> jobs()
        List jobs. Always return a non-null list.
        Returns:
        List<Job>
      • foregroundJob

        Job foregroundJob()
        Get the current foreground job or null.
        Returns:
        Job
      • setJobListener

        void setJobListener​(JobListener listener)
        Set the job listener for this session.
        Parameters:
        listener - the listener