com.rubecula.util
Interface MillInterface

All Superinterfaces:
Auditable, Identifiable, Lookupable
All Known Implementing Classes:
Mill

public interface MillInterface
extends Auditable, Lookupable

This interface defines the operations supported by a "Mill".

Since:
V_0_3 (Was called Millable - that name used for a different interface now).
Version:
$Revision: 1.3 $ // TODO consider referencing the Operator class here (which would entail moving Operator into util package).
Author:
Robin Hillyard

Method Summary
 void addConstants(Lookupable table)
          MUTATING method to add a table of constants.
 int getAdy(java.lang.String operator)
          This method returns the number of presentables needed to be popped off the stack for an operation.
 AlphabeticalMap getOperations()
          Method to get a map which represents the supported functions of this Mill.
 void help(java.io.PrintStream output)
          This method outputs help information listing and describing the various operations supported by the mill.
 java.lang.String lookupOperator(java.lang.String description)
          This method returns the name of an operator whose description matches the string description in some way.
 void operate(java.lang.String operator)
          Mutating method to apply the operation operator to the stack.
 java.lang.Object pop()
          Mutating method to remove an operand from the top of the Mill stack.
 void push(Presentable operand)
          Mutating method to push operand onto the top of the Mill stack.
 void setValue(java.lang.String name, Presentable value)
          Method to set a value which can later be retrieved using the name given (using the method defined by the Lookupable interface).
 int size()
          Get the current depth of the stack.
 
Methods inherited from interface com.rubecula.util.Auditable
audit, audit, audit
 
Methods inherited from interface com.rubecula.util.Identifiable
getIdentifier
 
Methods inherited from interface com.rubecula.util.Lookupable
getKeys, getValue
 

Method Detail

pop

public java.lang.Object pop()
                     throws java.util.EmptyStackException
Mutating method to remove an operand from the top of the Mill stack.

Returns:
the erstwhile top element on the stack, as an object, but in fact it will always be in the form of a Presentable.
Throws:
java.util.EmptyStackException

push

public void push(Presentable operand)
          throws MillException
Mutating method to push operand onto the top of the Mill stack.

Parameters:
operand - a presentable object which will displace the former top of the stack to the second position and itself become the top object.
Throws:
MillException

operate

public void operate(java.lang.String operator)
             throws java.util.EmptyStackException,
                    MillException
Mutating method to apply the operation operator to the stack. The number of items required on the stack prior to the operation and the number of items left on the stack afterwards depends upon the operation.

Parameters:
operator - the name for the operation. Different Mills will naturally support different operations.
Throws:
java.util.EmptyStackException
MillException

size

public int size()
Get the current depth of the stack.

Returns:
the size of the stack (i.e. number of entries).

setValue

public void setValue(java.lang.String name,
                     Presentable value)
              throws MillException
Method to set a value which can later be retrieved using the name given (using the method defined by the Lookupable interface). A memory value can be unset by setting to the null value. Names which appear in the constants list cannot be reused.

Parameters:
name - the name or key by which this value can be retrieved.
value - a Presentable value which is lookupable.
Throws:
MillException - if memory slot name cannot be set to value, because the name is already in use (or an attempt to remove a constant).

getOperations

public AlphabeticalMap getOperations()
Method to get a map which represents the supported functions of this Mill. The keys are the operators (typically abbreviations, all lower case) and the entries are the full mathematical function names (all lower case).

Returns:
a map of the abbreviation-function mappings for the supported operations of this mill.

getAdy

public int getAdy(java.lang.String operator)
           throws MillException
This method returns the number of presentables needed to be popped off the stack for an operation.

Parameters:
operator - the name (abbreviation) of the operator.
Returns:
0, 1 or 2 for an-, mon- or dy-adic operators.
Throws:
MillException - operator is not supported.

lookupOperator

public java.lang.String lookupOperator(java.lang.String description)
                                throws MillException
This method returns the name of an operator whose description matches the string description in some way.

Parameters:
description - the mathematical name or description of the operator.
Returns:
the name of the operator, or null if no match found.
Throws:
MillException - more than one operator matched.

help

public void help(java.io.PrintStream output)
This method outputs help information listing and describing the various operations supported by the mill.

Parameters:
output - an output stream.

addConstants

public void addConstants(Lookupable table)
MUTATING method to add a table of constants. All entries in the table are Presentables.

Parameters:
table - the set of constants to be added.