Search in sources :

Example 1 with LowerCase

use of javax.jcr.query.qom.LowerCase in project jackrabbit-oak by apache.

the class QomTest method lowerCase.

@Test
public void lowerCase() throws RepositoryException {
    PropertyValue p = f.propertyValue("selectorName", "propertyName");
    Length length = f.length(p);
    LowerCase l = f.lowerCase(length);
    assertEquals(length, l.getOperand());
    assertEquals("LOWER(LENGTH([selectorName].[propertyName]))", l.toString());
}
Also used : Length(javax.jcr.query.qom.Length) PropertyValue(javax.jcr.query.qom.PropertyValue) LowerCase(javax.jcr.query.qom.LowerCase) Test(org.junit.Test) AbstractRepositoryTest(org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)

Example 2 with LowerCase

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

the class OperandEvaluator method getValues.

/**
     * Evaluates the given operand in the context of the given row.
     *
     * @param operand operand to be evaluated
     * @param row query result row
     * @return values of the operand at the given row
     * @throws RepositoryException if the operand can't be evaluated
     */
public Value[] getValues(Operand operand, Row row) throws RepositoryException {
    if (operand instanceof StaticOperand) {
        StaticOperand so = (StaticOperand) operand;
        return new Value[] { getValue(so) };
    } else if (operand instanceof FullTextSearchScore) {
        FullTextSearchScore ftss = (FullTextSearchScore) operand;
        double score = row.getScore(ftss.getSelectorName());
        return new Value[] { factory.createValue(score) };
    } else if (operand instanceof NodeName) {
        NodeName nn = (NodeName) operand;
        String name = row.getNode(nn.getSelectorName()).getName();
        // root node
        if ("".equals(name)) {
            return new Value[] { factory.createValue(name, PropertyType.STRING) };
        }
        return new Value[] { factory.createValue(name, PropertyType.NAME) };
    } else if (operand instanceof Length) {
        return getLengthValues((Length) operand, row);
    } else if (operand instanceof LowerCase) {
        return getLowerCaseValues((LowerCase) operand, row);
    } else if (operand instanceof UpperCase) {
        return getUpperCaseValues((UpperCase) operand, row);
    } else if (operand instanceof NodeLocalName) {
        return getNodeLocalNameValues((NodeLocalName) operand, row);
    } else if (operand instanceof PropertyValue) {
        return getPropertyValues((PropertyValue) operand, row);
    } else {
        throw new UnsupportedRepositoryOperationException("Unknown operand type: " + operand);
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) UpperCase(javax.jcr.query.qom.UpperCase) StaticOperand(javax.jcr.query.qom.StaticOperand) NodeName(javax.jcr.query.qom.NodeName) Length(javax.jcr.query.qom.Length) Value(javax.jcr.Value) PropertyValue(javax.jcr.query.qom.PropertyValue) BindVariableValue(javax.jcr.query.qom.BindVariableValue) LowerCase(javax.jcr.query.qom.LowerCase) PropertyValue(javax.jcr.query.qom.PropertyValue) FullTextSearchScore(javax.jcr.query.qom.FullTextSearchScore) NodeLocalName(javax.jcr.query.qom.NodeLocalName)

Example 3 with LowerCase

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

the class QueryObjectModelFactoryTest method testLowerCase.

/**
     * Test case for {@link QueryObjectModelFactory#lowerCase(DynamicOperand)}
     */
public void testLowerCase() throws RepositoryException {
    PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    LowerCase lower = qf.lowerCase(propValue);
    assertTrue("Not a property value operand", lower.getOperand() instanceof PropertyValue);
}
Also used : PropertyValue(javax.jcr.query.qom.PropertyValue) LowerCase(javax.jcr.query.qom.LowerCase)

Aggregations

LowerCase (javax.jcr.query.qom.LowerCase)3 PropertyValue (javax.jcr.query.qom.PropertyValue)3 Length (javax.jcr.query.qom.Length)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 Value (javax.jcr.Value)1 BindVariableValue (javax.jcr.query.qom.BindVariableValue)1 FullTextSearchScore (javax.jcr.query.qom.FullTextSearchScore)1 NodeLocalName (javax.jcr.query.qom.NodeLocalName)1 NodeName (javax.jcr.query.qom.NodeName)1 StaticOperand (javax.jcr.query.qom.StaticOperand)1 UpperCase (javax.jcr.query.qom.UpperCase)1 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)1 Test (org.junit.Test)1