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, outFields 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 voidprotected intExecute this session.protected intexecute(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, setExitValueMethods inherited from class org.dellroad.jct.core.AbstractConsoleSession
doInterrupt, execute, 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, getRequest, interruptMethods 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:ConsoleSessionGet the owner, i.e., the console component that created this session.- Specified by:
getOwnerin interfaceConsoleSession<Shell,ShellRequest> - Overrides:
getOwnerin classAbstractConsoleSession<Shell,ShellRequest> - Returns:
- owning component
-
doExecute
Description copied from class:AbstractConsoleSessionExecute this session.This method is invoked by
AbstractConsoleSession.execute()to do the actual work.- Specified by:
doExecutein 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.Sessiondelegates toSimpleShell.getGreeting().- Returns:
- welcome greeting, or null for none
-
getNormalPrompt
Get the normal prompt.The implementation in
SimpleShell.Sessiondelegates toSimpleShell.getNormalPrompt().- Returns:
- the normal prompt
-
getContinuationPrompt
Get the continuation line prompt.The implementation in
SimpleShell.Sessiondelegates 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.Sessionjust 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- ifcommandis null
-