Class AbstractShellSession

All Implemented Interfaces:
ConsoleSession<Shell,ShellRequest>, ShellSession
Direct Known Subclasses:
JShellShellSession, SimpleShell.Session

public abstract class AbstractShellSession extends AbstractConsoleSession<Shell,ShellRequest> implements ShellSession
Support superclass for ShellSession implementations.
  • Field Details

  • Constructor Details

    • AbstractShellSession

      protected AbstractShellSession(Shell owner, ShellRequest request)
      Constructor.
      Parameters:
      owner - session owner
      request - associated request
      Throws:
      IllegalArgumentException - if either parameter is null
    • AbstractShellSession

      protected AbstractShellSession(Shell owner, ShellRequest request, InputStream in, PrintStream out)
      Constructor.
      Parameters:
      owner - session owner
      request - associated request
      in - input stream
      out - output stream
      Throws:
      IllegalArgumentException - if any parameter is null
  • Method Details

    • buildInputStream

      protected InputStream buildInputStream(org.jline.terminal.Terminal terminal)
      Get the InputStream to use for input from the given Terminal.
      Parameters:
      terminal - terminal for shell
      Returns:
      corresponding input stream
      Throws:
      IllegalArgumentException - if terminal is null
    • buildOutputStream

      protected PrintStream buildOutputStream(org.jline.terminal.Terminal terminal)
      Get the PrintStream to use for output from the given Terminal.
      Parameters:
      terminal - terminal for shell
      Returns:
      corresponding output stream
      Throws:
      IllegalArgumentException - if terminal is null
    • getInputStream

      public InputStream getInputStream()
      Description copied from interface: ConsoleSession
      Get this session's input stream.
      Specified by:
      getInputStream in interface ConsoleSession<Shell,ShellRequest>
      Returns:
      session input
    • getOutputStream

      public PrintStream getOutputStream()
      Description copied from interface: ConsoleSession
      Get this session's output stream.
      Specified by:
      getOutputStream in interface ConsoleSession<Shell,ShellRequest>
      Returns:
      session output
    • setExitValue

      public boolean setExitValue(int exitValue)
      Description copied from interface: ShellSession
      Signal to the shell that it should exit with the specified exit value.

      Whether the exitValue is meaningful and what to do with it (if anything) is up to the shell.

      Specified by:
      setExitValue in interface ShellSession
      Parameters:
      exitValue - integer exit value
      Returns:
      true if successful, false if setting exit value is unsupported or otherwise not possible
    • getExitValue

      public int getExitValue()
      Description copied from interface: ShellSession
      Get the current exit value, if any.
      Specified by:
      getExitValue in interface ShellSession
      Returns:
      exit value, or zero if none set or not available