Package org.dellroad.jct.core.simple
Class SimpleShell.Session
java.lang.Object
org.dellroad.jct.core.AbstractConsoleSession<Shell,ShellRequest>
org.dellroad.jct.core.AbstractShellSession
org.dellroad.jct.core.simple.SimpleShell.Session
- All Implemented Interfaces:
ConsoleSession<Shell,
,ShellRequest> ShellSession
- Enclosing class:
- SimpleShell
Default
ShellSession
implementation used by SimpleShell
.-
Field Summary
FieldsFields inherited from class org.dellroad.jct.core.AbstractShellSession
exitValue, in, out
Fields inherited from class org.dellroad.jct.core.AbstractConsoleSession
owner, request
-
Constructor Summary
ConstructorsConstructorDescriptionSession
(SimpleShell shell, ShellRequest request, org.jline.reader.LineReader reader) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected int
Execute this session.protected int
execute
(SimpleCommandSupport.FoundCommand command) Execute the given command in the context of this session.Get the continuation line prompt.Get the welcome greeting.Get the normal prompt.getOwner()
Get the owner, i.e., the console component that created this session.Methods inherited from class org.dellroad.jct.core.AbstractShellSession
buildInputStream, buildOutputStream, getExitValue, getInputStream, getOutputStream, setExitValue
Methods inherited from class org.dellroad.jct.core.AbstractConsoleSession
doInterrupt, execute, 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, getRequest, interrupt
Methods inherited from interface org.dellroad.jct.core.ShellSession
getErrorStream
-
Field Details
-
reader
protected final org.jline.reader.LineReader reader
-
-
Constructor Details
-
Session
public Session(SimpleShell shell, ShellRequest request, org.jline.reader.LineReader reader) throws IOException Constructor.- Parameters:
shell
- session ownerrequest
- shell execution requestreader
- console line reader- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if any parameter is null
-
-
Method Details
-
getOwner
Description copied from interface:ConsoleSession
Get the owner, i.e., the console component that created this session.- Specified by:
getOwner
in interfaceConsoleSession<Shell,
ShellRequest> - Overrides:
getOwner
in classAbstractConsoleSession<Shell,
ShellRequest> - Returns:
- owning component
-
doExecute
Description copied from class:AbstractConsoleSession
Execute this session.This method is invoked by
AbstractConsoleSession.execute()
to do the actual work.- Specified by:
doExecute
in classAbstractConsoleSession<Shell,
ShellRequest> - Returns:
- zero if successful, non-zero error code if an error occurred
- Throws:
InterruptedException
- if the current thread is interrupted
-
getGreeting
Get the welcome greeting.The implementation in
SimpleShell.Session
delegates toSimpleShell.getGreeting()
.- Returns:
- welcome greeting, or null for none
-
getNormalPrompt
Get the normal prompt.The implementation in
SimpleShell.Session
delegates toSimpleShell.getNormalPrompt()
.- Returns:
- the normal prompt
-
getContinuationPrompt
Get the continuation line prompt.The implementation in
SimpleShell.Session
delegates toSimpleShell.getContinuationPrompt()
.- Returns:
- the continuation line prompt
-
commandLoop
protected void commandLoop() -
execute
Execute the given command in the context of this session.The implementation in
SimpleShell.Session
just invokesSimpleCommandSupport.FoundCommand.execute(org.dellroad.jct.core.ConsoleSession<?, ?>)
. Subclasses can override this method to intercept/wrap individual command execution.- Parameters:
command
- command to execute- Returns:
- command return value
- Throws:
InterruptedException
- if the current thread is interruptedIllegalArgumentException
- ifcommand
is null
-