All Packages Class Hierarchy This Package Previous Next Index
Class com.cometway.jerminal.Jerminal
java.lang.Object
|
+----com.cometway.jerminal.Jerminal
- public class Jerminal
- extends Object
- implements Runnable
The Jerminal. This class contains the parse, the interpreter, and the necessary session
variables that tracks the state of a session.
-
cachedCommands
- This is the Hashtable of cached commands.
-
classAliases
- This is the Hashtable which tracks the classname aliases set by the aliasClass command
-
commandHistory
- This is the Vector which contains this sessions command history
-
stopRunning
- Setting this to true will cause the Jerminal to stop accepting commands and its thread to stop.
-
Jerminal(InputStream, OutputStream, Props, boolean, boolean)
- This instantiates and initializes a Jerminal.
-
allowBinaryAccess()
-
-
allowFileAccess()
-
-
error(String, Exception)
- This prints error messages to System.err as well as the Jerminal if the
'print_errors' jerminal environment variable exists.
-
evaluate(String)
- This method evaluates a command string.
-
getAliasedClass(String)
- This method takes a String alias and unaliases it to the Classname.
-
getHistoryCommand(String)
- This method takes a String pattern and matches it with all the commands in the command history.
-
getInputStream()
-
-
getOutputStream()
-
-
getProps()
- This method returns the Props object which holds all the environment variables.
-
initProps()
- This initializes the default evironment variables.
-
main(String[])
-
-
parseArgs(String)
- This method is responsible for parsing a String of arguments and making evaluations
based on the syntax.
-
print(String)
- This prints messages to the System.out as well as the Jerminal if the
'verbose' jerminal environment variable variable exists.
-
prompt()
- This method prints a prompt and performs the necesary maintenance on the session
and the prompt.
-
run()
- This method is the prompt/read/evaluate cycle of the Jerminal interpreter.
-
start()
- This starts the Jerminal on its own Thread of execution.
stopRunning
public boolean stopRunning
- Setting this to true will cause the Jerminal to stop accepting commands and its thread to stop.
cachedCommands
public Hashtable cachedCommands
- This is the Hashtable of cached commands. This Hashtable can be cleared by the rehash command.
commandHistory
public Vector commandHistory
- This is the Vector which contains this sessions command history
classAliases
public Hashtable classAliases
- This is the Hashtable which tracks the classname aliases set by the aliasClass command
Jerminal
public Jerminal(InputStream in,
OutputStream out,
Props p,
boolean allowFileAccess,
boolean allowBinaryAccess)
- This instantiates and initializes a Jerminal.
- Parameters:
- in - The InputStream which the Jerminal is to read its commands from
- out - The OutputStream which the Jerminal is to write the results to.
- p - The Props Object which will hold all the environment variables.
- allowFileAccess - If set to FALSE, file access is denied in this session.
- allowBinaryAccess - If set to FALSE, access to binaries on the local system is denied in this session.
getProps
public Props getProps()
- This method returns the Props object which holds all the environment variables.
- Returns:
- The Props object which contains all the environment variables of the current session.
start
public void start()
- This starts the Jerminal on its own Thread of execution.
initProps
public void initProps()
- This initializes the default evironment variables.
run
public void run()
- This method is the prompt/read/evaluate cycle of the Jerminal interpreter.
getHistoryCommand
public String getHistoryCommand(String s)
- This method takes a String pattern and matches it with all the commands in the command history.
- Parameters:
- s - This is the pattern which to match the commands. If blank or null, the most recent command is returned
- Returns:
- Returns the most recent command that starts with the String parameter.
getAliasedClass
public String getAliasedClass(String alias)
- This method takes a String alias and unaliases it to the Classname.
- Parameters:
- alias - This is the alias of the classname set by the aliasClass command
- Returns:
- Returns the class name which is aliased by the [alias] parameter.
allowFileAccess
public boolean allowFileAccess()
- Returns:
- Returns whether file access is allowed in this session of the Jerminal
allowBinaryAccess
public boolean allowBinaryAccess()
- Returns:
- Returns whether binary access is allowed in this session of the Jerminal
getOutputStream
public OutputStream getOutputStream()
- Returns:
- Returns the OutputStream which this Jerminal session is writing its results to.
getInputStream
public InputStream getInputStream()
- Returns:
- Returns the InputStream which this Jerminal session is reading its commands from.
prompt
protected void prompt()
- This method prints a prompt and performs the necesary maintenance on the session
and the prompt. The prompt can have the appropriate codes: '@c'= the session counter,
'@t'= current time (am/pm), '@T'= current time military, '@D'= current working directory
as the full path, '@d'= current working directory with home replaced with ~
evaluate
public Object evaluate(String command)
- This method evaluates a command string. The syntax is [operator] [operands]...
The operands can be evaluated using the '%' character. The result of the evaluation
is returned as an Object. The operators are classnames in the 'command_prefix_list'
variable. By default, the com.cometway.jerminal.commands package is automatically
added to this list. If the given command is not found and binaries access is allowed,
this method will attempt to execute the binary denoted by the command.
- Parameters:
- command - The Command String that needs to be evaluated.
- Returns:
- Returns the result of that evaluation, or the result of the 'evaluate' method call on the command class.
parseArgs
protected Vector parseArgs(String args)
- This method is responsible for parsing a String of arguments and making evaluations
based on the syntax. The reserved characters are '\'=escape character, '$'=evaluate
environment variable, '%'=evaluate the string, '"'=quote groups of arguments, '('=
start of a simple type cast, ')'=ending the cast, and whitespace which is used to delimit
the operand and the operators.
- Parameters:
- args - This is the String of arguments that need to be parsed
- Returns:
- returns a Vector of argument Objects.
print
public void print(String s)
- This prints messages to the System.out as well as the Jerminal if the
'verbose' jerminal environment variable variable exists.
error
public void error(String s,
Exception e)
- This prints error messages to System.err as well as the Jerminal if the
'print_errors' jerminal environment variable exists.
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index