net.christopherschultz.evaluator.function
Class BinaryOperator

java.lang.Object
  extended by net.christopherschultz.evaluator.StandardFunction
      extended by net.christopherschultz.evaluator.function.MathFunction
          extended by net.christopherschultz.evaluator.function.BinaryOperator
All Implemented Interfaces:
Function
Direct Known Subclasses:
BinaryOperator.Add, BinaryOperator.And, BinaryOperator.Divide, BinaryOperator.Equal, BinaryOperator.Greater, BinaryOperator.GreaterEqual, BinaryOperator.Less, BinaryOperator.LessEqual, BinaryOperator.Modulus, BinaryOperator.Multiply, BinaryOperator.Or, BinaryOperator.Subtract

public abstract class BinaryOperator
extends MathFunction

Provdes implementations of standard mathematical, logical, and relational binary operators including the following usual suspects: +, -, *, /, =, !=, >, <, >=, <=, &&, ||

Version:
$Revision: 1.2 $ $Date: 2008-06-20 22:58:48 $
Author:
Chris Schultz

Nested Class Summary
static class BinaryOperator.Add
          Implements addition.
static class BinaryOperator.And
          Implements logical AND.
static class BinaryOperator.Divide
          Implements division.
static class BinaryOperator.Equal
          Implements equals.
static class BinaryOperator.Greater
          Implements greater-than.
static class BinaryOperator.GreaterEqual
          Implements generic greater-than or equal to.
static class BinaryOperator.IncompatibleArgumentsException
           
static class BinaryOperator.Less
          Implements less than.
static class BinaryOperator.LessEqual
          Implements greater-than.
static class BinaryOperator.Modulus
          Implements modulus (remainder).
static class BinaryOperator.Multiply
          Implements multiplication.
static class BinaryOperator.NotEqual
          Implements unequal.
static class BinaryOperator.Or
          Implements logical OR.
static class BinaryOperator.Subtract
          Implements subtraction.
 
Nested classes/interfaces inherited from class net.christopherschultz.evaluator.function.MathFunction
MathFunction.abs, MathFunction.acos, MathFunction.asin, MathFunction.atan, MathFunction.ceil, MathFunction.cos, MathFunction.DoubleFunction, MathFunction.exp, MathFunction.floor, MathFunction.heaviside, MathFunction.log, MathFunction.max, MathFunction.min, MathFunction.pow, MathFunction.random, MathFunction.rint, MathFunction.sin, MathFunction.sqrt, MathFunction.tan, MathFunction.toDegrees, MathFunction.toRadians
 
Field Summary
 
Fields inherited from class net.christopherschultz.evaluator.function.MathFunction
ALLOW_NULL_COMPARISON, NULL_RETURNS_NULL
 
Constructor Summary
BinaryOperator()
           
 
Method Summary
protected abstract  Object call(EvaluationContext ec, Object lvalue, Object rvalue)
           
 Object call(EvaluationContext ec, String functionName, Object[] args)
          Checks for exactly two arguments and calls the subclass's 2-argument call function.
 
Methods inherited from class net.christopherschultz.evaluator.StandardFunction
call, getExpressionValue, getExpressionValueArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryOperator

public BinaryOperator()
Method Detail

call

public Object call(EvaluationContext ec,
                   String functionName,
                   Object[] args)
            throws EvaluationException
Checks for exactly two arguments and calls the subclass's 2-argument call function.

Specified by:
call in class StandardFunction
Parameters:
ec - The EvaluationContext in which this function is being called.
functionName - The name of the function being invoked.
args - The argument values to pass to this function.
Returns:
The result of the function.
Throws:
EvaluationException - If there is an error during function execution.

call

protected abstract Object call(EvaluationContext ec,
                               Object lvalue,
                               Object rvalue)
                        throws EvaluationException
Throws:
EvaluationException