Package org.boris.expr

Examples of org.boris.expr.Expr


        }
    }

    private void parseFunction(ExprToken token, ExprLexer lexer,
            IEvaluationCallback callback) throws ExprException, IOException {
        Expr c = current;
        current = null;
        ExprToken e = null;
        ArrayList args = new ArrayList();
        while ((e = lexer.next()) != null) {
            if (e.type.equals(ExprTokenType.Comma)) {
View Full Code Here


        setValue(f);
    }

    private void parseExpression(ExprLexer lexer, IEvaluationCallback callback)
            throws IOException, ExprException {
        Expr c = current;
        current = null;
        ExprToken e = null;
        while ((e = lexer.next()) != null) {
            if (e.type.equals(ExprTokenType.CloseBracket)) {
                Expr t = current;
                current = c;
                setValue(new ExprExpression(t));
                break;
            } else {
                parseToken(lexer, callback, e);
View Full Code Here

        }
    }

    private void parseArray(ExprLexer lexer, IEvaluationCallback callback)
            throws ExprException, IOException {
        Expr c = current;
        current = null;
        ExprToken e = null;
        int cols = -1;
        int count = 0;
        ArrayList args = new ArrayList();
View Full Code Here

        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

    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

    }

    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

    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

{
    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

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

        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

TOP

Related Classes of org.boris.expr.Expr

Copyright © 2018 www.massapicom. 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.