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.


Variable Index

 o cachedCommands
This is the Hashtable of cached commands.
 o classAliases
This is the Hashtable which tracks the classname aliases set by the aliasClass command
 o commandHistory
This is the Vector which contains this sessions command history
 o listeners
This is the Vector of JerminalListenerInterface listening to this session.
 o stopRunning
Setting this to true will cause the JerminalSession to stop accepting commands and its thread to stop.

Constructor Index

 o JerminalSession(InputStream, OutputStream, Props, boolean, boolean)
This instantiates and initializes a JerminalSession.
 o JerminalSession(InputStream, OutputStream, Props, boolean, boolean, boolean)
This instantiates and initializes a JerminalSession.

Method Index

 o addListener(JerminalListenerInterface)
This adds a JerminalListener to this JerminalSession
 o allowBinaryAccess()
 o allowFileAccess()
 o commaToVector(String)
 o error(String, Exception)
This prints error messages to System.err as well as the JerminalSession if the 'print_errors' jerminal environment variable exists.
 o evaluate(String)
This method evaluates a command string.
 o getAliasedClass(String)
This method takes a String alias and unaliases it to the Classname.
 o getHistoryCommand(String)
This method takes a String pattern and matches it with all the commands in the command history.
 o getInputStream()
 o getOutputStream()
 o getProps()
This method returns the Props object which holds all the environment variables.
 o initProps()
This initializes the default evironment variables.
 o main(String[])
 o parseArgs(String)
This method is responsible for parsing a String of arguments and making evaluations based on the syntax.
 o print(String)
This prints messages to the System.out as well as the JerminalSession if the 'verbose' jerminal environment variable variable exists.
 o prompt()
This method prints a prompt and performs the necesary maintenance on the session and the prompt.
 o removeListener(JerminalListenerInterface)
This removes a JerminalListener.
 o run()
This method is the prompt/read/evaluate cycle of the JerminalSession interpreter.
 o start()
This starts the JerminalSession on its own Thread of execution.

Variables

 o stopRunning
 public boolean stopRunning
Setting this to true will cause the JerminalSession to stop accepting commands and its thread to stop.

 o cachedCommands
 public Hashtable cachedCommands
This is the Hashtable of cached commands. This Hashtable can be cleared by the rehash command.

 o commandHistory
 public Vector commandHistory
This is the Vector which contains this sessions command history

 o classAliases
 public Hashtable classAliases
This is the Hashtable which tracks the classname aliases set by the aliasClass command

 o listeners
 public Vector listeners
This is the Vector of JerminalListenerInterface listening to this session.

Constructors

 o 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.
 o 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.

Methods

 o addListener
 public void addListener(JerminalListenerInterface listener)
This adds a JerminalListener to this JerminalSession

 o removeListener
 public void removeListener(JerminalListenerInterface listener)
This removes a JerminalListener.

 o 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.
 o start
 public void start()
This starts the JerminalSession on its own Thread of execution.

 o initProps
 public void initProps()
This initializes the default evironment variables.

 o run
 public void run()
This method is the prompt/read/evaluate cycle of the JerminalSession interpreter.

 o 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.
 o 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.
 o allowFileAccess
 public boolean allowFileAccess()
Returns:
Returns whether file access is allowed in this session of the Jerminal
 o allowBinaryAccess
 public boolean allowBinaryAccess()
Returns:
Returns whether binary access is allowed in this session of the Jerminal
 o getOutputStream
 public OutputStream getOutputStream()
Returns:
Returns the OutputStream which this Jerminal session is writing its results to.
 o getInputStream
 public InputStream getInputStream()
Returns:
Returns the InputStream which this Jerminal session is reading its commands from.
 o 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 ~

 o 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.
 o 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.
 o 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.

 o 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.

 o commaToVector
 public static Vector commaToVector(String in)
 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index