Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.Order


    }

    protected OrderBySpec parseOrderBySpec( TokenStream tokens ) {
        if (tokens.canConsume('@')) {
            NameTest attributeName = parseQName(tokens);
            Order order = Order.ASCENDING;
            if (tokens.canConsume("ascending")) order = Order.ASCENDING;
            else if (tokens.canConsume("descending")) order = Order.DESCENDING;
            return new OrderBySpec(order, attributeName);
        }
        if (tokens.matches("jcr", ":", "score", "(")) {
            FunctionCall scoreFunction = parseFunctionCall(tokens);
            Order order = Order.ASCENDING;
            if (tokens.canConsume("ascending")) order = Order.ASCENDING;
            else if (tokens.canConsume("descending")) order = Order.DESCENDING;
            return new OrderBySpec(order, scoreFunction);
        }

        PathExpression path = this.parsePathExpr(tokens);

        if (!path.isRelative()) {
            throw new ParsingException(tokens.nextPosition(),
                    "Expected either 'jcr:score(tableName)', '@<propertyName>', "
                    + "or '<childName>/@<propertyOnChild>' but absolute path was found "
                    + tokens.consume());
        }

        List<StepExpression> steps = path.getSteps();
        if (steps.size() != 2) {
            throw new ParsingException(tokens.nextPosition(),
                    "Expected either 'jcr:score(tableName)', '@<propertyName>', "
                    + "or '<childName>/@<propertyOnChild>' but was found "
                    + tokens.consume());
        }

        if (!(((AxisStep)steps.get(0)).getNodeTest() instanceof NameTest)) {
            throw new ParsingException(tokens.nextPosition(),
                    "Expected '<childName>/@<propertyOnChild>' but was found "
                    + tokens.consume());
        }

        if (!(((AxisStep)steps.get(1)).getNodeTest() instanceof AttributeNameTest)) {
            throw new ParsingException(tokens.nextPosition(),
                    "Expected '<childName>/@<propertyOnChild>' but was found "
                    + tokens.consume());
        }

        Order order = Order.ASCENDING;
        if (tokens.canConsume("ascending")) {
            order = Order.ASCENDING;
        } else if (tokens.canConsume("descending")) {
            order = Order.DESCENDING;
        }
View Full Code Here


    protected Ordering parseOrdering( TokenStream tokens,
                                      TypeSystem typeSystem,
                                      Source source ) {
        DynamicOperand operand = parseDynamicOperand(tokens, typeSystem, source);
        Order order = Order.ASCENDING;
        if (tokens.canConsume("DESC")) order = Order.DESCENDING;
        if (tokens.canConsume("ASC")) order = Order.ASCENDING;
        NullOrder nullOrder = NullOrder.defaultOrder(order);
        if (tokens.canConsume("NULLS", "FIRST")) nullOrder = NullOrder.NULLS_FIRST;
        if (tokens.canConsume("NULLS", "LAST")) nullOrder = NullOrder.NULLS_LAST;
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.Order

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.