/*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Peter Smith
*******************************************************************************/
package org.boris.expr.function;
import org.boris.expr.Expr;
import org.boris.expr.ExprDouble;
import org.boris.expr.ExprError;
import org.boris.expr.ExprException;
import org.boris.expr.ExprNumber;
public abstract class DoubleInOutFunctionErr extends AbstractFunction
{
public Expr evaluate(Expr[] args) throws ExprException {
assertArgCount(args, 1);
Expr a = evalArg(args[0]);
if (a instanceof ExprError)
return a;
if (!isNumber(a))
return ExprError.VALUE;
return new ExprDouble(evaluate(((ExprNumber) a).doubleValue()));
}
protected abstract double evaluate(double value) throws ExprException;
}