edu.nmu.os.shell
Class ShellImpl

java.lang.Object
  |
  +--edu.nmu.os.shell.Shell
        |
        +--edu.nmu.os.shell.ShellImpl
All Implemented Interfaces:
java.lang.Runnable

public class ShellImpl
extends Shell

A command shell for the Java Virtual Machine

TODO: man page

Since:
jdk1.4
Version:
0.1, Jan 24, 2003 7:16:18 PM
Author:
Matt Murphy

Field Summary
static java.lang.String CLASSPATH_PATH_PROPERTY
           
static java.lang.String CLASSPATH_PWD_PROPERTY
           
static java.lang.String DEFAULT_CLASSPATH_PATH
           
static java.lang.String PATH_PROPERTY
           
static java.lang.String PWD_PROPERTY
           
static java.lang.String SHELL_LEVEL_PROPERTY
           
static java.lang.String USER_PROPERTY
           
 
Fields inherited from class edu.nmu.os.shell.Shell
DEFAULT_PROMPT, GET_ERR_PERMISSION, GET_IN_PERMISSION, GET_OUT_PERMISSION, GET_PARENT_SHELL_PERMISSION, SET_SECURITY_MANAGER_PERMISSION
 
Constructor Summary
protected ShellImpl(Shell s)
           
 
Method Summary
protected  void doHelp()
          Used as an alternate run mode for the Shell
protected  void exitMessage(java.lang.String s)
          Handles an exit message to be given just before the Shell exits
protected  CommandLine getCommandLine()
          Gets the next CommandLine to be executed
protected  java.io.PrintStream getErr0()
          Returns the error PrintStream of this Shell
protected  java.io.InputStream getIn0()
          Returns the InputStream of this Shell
protected  java.util.Properties getInitialEnv()
          Returns the initial values of environment variable as they should be set if this Shell has no parent
protected  java.io.PrintStream getOut0()
          Returns the output PrintStream of this Shell
 java.lang.String getPrompt()
          The user prompt
 void handleThrowable(java.lang.Throwable t)
          Handles the given Throwable
protected  void handleUnresolved(java.lang.String[] unresolved)
          Handles a list of unresolved programs
 boolean isUser()
          Returns whether or not the user is typing commands into this Shell
protected  boolean shouldDoHelp()
          Returns true if the Shell should run the doHelp() instead of running normally
 
Methods inherited from class edu.nmu.os.shell.Shell
executeCommand, executeCommandLine, getEnv, getEnv, getEnv, getEnv0, getEnv0, getEnv0, getErr, getIn, getOut, getParentShell, getSecurityManager, getShell, getShellLevel, isRunning, main, run, setEnv, setEnv, setEnv0, setEnv0, setSecurityManager, setSecurityManager0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHELL_LEVEL_PROPERTY

public static final java.lang.String SHELL_LEVEL_PROPERTY
See Also:
Constant Field Values

USER_PROPERTY

public static final java.lang.String USER_PROPERTY
See Also:
Constant Field Values

PWD_PROPERTY

public static final java.lang.String PWD_PROPERTY
See Also:
Constant Field Values

PATH_PROPERTY

public static final java.lang.String PATH_PROPERTY
See Also:
Constant Field Values

CLASSPATH_PWD_PROPERTY

public static final java.lang.String CLASSPATH_PWD_PROPERTY
See Also:
Constant Field Values

CLASSPATH_PATH_PROPERTY

public static final java.lang.String CLASSPATH_PATH_PROPERTY
See Also:
Constant Field Values

DEFAULT_CLASSPATH_PATH

public static final java.lang.String DEFAULT_CLASSPATH_PATH
See Also:
Constant Field Values
Constructor Detail

ShellImpl

protected ShellImpl(Shell s)
Method Detail

shouldDoHelp

protected boolean shouldDoHelp()
Description copied from class: Shell
Returns true if the Shell should run the Shell.doHelp() instead of running normally

This method is used by Shell.main(String[])

Specified by:
shouldDoHelp in class Shell
Returns:
true if the Shell should run the Shell.doHelp(), false if it should run normally

doHelp

protected void doHelp()
Description copied from class: Shell
Used as an alternate run mode for the Shell

It is expected that this method would print some sort of help screen to the user, though that is not the required behavior.

Specified by:
doHelp in class Shell
See Also:
Shell.shouldDoHelp()

handleThrowable

public void handleThrowable(java.lang.Throwable t)
Description copied from class: Shell
Handles the given Throwable

This method handles the given Throwable in an implementation specific manner.

Specified by:
handleThrowable in class Shell
Parameters:
t - the Throwable

handleUnresolved

protected void handleUnresolved(java.lang.String[] unresolved)
Description copied from class: Shell
Handles a list of unresolved programs

This method is called when the Shell is running and the CommandLine produces unresolved programs

Specified by:
handleUnresolved in class Shell
Parameters:
unresolved - the unresolved program names

exitMessage

protected void exitMessage(java.lang.String s)
Description copied from class: Shell
Handles an exit message to be given just before the Shell exits

This method is only called during abnormal exit.

Specified by:
exitMessage in class Shell
Parameters:
s - the exit message to be handled

getInitialEnv

protected java.util.Properties getInitialEnv()
Description copied from class: Shell
Returns the initial values of environment variable as they should be set if this Shell has no parent

This method is called by the Shell.Shell(Shell) constructor to set the default environment variables of the Shell if its parent is null

Specified by:
getInitialEnv in class Shell
Returns:
the environment variables

getCommandLine

protected CommandLine getCommandLine()
                              throws ShellException
Description copied from class: Shell
Gets the next CommandLine to be executed

This method should never return null. If there are no CommandLines available, this method should either hang while it waits or throw a ShellException.

Specified by:
getCommandLine in class Shell
Returns:
the next CommandLine
Throws:
ShellException - if an error occurs

getOut0

protected java.io.PrintStream getOut0()
Description copied from class: Shell
Returns the output PrintStream of this Shell

Specified by:
getOut0 in class Shell
Returns:
the output PrintStream

getErr0

protected java.io.PrintStream getErr0()
Description copied from class: Shell
Returns the error PrintStream of this Shell

Specified by:
getErr0 in class Shell
Returns:
the error PrintStream

getIn0

protected java.io.InputStream getIn0()
Description copied from class: Shell
Returns the InputStream of this Shell

Specified by:
getIn0 in class Shell
Returns:
the InputStream

getPrompt

public java.lang.String getPrompt()
Description copied from class: Shell
The user prompt

The default implemention returns Shell.DEFAULT_PROMPT.

Overrides:
getPrompt in class Shell
Returns:
the user prompt that should be displayed while waiting for a CommandLine to be entered

isUser

public boolean isUser()
Description copied from class: Shell
Returns whether or not the user is typing commands into this Shell

Specified by:
isUser in class Shell
Returns:
true if this Shell's actor is the user, false otherwise