csheets.core.formula
Class BinaryOperation

java.lang.Object
  extended by csheets.core.formula.Operation<BinaryOperator>
      extended by csheets.core.formula.BinaryOperation
All Implemented Interfaces:
Expression, Serializable
Direct Known Subclasses:
ReferenceOperation

public class BinaryOperation
extends Operation<BinaryOperator>

A binary operation in a formula.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class csheets.core.formula.Operation
operator
 
Constructor Summary
BinaryOperation(Expression leftOperand, BinaryOperator operator, Expression rightOperand)
          Creates a new binary operation.
 
Method Summary
 Object accept(ExpressionVisitor visitor)
          Accepts to visit the given expression visitor.
 Value evaluate()
          Evaluates the expression and returns the result.
 Expression getLeftOperand()
          Returns the left(first) operand.
 Expression getRightOperand()
          Returns the right(second) operand.
 String toString()
           
 
Methods inherited from class csheets.core.formula.Operation
getOperator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryOperation

public BinaryOperation(Expression leftOperand,
                       BinaryOperator operator,
                       Expression rightOperand)
Creates a new binary operation.

Parameters:
leftOperand - the left(first) operand
operator - the binary operator
rightOperand - the right(second) operand
Method Detail

evaluate

public Value evaluate()
               throws IllegalValueTypeException
Description copied from interface: Expression
Evaluates the expression and returns the result.

Returns:
the result of the evaluation
Throws:
IllegalValueTypeException - if a value of an unexpected type was encountered when evaluating the expression

getLeftOperand

public Expression getLeftOperand()
Returns the left(first) operand.

Returns:
an expression tree representing the operand

getRightOperand

public Expression getRightOperand()
Returns the right(second) operand.

Returns:
an expression tree representing the operand

accept

public Object accept(ExpressionVisitor visitor)
Description copied from interface: Expression
Accepts to visit the given expression visitor.

Parameters:
visitor - the visitor

toString

public String toString()
Overrides:
toString in class Object