Examples of Expr


Examples of org.boris.expr.Expr

        setValue(a);
    }

    private void parseValue(ExprToken e, IEvaluationCallback callback)
            throws ExprException {
        Expr value = null;
        switch (e.type) {
        case Decimal:
            value = new ExprDouble(e.doubleValue);
            break;
        case Integer:
View Full Code Here

Examples of org.boris.expr.Expr

    private void setValue(Expr value) throws ExprException {
        if (current == null) {
            current = value;
            return;
        } else {
            Expr c = current;
            do {
                if (!(c instanceof IBinaryOperator))
                    throw new ExprException("Expected operator not found");

                Expr rhs = ((IBinaryOperator) c).getRHS();
                if (rhs == null) {
                    ((IBinaryOperator) c).setRHS(value);
                    return;
                } else {
                    c = rhs;
View Full Code Here

Examples of org.boris.expr.Expr

    }

    private void parseOperator(ExprToken e) throws ExprException {
        switch (e.type) {
        case Plus:
            Expr lhs = current;
            current = new ExprAddition(lhs, null);
            break;
        case Minus:
            lhs = current;
            current = new ExprSubtraction(lhs, null);
View Full Code Here

Examples of org.boris.expr.Expr

    private void parseMultiplyDivide(IBinaryOperator md) throws ExprException {
        if (current == null)
            throw new ExprException("Unexpected null token");

        Expr c = current;
        Expr prev = null;
        while (c != null) {
            if (c instanceof ExprAddition || c instanceof ExprSubtraction) {
                prev = c;
                c = ((IBinaryOperator) c).getRHS();
            } else {
View Full Code Here

Examples of org.boris.expr.Expr

{
    public final Expr evaluate(Expr[] args) throws ExprException {
        assertArgCount(args, 3);

        // Get database argument
        Expr edb = evalArg(args[0]);
        if (!(edb instanceof ExprArray)) {
            return ExprError.VALUE;
        }
        Database db = Database.valueOf((ExprArray) edb);
        if (db == null) {
            return ExprError.VALUE;
        }

        // Get field argument
        Expr ef = evalArg(args[1]);
        String field = null;
        if (ef instanceof ExprString) {
            field = ((ExprString) ef).str;
        } else if (ef instanceof ExprInteger) {
            int col = ((ExprInteger) ef).intValue();
            int cc = db.getColumnCount();
            if (col < 1 || col > cc)
                return ExprError.VALUE;
            field = db.getColumnName(col - 1);
        }

        // Get criteria argument
        Expr ec = evalArg(args[2]);
        if (!(ec instanceof ExprArray)) {
            return ExprError.VALUE;
        }
        Criteria criteria = Criteria.valueOf((ExprArray) ec);
View Full Code Here

Examples of org.boris.expr.Expr

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()));
View Full Code Here

Examples of org.boris.expr.Expr

        set(name, parse(expression));
    }

    public void calculate() throws ExprException {
        for (String name : graph.sort()) {
            Expr input = inputs.get(name);
            if (input instanceof ExprEvaluatable) {
                Expr result = null;
                try {
                    fireBeforeCalculation(name);
                    result = ((ExprEvaluatable) input).evaluate();
                } catch (ExprException e) {
                    result = new ExprError(e);
View Full Code Here

Examples of org.boris.expr.Expr

    }

    private class EngineFunctionManager extends FunctionManager
    {
        public Expr evaluateVariable(ExprVariable variable) throws ExprException {
            Expr v = results.get(variable.getName());
            return v == null ? ExprError.NAME : v;
        }
View Full Code Here

Examples of org.boris.expr.Expr

        throw new ExprException("Invalid argument type for function " +
                getClass().getSimpleName());
    }
   
    protected String asString(Expr[] args, int index, String defaultValue) throws ExprException {
        Expr arg = getArg(args, index);
        return arg == null ? defaultValue : arg.toString();
    }
View Full Code Here

Examples of org.boris.expr.Expr

        Expr arg = getArg(args, index);
        return arg == null ? defaultValue : arg.toString();
    }
   
    protected int asInteger(Expr[] args, int index, int defaultValue) throws ExprException {
        Expr arg = getArg(args, index);
        if(arg instanceof ExprNumber)
            return ((ExprNumber)arg).intValue();
        return defaultValue;
    }
View Full Code Here
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.