Package org.modeshape.jcr.query.model

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


        return new Literal(value);
    }

    protected And and( Constraint left,
                       Constraint right ) {
        return new And(left, right);
    }
View Full Code Here


        NamedSelector selector = (NamedSelector)query.source();
        assertThat(selector.name(), is(selectorName("nt:base")));
        assertThat(selector.aliasOrName(), is(selectorName("nt:base")));
        assertThat(selector.alias(), is(nullValue()));
        // WHERE ...
        And and = isAnd(query.constraint());
        Comparison comparison1 = isComparison(and.left());
        assertThat(comparison1.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base"))));
        assertThat(comparison1.getOperand2(), is((StaticOperand)literal("/a/b/%")));
        Not not = isNot(and.right());
        Comparison comparison2a = isComparison(not.getConstraint());
        assertThat(comparison2a.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base"))));
        assertThat(comparison2a.getOperand2(), is((StaticOperand)literal("/a/b/%/%")));
    }
View Full Code Here

        NamedSelector selector = (NamedSelector)query.source();
        assertThat(selector.name(), is(selectorName("nt:base")));
        assertThat(selector.aliasOrName(), is(selectorName("nt:base")));
        assertThat(selector.alias(), is(nullValue()));
        // WHERE ...
        And and = isAnd(query.constraint());
        Comparison comparison1 = isComparison(and.left());
        assertThat(comparison1.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base"))));
        assertThat(comparison1.getOperand2(), is((StaticOperand)literal("/a/b/%")));
        Not not = isNot(and.right());
        Comparison comparison2a = isComparison(not.getConstraint());
        assertThat(comparison2a.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base"))));
        assertThat(comparison2a.getOperand2(), is((StaticOperand)literal("/a/b/%/%")));
    }
View Full Code Here

        return new Not(constraint);
    }

    protected And and( Constraint constraint1,
                       Constraint constraint2 ) {
        return new And(constraint1, constraint2);
    }
View Full Code Here

                    return "(not " + not + " )";
                }
            };
        }
        if (constraint instanceof And) {
            And andConstraint = (And)constraint;
            final RowFilter left = createRowFilter(andConstraint.left(), context, columns, sources);
            final RowFilter right = createRowFilter(andConstraint.right(), context, columns, sources);
            return new RowFilter() {
                @Override
                public boolean isCurrentRowValid( Batch batch ) {
                    return left.isCurrentRowValid(batch) && right.isCurrentRowValid(batch);
                }
View Full Code Here

    }

    protected Constraint rewriteCriteria( QueryContext context,
                                          Constraint constraint ) {
        if (constraint instanceof And) {
            And and = (And)constraint;
            Constraint oldLeft = and.left();
            Constraint oldRight = and.right();
            Constraint newLeft = rewriteCriteria(context, oldLeft);
            Constraint newRight = rewriteCriteria(context, oldRight);
            if (newRight != oldRight) {
                // The right side is path-oriented ...
                if (newLeft != oldLeft) {
                    // The left is too, so create a new And constraint to signal that it's path oriented ...
                    return new And(newLeft, newRight);
                }
                // Only the right is, so swap the order ...
                return new And(newRight, newLeft);
            }
            // Neither are path-oriented ...
            return and;
        }
        if (constraint instanceof Or) {
View Full Code Here

    protected void separateAndConstraints( Constraint constraint,
                                           List<Constraint> andableConstraints ) {
        if (constraint == null) return;
        assert andableConstraints != null;
        if (constraint instanceof And) {
            And and = (And)constraint;
            separateAndConstraints(and.left(), andableConstraints);
            separateAndConstraints(and.right(), andableConstraints);
        } else {
            andableConstraints.add(constraint);
        }
    }
View Full Code Here

            DynamicOperand newOperand = rewrite(context, operand);
            if (newOperand != operand) {
                return new Comparison(newOperand, comparison.operator(), comparison.getOperand2());
            }
        } else if (constraint instanceof And) {
            And and = (And)constraint;
            Constraint left = and.left();
            Constraint right = and.right();
            Constraint newLeft = rewrite(context, left);
            Constraint newRight = rewrite(context, right);
            if (newLeft != left || newRight != right) {
                return new And(newLeft, newRight);
            }
        } else if (constraint instanceof Or) {
            Or or = (Or)constraint;
            Constraint left = or.left();
            Constraint right = or.right();
View Full Code Here

                joinableSources.add(new SameNodeJoinCondition(selector1, selector2), position);

                // AND has higher precedence than OR, so we need to evaluate it first ...
                while (tokens.canConsume("AND")) {
                    Constraint rhs = parseConstraint(tokens, typeSystem, source);
                    if (rhs != null) constraint = constraint != null ? new And(constraint, rhs) : rhs;
                }
                while (tokens.canConsume("OR")) {
                    Constraint rhs = parseConstraint(tokens, typeSystem, source);
                    if (rhs != null) constraint = constraint != null ? new And(constraint, rhs) : rhs;
                }
                return constraint;
            }
        }
        if (constraint != null) {
            // AND has higher precedence than OR, so we need to evaluate it first ...
            while (tokens.canConsume("AND")) {
                Constraint rhs = parseConstraint(tokens, typeSystem, source);
                if (rhs != null) constraint = new And(constraint, rhs);
            }
            while (tokens.canConsume("OR")) {
                Constraint rhs = parseConstraint(tokens, typeSystem, source);
                if (rhs != null) constraint = new Or(constraint, rhs);
            }
View Full Code Here

                // performed on all properties of the node(s). However, JCR-SQL2 and our AQM
                // expect a '*' to be used instead ...
                return new FullTextSearch(search.selectorName(), search.fullTextSearchExpression());
            }
        } else if (constraint instanceof And) {
            And and = (And)constraint;
            constraint = new And(rewriteConstraint(and.left()), rewriteConstraint(and.right()));
        } else if (constraint instanceof Or) {
            Or or = (Or)constraint;
            constraint = new Or(rewriteConstraint(or.left()), rewriteConstraint(or.right()));
        }
        return constraint;
View Full Code Here

TOP

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

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.