org.lsst.ccs.shell
Class Shell

java.lang.Object
  extended by org.lsst.ccs.shell.Shell

public class Shell
extends Object

Shell is the class interacting with user. Provides the command loop. All logic lies here.

Author:
ASG

Nested Class Summary
static class Shell.Settings
           
 
Field Summary
static String PROJECT_HOMEPAGE_URL
           
 
Constructor Summary
Shell(Shell.Settings s, CommandTable commandTable, List<String> path)
          Shell's constructor You probably don't need this one, see methods of the ShellFactory.
 
Method Summary
 void addAuxHandler(Object handler, String prefix)
          This method is very similar to addMainHandler, except ShellFactory will pass all handlers registered with this method to all this shell's subshells.
 void addCompleter(jline.console.completer.Completer completer)
           
 void addMainHandler(Object handler, String prefix)
          Method for registering command hanlers (or providers?) You call it, and from then the Shell has all commands declare in the handler object.
 void commandLoop()
          Runs the command session.
 String getAppName()
           
 CommandTable getCommandTable()
           
 InputConversionEngine getInputConverter()
          Call this method to get InputConversionEngine used by the Shell.
 Throwable getLastException()
          Returns last thrown exception
 OutputConversionEngine getOutputConverter()
          Call this method to get OutputConversionEngine used by the Shell.
 List<String> getPath()
           
 Shell.Settings getSettings()
           
 void processLine(String line)
          You can operate Shell linewise, without entering the command loop.
 void setAppName(String appName)
          Hint is some text displayed before the command loop and every time user enters "?".
 void setDisplayTime(boolean displayTime)
          Turns command execution time display on and off
 void setSettings(Shell.Settings s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT_HOMEPAGE_URL

public static String PROJECT_HOMEPAGE_URL
Constructor Detail

Shell

public Shell(Shell.Settings s,
             CommandTable commandTable,
             List<String> path)
Shell's constructor You probably don't need this one, see methods of the ShellFactory.

Parameters:
s - Settings object for the shell instance
commandTable - CommandTable to store commands
path - Shell's location: list of path elements.
See Also:
asg.cliche.ShellFactory
Method Detail

getSettings

public Shell.Settings getSettings()

setSettings

public void setSettings(Shell.Settings s)

getCommandTable

public CommandTable getCommandTable()
Returns:
the CommandTable for this shell.

getOutputConverter

public OutputConversionEngine getOutputConverter()
Call this method to get OutputConversionEngine used by the Shell.

Returns:
a conversion engine.

getInputConverter

public InputConversionEngine getInputConverter()
Call this method to get InputConversionEngine used by the Shell.

Returns:
a conversion engine.

addMainHandler

public void addMainHandler(Object handler,
                           String prefix)
Method for registering command hanlers (or providers?) You call it, and from then the Shell has all commands declare in the handler object. This method recognizes if it is passed ShellDependent or ShellManageable and calls corresponding methods, as described in those interfaces.

Parameters:
handler - Object which should be registered as handler.
prefix - Prefix that should be prepended to all handler's command names.
See Also:
asg.cliche.ShellDependent, asg.cliche.ShellManageable

addAuxHandler

public void addAuxHandler(Object handler,
                          String prefix)
This method is very similar to addMainHandler, except ShellFactory will pass all handlers registered with this method to all this shell's subshells.

Parameters:
handler - Object which should be registered as handler.
prefix - Prefix that should be prepended to all handler's command names.
See Also:
asg.cliche.Shell#addMainHandler(java.lang.Object, java.lang.String)

getLastException

public Throwable getLastException()
Returns last thrown exception


getPath

public List<String> getPath()
Returns:
list of path elements, as it was passed in constructor

addCompleter

public void addCompleter(jline.console.completer.Completer completer)

commandLoop

public void commandLoop()
                 throws IOException
Runs the command session. Create the Shell, then run this method to listen to the user, and the Shell will invoke Handler's methods.

Throws:
IOException - when can't readLine() from input.

processLine

public void processLine(String line)
                 throws CLIException
You can operate Shell linewise, without entering the command loop. All output is directed to shell's Output.

Parameters:
line - Full command line
Throws:
asg.cliche.CLIException - This may be TokenException
CLIException
See Also:
asg.cliche.Output

setDisplayTime

public void setDisplayTime(boolean displayTime)
Turns command execution time display on and off

Parameters:
displayTime - true if do display, false otherwise

setAppName

public void setAppName(String appName)
Hint is some text displayed before the command loop and every time user enters "?".


getAppName

public String getAppName()


Copyright © 2013 LSST. All Rights Reserved.