jfun.jaskell.shell
Class ShellImpl

java.lang.Object
  extended by jfun.jaskell.shell.ShellImpl

public class ShellImpl
extends java.lang.Object

Implementation of shell functionality parameterized with Jaskell runtime so that this can be used for any different runtime configuration.

Author:
Ben Yu Jan 25, 2006 10:41:09 AM

Constructor Summary
ShellImpl()
          To create a ShellImpl object.
ShellImpl(Jaskell runtime, java.lang.String greeting)
          To create a ShellImpl object.
 
Method Summary
 java.lang.String getGreeting()
          Get the greeting text.
 Jaskell getRuntime()
          Get the Jaskell runtime used to evaluate expressions.
protected  java.lang.Object getUserVariable(java.lang.String name)
          Get the value of a user defined variable.
protected  int getUserVariableCount()
          To get the number of variables defined by user.
protected  java.lang.String[] getUserVariableNames()
          Get the user variable names.
protected  boolean hasUserVariable(java.lang.String name)
          To determine if a certain variable is defined by user.
 void interaction()
          Interpret commands and expressions interactively.
protected  void onExit()
          called when the shell exits.
protected  void onStartup()
          Called when the shell starts up.
 void runShell(java.lang.String[] args)
          Run the shell using an array of command line arguments.
 void setGreeting(java.lang.String greeting)
          To set the greeting message.
 void setRuntime(Jaskell runtime)
          To set the Jaskell runtime used by the shell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShellImpl

public ShellImpl(Jaskell runtime,
                 java.lang.String greeting)
To create a ShellImpl object.

Parameters:
runtime - the Jaskell runtime object.
greeting - the greeting message when shell starts up.

ShellImpl

public ShellImpl()
To create a ShellImpl object.

setRuntime(Jaskell) will need to be called before the shell is started up.

Method Detail

runShell

public void runShell(java.lang.String[] args)
Run the shell using an array of command line arguments.

If one argument is provided, it is treated as a file name and the file is interpreted, otherwise, commands are interpreted interactively/

Parameters:
args - the command line arguments.

getUserVariable

protected java.lang.Object getUserVariable(java.lang.String name)
Get the value of a user defined variable.

Parameters:
name - the variable name.
Returns:
the value. null is returned if no user variable is defined under this name.

hasUserVariable

protected boolean hasUserVariable(java.lang.String name)
To determine if a certain variable is defined by user.

Parameters:
name - the variable name.
Returns:
true if the variable is defined by user.

getUserVariableCount

protected int getUserVariableCount()
To get the number of variables defined by user.


getUserVariableNames

protected java.lang.String[] getUserVariableNames()
Get the user variable names.


interaction

public void interaction()
Interpret commands and expressions interactively.


getGreeting

public java.lang.String getGreeting()
Get the greeting text.


getRuntime

public Jaskell getRuntime()
Get the Jaskell runtime used to evaluate expressions.


setRuntime

public void setRuntime(Jaskell runtime)
To set the Jaskell runtime used by the shell.

Parameters:
runtime - the jaskell runtime to use.

setGreeting

public void setGreeting(java.lang.String greeting)
To set the greeting message. used by the shell.

Parameters:
greeting - the greeting message.

onExit

protected void onExit()
called when the shell exits.


onStartup

protected void onStartup()
Called when the shell starts up.