Search in sources :

Example 1 with Expression

use of org.apache.qpid.server.filter.Expression in project qpid-broker-j by apache.

the class ConfiguredObjectFilterParser method multExpr.

public final Expression multExpr() throws ParseException {
    Expression left;
    Expression right;
    left = unaryExpr();
    label_8: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 42:
            case 43:
            case 44:
                ;
                break;
            default:
                break label_8;
        }
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 42:
                jj_consume_token(42);
                right = unaryExpr();
                left = ArithmeticExpression.createMultiply(left, right);
                break;
            case 43:
                jj_consume_token(43);
                right = unaryExpr();
                left = ArithmeticExpression.createDivide(left, right);
                break;
            case 44:
                jj_consume_token(44);
                right = unaryExpr();
                left = ArithmeticExpression.createMod(left, right);
                break;
            default:
                jj_consume_token(-1);
                throw new ParseException();
        }
    }
    {
        if (true)
            return left;
    }
    throw new Error("Missing return statement in function");
}
Also used : ArithmeticExpression(org.apache.qpid.server.filter.ArithmeticExpression) NamedExpression(org.apache.qpid.server.filter.NamedExpression) ComparisonExpression(org.apache.qpid.server.filter.ComparisonExpression) LogicExpression(org.apache.qpid.server.filter.LogicExpression) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression) UnaryExpression(org.apache.qpid.server.filter.UnaryExpression) ConstantExpression(org.apache.qpid.server.filter.ConstantExpression) Expression(org.apache.qpid.server.filter.Expression) BooleanExpression(org.apache.qpid.server.filter.BooleanExpression)

Example 2 with Expression

use of org.apache.qpid.server.filter.Expression in project qpid-broker-j by apache.

the class ConfiguredObjectFilterParser method equalityExpression.

public final Expression equalityExpression() throws ParseException {
    Expression left;
    Expression right;
    left = comparisonExpression();
    label_3: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case IS:
            case 31:
            case 32:
                ;
                break;
            default:
                break label_3;
        }
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 31:
                jj_consume_token(31);
                right = comparisonExpression();
                left = ComparisonExpression.createEqual(left, right);
                break;
            case 32:
                jj_consume_token(32);
                right = comparisonExpression();
                left = ComparisonExpression.createNotEqual(left, right);
                break;
            default:
                if (jj_2_1(2)) {
                    jj_consume_token(IS);
                    jj_consume_token(NULL);
                    left = ComparisonExpression.createIsNull(left);
                } else {
                    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                        case IS:
                            jj_consume_token(IS);
                            jj_consume_token(NOT);
                            jj_consume_token(NULL);
                            left = ComparisonExpression.createIsNotNull(left);
                            break;
                        default:
                            jj_consume_token(-1);
                            throw new ParseException();
                    }
                }
        }
    }
    {
        if (true)
            return left;
    }
    throw new Error("Missing return statement in function");
}
Also used : ArithmeticExpression(org.apache.qpid.server.filter.ArithmeticExpression) NamedExpression(org.apache.qpid.server.filter.NamedExpression) ComparisonExpression(org.apache.qpid.server.filter.ComparisonExpression) LogicExpression(org.apache.qpid.server.filter.LogicExpression) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression) UnaryExpression(org.apache.qpid.server.filter.UnaryExpression) ConstantExpression(org.apache.qpid.server.filter.ConstantExpression) Expression(org.apache.qpid.server.filter.Expression) BooleanExpression(org.apache.qpid.server.filter.BooleanExpression)

Example 3 with Expression

use of org.apache.qpid.server.filter.Expression in project qpid-broker-j by apache.

the class ConfiguredObjectQuery method parseSelectClause.

