Package org.modeshape.jcr.query.xpath.XPath

Examples of org.modeshape.jcr.query.xpath.XPath.OrderBySpec


    protected XPath.OrderBy orderBy( OrderBySpec... specs ) {
        return new XPath.OrderBy(Arrays.asList(specs));
    }

    protected OrderBySpec asc( FunctionCall scoreFunction ) {
        return new OrderBySpec(Order.ASCENDING, scoreFunction);
    }
View Full Code Here


    protected OrderBySpec asc( FunctionCall scoreFunction ) {
        return new OrderBySpec(Order.ASCENDING, scoreFunction);
    }

    protected OrderBySpec desc( FunctionCall scoreFunction ) {
        return new OrderBySpec(Order.DESCENDING, scoreFunction);
    }
View Full Code Here

    protected OrderBySpec desc( FunctionCall scoreFunction ) {
        return new OrderBySpec(Order.DESCENDING, scoreFunction);
    }

    protected OrderBySpec asc( NameTest attributeName ) {
        return new OrderBySpec(Order.ASCENDING, attributeName);
    }
View Full Code Here

    protected OrderBySpec asc( NameTest attributeName ) {
        return new OrderBySpec(Order.ASCENDING, attributeName);
    }

    protected OrderBySpec desc( NameTest attributeName ) {
        return new OrderBySpec(Order.DESCENDING, attributeName);
    }
View Full Code Here

    protected OrderBy parseOrderBy( TokenStream tokens ) {
        if (tokens.canConsume("order", "by")) {
            List<OrderBySpec> specs = new ArrayList<OrderBySpec>();
            do {
                OrderBySpec spec = parseOrderBySpec(tokens);
                specs.add(spec);
            } while (tokens.canConsume(','));
            if (!specs.isEmpty()) return new OrderBy(specs);
        }
        return null;
View Full Code Here

        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;
        }
        return new OrderBySpec(order, path);
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.xpath.XPath.OrderBySpec

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.