Search in sources :

Example 26 with PropertyValue

use of javax.jcr.query.qom.PropertyValue in project jackrabbit by apache.

the class Parser method parseCondition.

private Constraint parseCondition(DynamicOperand left) throws RepositoryException {
    Constraint c;
    if (readIf("=")) {
        c = Operator.EQ.comparison(factory, left, parseStaticOperand());
    } else if (readIf("<>")) {
        c = Operator.NE.comparison(factory, left, parseStaticOperand());
    } else if (readIf("<")) {
        c = Operator.LT.comparison(factory, left, parseStaticOperand());
    } else if (readIf(">")) {
        c = Operator.GT.comparison(factory, left, parseStaticOperand());
    } else if (readIf("<=")) {
        c = Operator.LE.comparison(factory, left, parseStaticOperand());
    } else if (readIf(">=")) {
        c = Operator.GE.comparison(factory, left, parseStaticOperand());
    } else if (readIf("LIKE")) {
        c = Operator.LIKE.comparison(factory, left, parseStaticOperand());
    } else if (readIf("IS")) {
        boolean not = readIf("NOT");
        read("NULL");
        if (!(left instanceof PropertyValue)) {
            throw getSyntaxError("propertyName (NOT NULL is only supported for properties)");
        }
        PropertyValue p = (PropertyValue) left;
        c = getPropertyExistence(p);
        if (!not) {
            c = factory.not(c);
        }
    } else if (readIf("NOT")) {
        if (readIf("IS")) {
            read("NULL");
            if (!(left instanceof PropertyValue)) {
                throw new RepositoryException("Only property values can be tested for NOT IS NULL; got: " + left.getClass().getName());
            }
            PropertyValue pv = (PropertyValue) left;
            c = getPropertyExistence(pv);
        } else {
            read("LIKE");
            c = factory.not(Operator.LIKE.comparison(factory, left, parseStaticOperand()));
        }
    } else {
        throw getSyntaxError();
    }
    return c;
}
Also used : Constraint(javax.jcr.query.qom.Constraint) PropertyValue(javax.jcr.query.qom.PropertyValue) RepositoryException(javax.jcr.RepositoryException)

Aggregations

PropertyValue (javax.jcr.query.qom.PropertyValue)26 Ordering (javax.jcr.query.qom.Ordering)9 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)8 Test (org.junit.Test)8 Length (javax.jcr.query.qom.Length)5 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)5 Selector (javax.jcr.query.qom.Selector)5 BindVariableValue (javax.jcr.query.qom.BindVariableValue)4 Constraint (javax.jcr.query.qom.Constraint)4 PropertyExistence (javax.jcr.query.qom.PropertyExistence)4 NodeType (javax.jcr.nodetype.NodeType)3 Column (javax.jcr.query.qom.Column)3 LowerCase (javax.jcr.query.qom.LowerCase)3 UpperCase (javax.jcr.query.qom.UpperCase)3 RepositoryException (javax.jcr.RepositoryException)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)2 Value (javax.jcr.Value)2 Comparison (javax.jcr.query.qom.Comparison)2 NodeLocalName (javax.jcr.query.qom.NodeLocalName)2 NodeName (javax.jcr.query.qom.NodeName)2