csheets.ext.assertion
Class AssertionArithmeticVisitor

java.lang.Object
  extended by csheets.ext.assertion.AssertionArithmeticVisitor
All Implemented Interfaces:
ExpressionVisitor

public class AssertionArithmeticVisitor
extends Object
implements ExpressionVisitor

A Visitor for calculating System Generated assertions for a formula in the form of an Expression tree.


Constructor Summary
AssertionArithmeticVisitor()
          Constructs a new AssertionArithmeticVisitor.
 
Method Summary
 MultiInterval getResult(Expression expression)
          Retrieve the result of the arithmetic calculations performed by this visitor.
 Object visitBinaryOperation(BinaryOperation operation)
          Visits the given binary expression.
 Object visitFunctionCall(FunctionCall call)
          Visits the given function call.
 Object visitLiteral(Literal literal)
          Visits the given literal.
 Object visitReference(Reference reference)
          Visits the given cell reference.
 Object visitUnaryOperation(UnaryOperation operation)
          Visits the given unary expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertionArithmeticVisitor

public AssertionArithmeticVisitor()
Constructs a new AssertionArithmeticVisitor.

Method Detail

getResult

public MultiInterval getResult(Expression expression)
                        throws AssertionArithmeticException,
                               MathException
Retrieve the result of the arithmetic calculations performed by this visitor.

NOTE! This function should only be called after the visitor has been used to traverse some Expression tree (by calling Expression.accept() passing this visitor as an argument. Otherwise an exception will be thrown.

Parameters:
expression - the expression from which the
Returns:
The resulting interval from the performed calculations.
Throws:
AssertionArithmeticException - if no result has been calculated yet, or if the calculations resulted in more than one result. (Indicates an error in the formula).
MathException

visitBinaryOperation

public Object visitBinaryOperation(BinaryOperation operation)
                            throws AssertionArithmeticException,
                                   MathException
Description copied from interface: ExpressionVisitor
Visits the given binary expression.

Specified by:
visitBinaryOperation in interface ExpressionVisitor
Parameters:
operation - the operation to visit
Returns:
an arbitrary object
Throws:
AssertionArithmeticException
MathException

visitFunctionCall

public Object visitFunctionCall(FunctionCall call)
                         throws AssertionArithmeticException
Description copied from interface: ExpressionVisitor
Visits the given function call.

Specified by:
visitFunctionCall in interface ExpressionVisitor
Parameters:
call - the function call to visit
Returns:
an arbitrary object
Throws:
AssertionArithmeticException

visitLiteral

public Object visitLiteral(Literal literal)
                    throws AssertionArithmeticException
Description copied from interface: ExpressionVisitor
Visits the given literal.

Specified by:
visitLiteral in interface ExpressionVisitor
Parameters:
literal - the literal to visit
Returns:
an arbitrary object
Throws:
AssertionArithmeticException

visitReference

public Object visitReference(Reference reference)
                      throws AssertionArithmeticException
Description copied from interface: ExpressionVisitor
Visits the given cell reference.

Specified by:
visitReference in interface ExpressionVisitor
Parameters:
reference - the reference to visit
Returns:
an arbitrary object
Throws:
AssertionArithmeticException

visitUnaryOperation

public Object visitUnaryOperation(UnaryOperation operation)
                           throws AssertionArithmeticException
Description copied from interface: ExpressionVisitor
Visits the given unary expression.

Specified by:
visitUnaryOperation in interface ExpressionVisitor
Parameters:
operation - the operation to visit
Returns:
an arbitrary object
Throws:
AssertionArithmeticException