Package org.dellroad.jct.core
Class AbstractShellSession
java.lang.Object
org.dellroad.jct.core.AbstractConsoleSession<Shell,ShellRequest>
org.dellroad.jct.core.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 Summary
FieldsModifier and TypeFieldDescriptionprotected IntegerThis will be non-null ifsetExitValue(int)has been invoked.protected final InputStreamprotected final PrintStreamFields inherited from class org.dellroad.jct.core.AbstractConsoleSession
owner, request -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractShellSession(Shell owner, ShellRequest request) Constructor.protectedAbstractShellSession(Shell owner, ShellRequest request, InputStream in, PrintStream out) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected InputStreambuildInputStream(org.jline.terminal.Terminal terminal) Get theInputStreamto use for input from the givenTerminal.protected PrintStreambuildOutputStream(org.jline.terminal.Terminal terminal) Get thePrintStreamto use for output from the givenTerminal.intGet the current exit value, if any.Get this session's input stream.Get this session's output stream.booleansetExitValue(int exitValue) Signal to the shell that it should exit with the specified exit value.Methods inherited from class org.dellroad.jct.core.AbstractConsoleSession
doExecute, doInterrupt, execute, getOwner, getRequest, interruptMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dellroad.jct.core.ConsoleSession
execute, getOwner, getRequest, interruptMethods inherited from interface org.dellroad.jct.core.ShellSession
getErrorStream
-
Field Details
-
in
-
out
-
exitValue
This will be non-null ifsetExitValue(int)has been invoked.
-
-
Constructor Details
-
AbstractShellSession
Constructor.- Parameters:
owner- session ownerrequest- associated request- Throws:
IllegalArgumentException- if either parameter is null
-
AbstractShellSession
Constructor.- Parameters:
owner- session ownerrequest- associated requestin- input streamout- output stream- Throws:
IllegalArgumentException- if any parameter is null
-
-
Method Details
-
buildInputStream
Get theInputStreamto use for input from the givenTerminal.- Parameters:
terminal- terminal for shell- Returns:
- corresponding input stream
- Throws:
IllegalArgumentException- ifterminalis null
-
buildOutputStream
Get thePrintStreamto use for output from the givenTerminal.- Parameters:
terminal- terminal for shell- Returns:
- corresponding output stream
- Throws:
IllegalArgumentException- ifterminalis null
-
getInputStream
Description copied from interface:ConsoleSessionGet this session's input stream.- Specified by:
getInputStreamin interfaceConsoleSession<Shell,ShellRequest> - Returns:
- session input
-
getOutputStream
Description copied from interface:ConsoleSessionGet this session's output stream.- Specified by:
getOutputStreamin interfaceConsoleSession<Shell,ShellRequest> - Returns:
- session output
-
setExitValue
public boolean setExitValue(int exitValue) Description copied from interface:ShellSessionSignal to the shell that it should exit with the specified exit value.Whether the
exitValueis meaningful and what to do with it (if anything) is up to the shell.- Specified by:
setExitValuein interfaceShellSession- 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:ShellSessionGet the current exit value, if any.- Specified by:
getExitValuein interfaceShellSession- Returns:
- exit value, or zero if none set or not available
-