shell
Class Environment

java.lang.Object
  |
  +--shell.Environment

public final class Environment
extends java.lang.Object

A thread that will create the commandline prompt for the user For example:

    Window win = new Window(parent);
    win.show();
 

See Also:
Terminal, ProcessController

Field Summary
static java.lang.String RUNTIME_COMMAND_PACKAGE
           
 
Method Summary
 void doCommand(java.lang.String cmd)
          Runs a command represented by the String passed into the method.
 void executeCommand(java.util.Vector cmd, java.lang.String strcmd)
          -------- Deprecated ------------ Use doCommand() instead.
 java.util.Hashtable getAllEnvironmentVariables()
          Returns a handle to the Environment object's envVariable Hashtable which contains all the current registered env variables.
 java.lang.Object[] getAutoComplete(java.lang.String toMatch)
          This method takes in a string, then compares all files in the current directory to the string, putting the matching names into an ArrayList.
 java.lang.Object[] getAutoComplete(java.lang.String location, java.lang.String toMatch)
          This method takes in two strings, one representing the location of the directory to list the contents of, the other is the text to match.
 java.io.File getCurrentLocation()
          Static method that allows objects within the shell to obtain the current working directory.
static Environment getEnvironment()
          This method returns the current single instance of the Environment object.
 java.lang.String getEnvironmentVariable(java.lang.String name)
          Takes in a string and checks if it is a valid environment variable.
 java.io.PrintStream getStandardOut()
          This method returns a handle to the current standard output stream.
 Terminal getTerminal()
          This method returns a handle to the current user Terminal object that was passed in as a parameter to the constructor.
 java.lang.String parseForEnvVariables(java.lang.String cmd)
           
protected  java.util.Vector processCommand(java.lang.String cmd)
          This method takes in a command as a parameter and breaks it down into a Vectora.
 void setCurrentLocation(java.io.File newLocation)
          Static method that allows objects within the shell to set the current working directory.
 void setEnvironmentVariable(java.lang.String key, java.lang.String value)
          Returns a handle to the Environment object's envVariable Hashtable which contains all the current registered env variables.
 void setStandardOut(java.io.PrintStream output)
          Sets the standard output stream for the environment to the method's only argument.
 void setTerminal(Terminal terminal)
          Sets the standard output stream for the environment to the method's only argument.
 void startRuntime(java.lang.String strcmd)
          -------- Deprecated ------------ Use doCommand() instead.
 void terminateCommand(java.lang.String msg)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RUNTIME_COMMAND_PACKAGE

public static java.lang.String RUNTIME_COMMAND_PACKAGE
Method Detail

getEnvironment

public static Environment getEnvironment()
This method returns the current single instance of the Environment object.

Returns:
the current Terminal object.
See Also:
Terminal

getStandardOut

public java.io.PrintStream getStandardOut()
This method returns a handle to the current standard output stream.

Returns:
the current standard output stream
See Also:
Terminal

setStandardOut

public void setStandardOut(java.io.PrintStream output)
Sets the standard output stream for the environment to the method's only argument.

Parameters:
output - - the new standard output stream

getTerminal

public Terminal getTerminal()
This method returns a handle to the current user Terminal object that was passed in as a parameter to the constructor.

Returns:
the current Terminal object.
See Also:
Terminal

setTerminal

public void setTerminal(Terminal terminal)
Sets the standard output stream for the environment to the method's only argument.


getCurrentLocation

public java.io.File getCurrentLocation()
Static method that allows objects within the shell to obtain the current working directory. It appears that the actual systems current working directory is not changeable without using Runtime.exec() or writing a C function and calling it through JNI.

Returns:
the present working directory.
See Also:
#setCurrentLocation()

setCurrentLocation

public void setCurrentLocation(java.io.File newLocation)
Static method that allows objects within the shell to set the current working directory.

Parameters:
newLocation - - the new present working directory.
Returns:
See Also:
getCurrentLocation()

getEnvironmentVariable

public java.lang.String getEnvironmentVariable(java.lang.String name)
Takes in a string and checks if it is a valid environment variable. If the name is found in the envVariables Hashtable then the String value of the name is returned.

Parameters:
name - - a string representation of the variable name to look for.
Returns:
Environment variable value that corresponds to the parameter.
See Also:
#setEnvironmentVariable(), getAllEnvironmentVariables()

getAllEnvironmentVariables

public java.util.Hashtable getAllEnvironmentVariables()
Returns a handle to the Environment object's envVariable Hashtable which contains all the current registered env variables.

Returns:
Hashtable of all the current environment variables.
See Also:
#setEnvironmentVariable(), #getEnvironmentVariable()

setEnvironmentVariable

public void setEnvironmentVariable(java.lang.String key,
                                   java.lang.String value)
Returns a handle to the Environment object's envVariable Hashtable which contains all the current registered env variables.

Parameters:
key - - key value of the environment variable, will be used as key for hashtable.
value - - value of the variable.
See Also:
getAllEnvironmentVariables(), #getEnvironmentVariable()

getAutoComplete

public java.lang.Object[] getAutoComplete(java.lang.String toMatch)
This method takes in a string, then compares all files in the current directory to the string, putting the matching names into an ArrayList. If the ArrayList contains more than one name, they are compared to see if they both have a common starting substring. If they do then the substring is returned.

Returns:
Object[] containing all the Objects that had matching values.
See Also:
getAutoComplete(String location, String toMatch), #matchFiles(String toMatch).

getAutoComplete

public java.lang.Object[] getAutoComplete(java.lang.String location,
                                          java.lang.String toMatch)
This method takes in two strings, one representing the location of the directory to list the contents of, the other is the text to match. It compares all files in the current directory to the string, putting the matching names into an ArrayList. If the ArrayList contains more than one name, they are compared to see if they both have a common starting substring. If they do then the substring is returned.

Parameters:
location - - location of the directory which is being checked.
Returns:
Object[] containing all the Objects that had matching values.
See Also:
getAutoComplete(String location, String toMatch), #matchFiles(String toMatch).

doCommand

public void doCommand(java.lang.String cmd)
Runs a command represented by the String passed into the method.

Parameters:
cmd - - the command to execute
See Also:
getAutoComplete(String location, String toMatch), #matchFiles(String toMatch).

processCommand

protected java.util.Vector processCommand(java.lang.String cmd)
This method takes in a command as a parameter and breaks it down into a Vectora. Environment variables which are shown by "?ENV_NAME?" are replaced with correct corresponding values.

Parameters:
cmd - - the command to be processed.
Returns:
Vector containing the command broken up into elements, 0 being the app to run.

parseForEnvVariables

public java.lang.String parseForEnvVariables(java.lang.String cmd)

startRuntime

public void startRuntime(java.lang.String strcmd)
-------- Deprecated ------------ Use doCommand() instead. Passes the strcmd command onto the Environment object's RuntimeProcessController.

Parameters:
strcmd - - the command to be processed.
Returns:
void.
See Also:
shell.RuntimeProcessController#command().

executeCommand

public void executeCommand(java.util.Vector cmd,
                           java.lang.String strcmd)
-------- Deprecated ------------ Use doCommand() instead. executeCommand() this will create and run the Threaded RuntimeCommand, passing the correct parameters as arguments.

Parameters:
cmd - - the command broken up into idividual elements.
strcmd - - the command to be processed.
Returns:
void.
See Also:
shell.ProcessController#command().

terminateCommand

public void terminateCommand(java.lang.String msg)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object