anl.aida.formula
Class DefaultParser

java.lang.Object
  extended by anl.aida.formula.DefaultParser
All Implemented Interfaces:
FormulaParser

public class DefaultParser
extends java.lang.Object
implements FormulaParser

Version:
$Revision$ $Date$

Field Summary
private  java.lang.String formula
           
private  Frame frame
           
private  Parser parser
           
private  ASTTreeInfo treeInfo
           
 
Constructor Summary
DefaultParser(java.lang.String formula, Frame frame)
           
 
Method Summary
 FormulaArray evaluate()
          Evaluates the formula and returns the result as a FormulaArray.
 java.lang.String getFormulaAsString()
          Gets the String representation of the formula.
 ASTTreeInfo parse()
          Parses the formula and returns information about the parse tree.
private  void preprocess()
           
 void setCoodinateIndices(int timeStep, int layer, int x, int y)
          Sets the coordinate indices under which the next evaluation will take place.
 void setVariable(java.lang.String name, DataFrame value)
          Sets the value of the variable to the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formula

private java.lang.String formula

parser

private Parser parser

frame

private Frame frame

treeInfo

private ASTTreeInfo treeInfo
Constructor Detail

DefaultParser

public DefaultParser(java.lang.String formula,
                     Frame frame)
Method Detail

preprocess

private void preprocess()
                 throws IllegalFormulaException
Throws:
IllegalFormulaException

setVariable

public void setVariable(java.lang.String name,
                        DataFrame value)
Sets the value of the variable to the specified array.

Specified by:
setVariable in interface FormulaParser
Parameters:
name - the name of the variable
value - the array value

evaluate

public FormulaArray evaluate()
                      throws IllegalFormulaException
Evaluates the formula and returns the result as a FormulaArray.

Specified by:
evaluate in interface FormulaParser
Returns:
the result of the evaluation
Throws:
IllegalFormulaException - if the formula is invalid

getFormulaAsString

public java.lang.String getFormulaAsString()
Description copied from interface: FormulaParser
Gets the String representation of the formula.

Specified by:
getFormulaAsString in interface FormulaParser
Returns:
the String representation of the formula.

parse

public ASTTreeInfo parse()
                  throws IllegalFormulaException
Description copied from interface: FormulaParser
Parses the formula and returns information about the parse tree.

Specified by:
parse in interface FormulaParser
Returns:
returns information about the parse tree.
Throws:
IllegalFormulaException - if there is an error during parsing.

setCoodinateIndices

public void setCoodinateIndices(int timeStep,
                                int layer,
                                int x,
                                int y)
Sets the coordinate indices under which the next evaluation will take place.

Specified by:
setCoodinateIndices in interface FormulaParser
Parameters:
timeStep - the time step index
layer - the layer index
x - the x index
y - the y index