jpiv2
Class CmdInterpreter

java.lang.Object
  extended by jpiv2.CmdInterpreter

public class CmdInterpreter
extends java.lang.Object

Executes external applications, shell commands, and interpretes javacode. The utilized class bsh.Interpreter() is part of the BeanShell project by Pat Niemeyer. For more information about BeanShell see: http://www.beanshell.org


Field Summary
static int TYPE_APPLICATION
          The command is an external application.
static int TYPE_BSHFILE
          The command is a file containing java code.
static int TYPE_JAVACODE
          The command is inline java code.
static int TYPE_SHELLCOMMAND
          The command will be executed in a system dependent shell.
 
Constructor Summary
CmdInterpreter(JPiv jpiv, java.lang.String handleName)
          Creates a new instance of a java2.CmdInterpreter.
 
Method Summary
 void clearBshNamespace()
          Clears all Bean Shell variables.
 void execute(java.lang.String[] command, int type)
          Executes a command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_APPLICATION

public static final int TYPE_APPLICATION
The command is an external application.

See Also:
Constant Field Values

TYPE_SHELLCOMMAND

public static final int TYPE_SHELLCOMMAND
The command will be executed in a system dependent shell.

See Also:
Constant Field Values

TYPE_JAVACODE

public static final int TYPE_JAVACODE
The command is inline java code.

See Also:
Constant Field Values

TYPE_BSHFILE

public static final int TYPE_BSHFILE
The command is a file containing java code.

See Also:
Constant Field Values
Constructor Detail

CmdInterpreter

public CmdInterpreter(JPiv jpiv,
                      java.lang.String handleName)
Creates a new instance of a java2.CmdInterpreter. The java2.CmdInterpreter starts applications, executes native console commands and interpretes java code. For interpreting java code the bsh.eval(String str) method of the bsh package (BeanShell) is used. Methods of an already constructed instance of a jpiv2.JPiv class can be referred to in a script or command via the automatically generated handle with the name handleName. Use the get... methods of the jpiv2.JPiv object to get handles to other objects. e.g. myHandle = handleName.getSettingsFrame();

Parameters:
jpiv - The jpiv2.JPiv object which methods you would like to use.
handleName - The name via that you would like to refere to the jpiv2.JPiv object.
Method Detail

execute

public void execute(java.lang.String[] command,
                    int type)
Executes a command. The command and its parameters (or the filename containing a bsh-script) are given as elements of an array. If javacode is or a bsh-script file given, only the first array element (index 0) is taken.

Parameters:
command - An array containing a command string and parameters or the name of a bsh-script file.
type - A constant. The constant specifies wether the command is executed directly, within an operating-system-specific shell or by the BeanShell java interpreter.

clearBshNamespace

public void clearBshNamespace()
Clears all Bean Shell variables.