csheets.core.formula
Class UnaryOperation

java.lang.Object
  extended by csheets.core.formula.Operation<UnaryOperator>
      extended by csheets.core.formula.UnaryOperation
All Implemented Interfaces:
Expression, Serializable

public class UnaryOperation
extends Operation<UnaryOperator>

A unary operation in a formula.

Author:
Einar Pehrson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class csheets.core.formula.Operation
operator
 
Constructor Summary
UnaryOperation(UnaryOperator operator, Expression operand)
          Creates a new unary operation.
 
Method Summary
 Object accept(ExpressionVisitor visitor)
          Accepts to visit the given expression visitor.
 Value evaluate()
          Evaluates the expression and returns the result.
 Expression getOperand()
          Returns the 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

UnaryOperation

public UnaryOperation(UnaryOperator operator,
                      Expression operand)
Creates a new unary operation.

Parameters:
operator - the unary operator
operand - the 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

getOperand

public Expression getOperand()
Returns the 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