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 Integer
This will be non-null ifsetExitValue(int)
has been invoked.protected final InputStream
protected final PrintStream
Fields inherited from class org.dellroad.jct.core.AbstractConsoleSession
owner, request
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractShellSession
(Shell owner, ShellRequest request) Constructor.protected
AbstractShellSession
(Shell owner, ShellRequest request, InputStream in, PrintStream out) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected InputStream
buildInputStream
(org.jline.terminal.Terminal terminal) Get theInputStream
to use for input from the givenTerminal
.protected PrintStream
buildOutputStream
(org.jline.terminal.Terminal terminal) Get thePrintStream
to use for output from the givenTerminal
.int
Get the current exit value, if any.Get this session's input stream.Get this session's output stream.boolean
setExitValue
(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, interrupt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.dellroad.jct.core.ConsoleSession
execute, getOwner, getRequest, interrupt
Methods 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 theInputStream
to use for input from the givenTerminal
.- Parameters:
terminal
- terminal for shell- Returns:
- corresponding input stream
- Throws:
IllegalArgumentException
- ifterminal
is null
-
buildOutputStream
Get thePrintStream
to use for output from the givenTerminal
.- Parameters:
terminal
- terminal for shell- Returns:
- corresponding output stream
- Throws:
IllegalArgumentException
- ifterminal
is null
-
getInputStream
Description copied from interface:ConsoleSession
Get this session's input stream.- Specified by:
getInputStream
in interfaceConsoleSession<Shell,
ShellRequest> - Returns:
- session input
-
getOutputStream
Description copied from interface:ConsoleSession
Get this session's output stream.- Specified by:
getOutputStream
in interfaceConsoleSession<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 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:ShellSession
Get the current exit value, if any.- Specified by:
getExitValue
in interfaceShellSession
- Returns:
- exit value, or zero if none set or not available
-