csheets.core.formula.lang
Class RelationalOperator

java.lang.Object
  extended by csheets.core.formula.lang.RelationalOperator
All Implemented Interfaces:
BinaryOperator, Operator, Serializable
Direct Known Subclasses:
Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEqual

public abstract class RelationalOperator
extends Object
implements BinaryOperator

A relational operator.

Author:
Einar Pehrson
See Also:
Serialized Form

Constructor Summary
RelationalOperator()
          Creates a new relational operator.
 
Method Summary
 Value applyTo(Expression leftOperand, Expression rightOperand)
          Applies the operator to the given operands and returns the result.
abstract
<T> boolean
compare(Comparable<T> left, T right)
          Applies the operator to the given operands and returns a boolean value.
 Value.Type getOperandValueType()
          Returns the type of value that the operator's operands can have.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface csheets.core.formula.Operator
getIdentifier
 

Constructor Detail

RelationalOperator

public RelationalOperator()
Creates a new relational operator.

Method Detail

applyTo

public final Value applyTo(Expression leftOperand,
                           Expression rightOperand)
                    throws IllegalValueTypeException
Description copied from interface: BinaryOperator
Applies the operator to the given operands and returns the result.

Specified by:
applyTo in interface BinaryOperator
Returns:
the result of the operation
Throws:
IllegalValueTypeException - if the value of an operand is not of the expected type

compare

public abstract <T> boolean compare(Comparable<T> left,
                                    T right)
Applies the operator to the given operands and returns a boolean value.

Parameters:
left - the value of the left operand
right - the value of the right operand
Returns:
the result of the comparison

getOperandValueType

public Value.Type getOperandValueType()
Description copied from interface: Operator
Returns the type of value that the operator's operands can have.

Specified by:
getOperandValueType in interface Operator
Returns:
the type of value that the operator's operands can have

toString

public String toString()
Overrides:
toString in class Object