Search in sources :

Example 1 with UpperCase

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

the class QueryObjectModelFactoryTest method testUpperCase.

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

Example 2 with UpperCase

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

the class QomTest method upperCase.

@Test
public void upperCase() throws RepositoryException {
    PropertyValue p = f.propertyValue("selectorName", "propertyName");
    Length length = f.length(p);
    UpperCase u = f.upperCase(length);
    assertEquals(length, u.getOperand());
    assertEquals("UPPER(LENGTH([selectorName].[propertyName]))", u.toString());
}
Also used : UpperCase(javax.jcr.query.qom.UpperCase) Length(javax.jcr.query.qom.Length) PropertyValue(javax.jcr.query.qom.PropertyValue) Test(org.junit.Test)

Example 3 with UpperCase

use of javax.jcr.query.qom.UpperCase 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)

Aggregations

PropertyValue (javax.jcr.query.qom.PropertyValue)3 UpperCase (javax.jcr.query.qom.UpperCase)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 LowerCase (javax.jcr.query.qom.LowerCase)1 NodeLocalName (javax.jcr.query.qom.NodeLocalName)1 NodeName (javax.jcr.query.qom.NodeName)1 StaticOperand (javax.jcr.query.qom.StaticOperand)1 Test (org.junit.Test)1