Search in sources :

Example 16 with Expression

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

the class ConfiguredObjectFilterParser method unaryExpr.

public final Expression unaryExpr() throws ParseException {
    String s = null;
    Expression left = null;
    if (jj_2_6(2147483647)) {
        jj_consume_token(40);
        left = unaryExpr();
    } else {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 41:
                jj_consume_token(41);
                left = unaryExpr();
                left = UnaryExpression.createNegate(left);
                break;
            case NOT:
                jj_consume_token(NOT);
                left = unaryExpr();
                left = UnaryExpression.createNOT(asBooleanExpression(left));
                break;
            case TRUE:
            case FALSE:
            case NULL:
            case DECIMAL_LITERAL:
            case HEX_LITERAL:
            case OCTAL_LITERAL:
            case FLOATING_POINT_LITERAL:
            case STRING_LITERAL:
            case FUNCTIONNAME:
            case ID:
            case QUOTED_ID:
            case 37:
                left = primaryExpr();
                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 17 with Expression

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

the class ConfiguredObjectFilterParser method orderByClauseElement.

public final OrderByExpression orderByClauseElement() throws ParseException {
    Expression expr;
    OrderByExpression orderByExpr;
    OrderByExpression.Order order = OrderByExpression.Order.ASC;
    expr = addExpression();
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case ASC:
        case DESC:
            switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                case ASC:
                    jj_consume_token(ASC);
                    break;
                case DESC:
                    jj_consume_token(DESC);
                    order = OrderByExpression.Order.DESC;
                    break;
                default:
                    jj_consume_token(-1);
                    throw new ParseException();
            }
            break;
        default:
            ;
    }
    {
        if (true)
            return new OrderByExpression(expr, order);
    }
    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) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression)

Example 18 with Expression

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

the class ConfiguredObjectFilterParser method functionExpression.

public final Expression functionExpression() throws ParseException {
    String s;
    Token t;
    List<Expression> args = new ArrayList<Expression>();
    Expression expr;
    t = jj_consume_token(FUNCTIONNAME);
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case NOT:
        case TRUE:
        case FALSE:
        case NULL:
        case DECIMAL_LITERAL:
        case HEX_LITERAL:
        case OCTAL_LITERAL:
        case FLOATING_POINT_LITERAL:
        case STRING_LITERAL:
        case FUNCTIONNAME:
        case ID:
        case QUOTED_ID:
        case 37:
        case 40:
        case 41:
            expr = addExpression();
            args.add(expr);
            label_9: while (true) {
                switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                    case 38:
                        ;
                        break;
                    default:
                        break label_9;
                }
                jj_consume_token(38);
                expr = addExpression();
                args.add(expr);
            }
            break;
        default:
            ;
    }
    jj_consume_token(39);
    {
        if (true)
            return _factory.createFunctionExpression(t.image.substring(0, t.image.length() - 1), args);
    }
    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) ArrayList(java.util.ArrayList)

Example 19 with Expression

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

the class ConfiguredObjectQuery method parseOrderByClause.

private List<OrderByExpression> parseOrderByClause(final String orderByClause, final HeadersAndValueExpressions headersAndValue) {
    final List<OrderByExpression> orderByExpressions;
    ConfiguredObjectFilterParser parser = new ConfiguredObjectFilterParser();
    parser.setConfiguredObjectExpressionFactory(new ConfiguredObjectExpressionFactory() {

        @Override
        public ConfiguredObjectExpression createConfiguredObjectExpression(final String propertyName) {
            if (headersAndValue.hasHeader(propertyName)) {
                Expression expression = headersAndValue.getValueExpressionForHeader(propertyName);
                return object -> expression.evaluate(object);
            } else {
                return super.createConfiguredObjectExpression(propertyName);
            }
        }
    });
    try {
        orderByExpressions = parser.parseOrderBy(orderByClause);
    } catch (ParseException | TokenMgrError e) {
        throw new SelectorParsingException("Unable to parse orderBy clause", e);
    }
    return orderByExpressions;
}
Also used : 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) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression)

Example 20 with Expression

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

the class SelectorParser method andExpression.

public final Expression andExpression() throws ParseException {
    Expression left;
    Expression right;
    left = equalityExpression();
    label_2: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case AND:
                ;
                break;
            default:
                break label_2;
        }
        jj_consume_token(AND);
        right = equalityExpression();
        left = LogicExpression.createAND(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