Package org.boris.expr.function

Source Code of org.boris.expr.function.DoubleInOutFunctionErr

/*******************************************************************************
* 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;
}
TOP

Related Classes of org.boris.expr.function.DoubleInOutFunctionErr

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.