private HeadersAndValueExpressions parseSelectClause(final String selectClause) {
    final List<String> headers = new ArrayList<>();
    final List<Expression> valueExpressions = new ArrayList<>();
    if (selectClause != null) {
        ConfiguredObjectFilterParser parser = new ConfiguredObjectFilterParser();
        parser.setConfiguredObjectExpressionFactory(_expressionFactory);
        try {
            final List<Map<String, Expression>> expressions = parser.parseSelect(selectClause);
            for (Map<String, Expression> expression : expressions) {
                final Map.Entry<String, Expression> entry = expression.entrySet().iterator().next();
                headers.add(entry.getKey());
                valueExpressions.add(entry.getValue());
            }
        } catch (ParseException | TokenMgrError e) {
            throw new SelectorParsingException("Unable to parse select clause", e);
        }
    } else {
        for (String field : STANDARD_FIELDS) {
            headers.add(field);
            valueExpressions.add(_expressionFactory.createConfiguredObjectExpression(field));
        }
    }
    return new HeadersAndValueExpressions() {

        @Override
        public List<String> getHeaders() {
            return Collections.unmodifiableList(headers);
        }

        @Override
        public List<Expression> getValueExpressions() {
            return Collections.unmodifiableList(valueExpressions);
        }

        @Override
        public boolean hasHeader(final String headerName) {
            return headers.contains(headerName);
        }

        @Override
        public Expression getValueExpressionForHeader(final String headerName) {
            final int i = headers.indexOf(headerName);
            if (i < 0) {
                throw new IllegalStateException(String.format("No expression found for header '%s'", headerName));
            }
            return valueExpressions.get(i);
        }
    };
}
Also used : ArrayList(java.util.ArrayList) SelectorParsingException(org.apache.qpid.server.filter.SelectorParsingException) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression) Expression(org.apache.qpid.server.filter.Expression) BooleanExpression(org.apache.qpid.server.filter.BooleanExpression) Map(java.util.Map)

Example 4 with Expression

use of org.apache.qpid.server.filter.Expression in project qpid-broker-j by apache.

the class SelectorParser method addExpression.

public final Expression addExpression() throws ParseException {
    Expression left;
    Expression right;
    left = multExpr();
    label_7: while (true) {
        if (jj_2_5(2147483647)) {
            ;
        } else {
            break label_7;
        }
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 36:
                jj_consume_token(36);
                right = multExpr();
                left = ArithmeticExpression.createPlus(left, right);
                break;
            case 37:
                jj_consume_token(37);
                right = multExpr();
                left = ArithmeticExpression.createMinus(left, right);
                break;
            default:
                jj_consume_token(-1);
                throw new ParseException();
        }
    }
    {
        if (true)
            return left;
    }
    throw new Error("Missing return statement in function");
}
Also used : ArithmeticExpression(org.apache.qpid.server.filter.ArithmeticExpression) ConstantExpression(org.apache.qpid.server.filter.ConstantExpression) PropertyExpression(org.apache.qpid.server.filter.PropertyExpression) ComparisonExpression(org.apache.qpid.server.filter.ComparisonExpression) Expression(org.apache.qpid.server.filter.Expression) LogicExpression(org.apache.qpid.server.filter.LogicExpression) BooleanExpression(org.apache.qpid.server.filter.BooleanExpression) UnaryExpression(org.apache.qpid.server.filter.UnaryExpression)

Example 5 with Expression

use of org.apache.qpid.server.filter.Expression in project qpid-broker-j by apache.

the class SelectorParser method orExpression.

public final Expression orExpression() throws ParseException {
    Expression left;
    Expression right;
    left = andExpression();
    label_1: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case OR:
                ;
                break;
            default:
                break label_1;
        }
        jj_consume_token(OR);
        right = andExpression();
        left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
    }
    {
        if (true)
            return left;
    }
    throw new Error("Missing return statement in function");
}
Also used : ArithmeticExpression(org.apache.qpid.server.filter.ArithmeticExpression) ConstantExpression(org.apache.qpid.server.filter.ConstantExpression) PropertyExpression(org.apache.qpid.server.filter.PropertyExpression) ComparisonExpression(org.apache.qpid.server.filter.ComparisonExpression) Expression(org.apache.qpid.server.filter.Expression) LogicExpression(org.apache.qpid.server.filter.LogicExpression) BooleanExpression(org.apache.qpid.server.filter.BooleanExpression) UnaryExpression(org.apache.qpid.server.filter.UnaryExpression)

Aggregations

BooleanExpression (org.apache.qpid.server.filter.BooleanExpression)23 Expression (org.apache.qpid.server.filter.Expression)23 ArithmeticExpression (org.apache.qpid.server.filter.ArithmeticExpression)21 ComparisonExpression (org.apache.qpid.server.filter.ComparisonExpression)21 ConstantExpression (org.apache.qpid.server.filter.ConstantExpression)21 LogicExpression (org.apache.qpid.server.filter.LogicExpression)21 UnaryExpression (org.apache.qpid.server.filter.UnaryExpression)21 OrderByExpression (org.apache.qpid.server.filter.OrderByExpression)14 NamedExpression (org.apache.qpid.server.filter.NamedExpression)12 PropertyExpression (org.apache.qpid.server.filter.PropertyExpression)9 ArrayList (java.util.ArrayList)4 SelectorParsingException (org.apache.qpid.server.filter.SelectorParsingException)2 Map (java.util.Map)1