Search in sources :

Example 1 with OrderByExpression

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

the class ConfiguredObjectFilterParser method orderByClause.

public final List<OrderByExpression> orderByClause() throws ParseException {
    List<OrderByExpression> returnVal = new ArrayList<OrderByExpression>();
    OrderByExpression element;
    element = orderByClauseElement();
    returnVal.add(element);
    label_11: while (true) {
        switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case 38:
                ;
                break;
            default:
                break label_11;
        }
        jj_consume_token(38);
        element = orderByClauseElement();
        returnVal.add(element);
    }
    jj_consume_token(0);
    {
        if (true)
            return returnVal;
    }
    throw new Error("Missing return statement in function");
}
Also used : ArrayList(java.util.ArrayList) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression)

Example 2 with OrderByExpression

use of org.apache.qpid.server.filter.OrderByExpression 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 3 with OrderByExpression

use of org.apache.qpid.server.filter.OrderByExpression 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 4 with OrderByExpression

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

the class ConfiguredObjectQueryTest method testArithmeticStatementInOrderBy.

public void testArithmeticStatementInOrderBy() {
    final List<OrderByExpression> orderByExpressions;
    String orderByClause = "a + b";
    ConfiguredObjectFilterParser parser = new ConfiguredObjectFilterParser();
    parser.setConfiguredObjectExpressionFactory(new ConfiguredObjectExpressionFactory());
    try {
        orderByExpressions = parser.parseOrderBy(orderByClause);
        assertEquals(1, orderByExpressions.size());
    } catch (ParseException | TokenMgrError e) {
        throw new SelectorParsingException("Unable to parse orderBy clause", e);
    }
}
Also used : SelectorParsingException(org.apache.qpid.server.filter.SelectorParsingException) OrderByExpression(org.apache.qpid.server.filter.OrderByExpression)

Aggregations

OrderByExpression (org.apache.qpid.server.filter.OrderByExpression)4 BooleanExpression (org.apache.qpid.server.filter.BooleanExpression)2 Expression (org.apache.qpid.server.filter.Expression)2 SelectorParsingException (org.apache.qpid.server.filter.SelectorParsingException)2 ArrayList (java.util.ArrayList)1 ArithmeticExpression (org.apache.qpid.server.filter.ArithmeticExpression)1 ComparisonExpression (org.apache.qpid.server.filter.ComparisonExpression)1 ConstantExpression (org.apache.qpid.server.filter.ConstantExpression)1 LogicExpression (org.apache.qpid.server.filter.LogicExpression)1 NamedExpression (org.apache.qpid.server.filter.NamedExpression)1 UnaryExpression (org.apache.qpid.server.filter.UnaryExpression)1