org.hecl
Class Operator

java.lang.Object
  extended by org.hecl.Operator
All Implemented Interfaces:
Command
Direct Known Subclasses:
FileCmds, MathCmds, MidletCmd, RMSCmd

public abstract class Operator
extends java.lang.Object
implements Command

The Operator class implements a number of features that are used in the creation of groups of commands, such as those found in InterpCmds, ListCmds, and so on.

Version:
1.0
Author:
David N. Welton

Field Summary
protected  int cmdcode
          cmdcode - the int that corresponds to the command to be executed.
protected  int maxargs
          maxargs - the maximum number of arguments this command accepts.
protected  int minargs
          minargs - the minimum number of arguments this command accepts.
 
Constructor Summary
protected Operator(int cmdcode, int minargs, int maxargs)
          Creates a new Operator instance.
 
Method Summary
 Thing cmdCode(Interp interp, Thing[] argv)
          The cmdCode method dispatches to the actual code via the operate method and cmdcode argument.
protected static void load(Interp ip, java.util.Hashtable cmdtable)
          The load method loads the commands in a class that extends Operator.
abstract  Thing operate(int cmdcode, Interp interp, Thing[] argv)
          The operate method dispatches to the actual code.
protected static void unload(Interp ip, java.util.Hashtable cmdtable)
          The unload method unloads the commands in a class that extends Operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmdcode

protected int cmdcode
cmdcode - the int that corresponds to the command to be executed.


minargs

protected int minargs
minargs - the minimum number of arguments this command accepts.


maxargs

protected int maxargs
maxargs - the maximum number of arguments this command accepts. A value of 0 means unlimited arguments.

Constructor Detail

Operator

protected Operator(int cmdcode,
                   int minargs,
                   int maxargs)
Creates a new Operator instance.

Parameters:
cmdcode - an int value corresponding to the command code number found in the class implementing the command.
minargs - an int value - the minimum number of arguments to the command.
maxargs - an int value - the maximum number of arguments to the command, or -1 if unlimited.
Method Detail

cmdCode

public Thing cmdCode(Interp interp,
                     Thing[] argv)
              throws HeclException
The cmdCode method dispatches to the actual code via the operate method and cmdcode argument.

Specified by:
cmdCode in interface Command
Parameters:
interp - an Interp value
argv - a Thing[] value
Returns:
The computed Thing, or null when no value has been computed.
Throws:
HeclException - if an error occurs

operate

public abstract Thing operate(int cmdcode,
                              Interp interp,
                              Thing[] argv)
                       throws HeclException
The operate method dispatches to the actual code.

Parameters:
cmdcode - an int value
interp - an Interp value
argv - a Thing[] value
Returns:
a Thing value, or null when no value has been
Throws:
HeclException - if an error occurs

load

protected static void load(Interp ip,
                           java.util.Hashtable cmdtable)
                    throws HeclException
The load method loads the commands in a class that extends Operator.

Parameters:
ip - an Interp value
Throws:
HeclException - if an error occurs

unload

protected static void unload(Interp ip,
                             java.util.Hashtable cmdtable)
                      throws HeclException
The unload method unloads the commands in a class that extends Operator.

Parameters:
ip - an Interp value
Throws:
HeclException - if an error occurs