All Packages Class Hierarchy This Package Previous Next Index
Class com.cometway.jerminal.JerminalSession
com.cometway.jerminal.JerminalSession
- public class JerminalSession
The JerminalSession. 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
-
listeners
- This is the Vector of JerminalListenerInterface listening to this session.
-
stopRunning
- Setting this to true will cause the JerminalSession to stop accepting commands and its thread to stop.
-
JerminalSession(InputStream, OutputStream, Props, boolean, boolean)
- This instantiates and initializes a JerminalSession.
-
JerminalSession(InputStream, OutputStream, Props, boolean, boolean, boolean)
- This instantiates and initializes a JerminalSession.
-
addListener(JerminalListenerInterface)
- This adds a JerminalListener to this JerminalSession
-
allowBinaryAccess()
-
-
allowFileAccess()
-
-
commaToVector(String)
-
-
error(String, Exception)
- This prints error messages to System.err as well as the JerminalSession 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 JerminalSession 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.
-
removeListener(JerminalListenerInterface)
- This removes a JerminalListener.
-
run()
- This method is the prompt/read/evaluate cycle of the JerminalSession interpreter.
-
start()
- This starts the JerminalSession on its own Thread of execution.
stopRunning
public boolean stopRunning
- Setting this to true will cause the JerminalSession 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
listeners
public Vector listeners
- This is the Vector of JerminalListenerInterface listening to this session.
JerminalSession
public JerminalSession(InputStream in,
OutputStream out,
Props p,
boolean allowFileAccess,
boolean allowBinaryAccess)
- This instantiates and initializes a JerminalSession.
- Parameters:
- in - The InputStream which the JerminalSession is to read its commands from
- out - The OutputStream which the JerminalSession 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.
JerminalSession
public JerminalSession(InputStream in,
OutputStream out,
Props p,
boolean allowFileAccess,
boolean allowBinaryAccess,
boolean allowStreamAccess)
- This instantiates and initializes a JerminalSession.
- Parameters:
- in - The InputStream which the JerminalSession is to read its commands from
- out - The OutputStream which the JerminalSession 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.
- allowStreamAccess - If set to TRUE, the io streams will be handed off to the processes that are spawned.
addListener
public void addListener(JerminalListenerInterface listener)
- This adds a JerminalListener to this JerminalSession
removeListener
public void removeListener(JerminalListenerInterface listener)
- This removes a JerminalListener.
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 JerminalSession 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 JerminalSession 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 JerminalSession 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 JerminalSession if the
'print_errors' jerminal environment variable exists.
commaToVector
public static Vector commaToVector(String in)
main
public static void main(String args[])
All Packages Class Hierarchy This Package Previous Next Index