csheets.core.formula.lang
Class ReferenceOperation

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

public class ReferenceOperation
extends BinaryOperation
implements Reference

A binary reference operation in a formula.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class csheets.core.formula.Operation
operator
 
Constructor Summary
ReferenceOperation(Reference leftOperand, RangeReference operator, Reference rightOperand)
          Creates a new reference operation.
 
Method Summary
 Object accept(ExpressionVisitor visitor)
          Accepts to visit the given expression visitor.
 int compareTo(Reference reference)
          Compares the reference with the given reference for order.
 Value evaluate()
          Evaluates the expression and returns the result.
 SortedSet<Cell> getCells()
          Returns the cell addresses (or address) that the reference points to.
 Reference getLeftOperand()
          Returns the left(first) operand.
 RangeReference getOperator()
          Returns the operator.
 Reference getRightOperand()
          Returns the right(second) operand.
 
Methods inherited from class csheets.core.formula.BinaryOperation
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceOperation

public ReferenceOperation(Reference leftOperand,
                          RangeReference operator,
                          Reference rightOperand)
Creates a new reference operation.

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

getCells

public SortedSet<Cell> getCells()
Description copied from interface: Reference
Returns the cell addresses (or address) that the reference points to.

Specified by:
getCells in interface Reference
Returns:
a naturally ordered set of the references' addresses

getOperator

public RangeReference getOperator()
Description copied from class: Operation
Returns the operator.

Overrides:
getOperator in class Operation<BinaryOperator>
Returns:
the operator.

getLeftOperand

public Reference getLeftOperand()
Description copied from class: BinaryOperation
Returns the left(first) operand.

Overrides:
getLeftOperand in class BinaryOperation
Returns:
an expression tree representing the operand

getRightOperand

public Reference getRightOperand()
Description copied from class: BinaryOperation
Returns the right(second) operand.

Overrides:
getRightOperand in class BinaryOperation
Returns:
an expression tree representing the operand

evaluate

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

Specified by:
evaluate in interface Expression
Specified by:
evaluate in interface Reference
Overrides:
evaluate in class BinaryOperation
Returns:
the result of the evaluation

accept

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

Specified by:
accept in interface Expression
Overrides:
accept in class BinaryOperation
Parameters:
visitor - the visitor
Throws:
ExpressionVisitorException

compareTo

public int compareTo(Reference reference)
Description copied from interface: Reference
Compares the reference with the given reference for order.

Specified by:
compareTo in interface Reference
Specified by:
compareTo in interface Comparable<Reference>
Parameters:
reference - the reference to be compared
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.