Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.PropertyValue


        return operand.getSelectors();
    }

    @Override
    public PropertyValue currentProperty() {
        PropertyValue p = operand.currentProperty();
        if (p == null) {
            return null;
        }
        // TODO what is the expected result of UPPER(x) for an array property?
        // currently throws an exception
        String value = p.getValue(STRING);
        return PropertyValues.newString(value.toUpperCase());
    }
View Full Code Here


        return Collections.singleton(selector);
    }

    @Override
    public PropertyValue currentProperty() {
        PropertyValue p = selector.currentOakProperty(QueryImpl.JCR_SCORE);
        if (p == null) {
            // TODO if score() is not supported by the index, use the value 0.0?
            return PropertyValues.newDouble(0.0);
        }
        return p;
View Full Code Here

        }
        return currentOakProperty(t, oakPropertyName, propertyType);
    }
   
    private PropertyValue currentOakProperty(Tree t, String oakPropertyName, Integer propertyType) {
        PropertyValue result;
        if (t == null || !t.exists()) {
            return null;
        }
        if (oakPropertyName.equals(QueryImpl.JCR_PATH)) {
            String path = currentPath();
            String local = getLocalPath(path);
            if (local == null) {
                // not a local path
                return null;
            }
            result = PropertyValues.newString(local);
        } else if (oakPropertyName.equals(QueryImpl.JCR_SCORE)) {
            result = currentRow.getValue(QueryImpl.JCR_SCORE);
        } else if (oakPropertyName.equals(QueryImpl.REP_EXCERPT)) {
            result = currentRow.getValue(QueryImpl.REP_EXCERPT);
        } else {
            result = PropertyValues.create(t.getProperty(oakPropertyName));
        }
        if (result == null) {
            return null;
        }
        if (propertyType != null && result.getType().tag() != propertyType) {
            return null;
        }
        return result;
    }
View Full Code Here

            } else {
                t = t.getChild(parent);
            }
        }
        if (!"*".equals(oakPropertyName)) {
            PropertyValue value = currentOakProperty(t, oakPropertyName, propertyType);
            if (value != null) {
                target.add(value);
            }
            return;
        }
          for (PropertyState p : t.getProperties()) {
              if (propertyType == null || p.getType().tag() == propertyType) {
                  PropertyValue v = PropertyValues.create(p);
                  target.add(v);
              }
          }
    }
View Full Code Here

    @Override
    public boolean evaluate() {
        // JCR 2.0 spec, 6.7.16 Comparison:
        // "operand1 may evaluate to an array of values"
        PropertyValue p1 = operand1.currentProperty();
        if (p1 == null) {
            return false;
        }
        for (StaticOperandImpl operand2 : operand2List) {
            PropertyValue p2 = operand2.currentValue();
            if (p2 == null) {
                // if the property doesn't exist, the result is false
                continue;
            }
            // "the value of operand2 is converted to the
View Full Code Here

        selector2 = source.getExistingSelector(selector2Name);
    }

    @Override
    public boolean evaluate() {
        PropertyValue p1 = selector1.currentProperty(property1Name);
        if (p1 == null) {
            return false;
        }
        PropertyValue p2 = selector2.currentProperty(property2Name);
        if (p2 == null) {
            return false;
        }
        if (!p1.isArray() && !p2.isArray()) {
            // both are single valued
            return PropertyValues.match(p1, p2);
        }
        // TODO what is the expected result of an equi join for multi-valued properties?
        if (!p1.isArray() && p2.isArray()) {
            p1 = convertValueToType(p1, p2);
            if (p1 != null && PropertyValues.match(p1, p2)) {
                return true;
            }
            return false;
        } else if (p1.isArray() && !p2.isArray()) {
            p2 = convertValueToType(p2, p1);
            if (p2 != null && PropertyValues.match(p1, p2)) {
                return true;
            }
            return false;
View Full Code Here

    }

    @Override
    public void restrict(FilterImpl f) {
        if (f.getSelector().equals(selector1)) {
            PropertyValue p2 = selector2.currentProperty(property2Name);
            if (p2 == null && f.isPreparing() && f.isPrepared(selector2)) {
                // during the prepare phase, if the selector is already
                // prepared, then we would know the value
                p2 = PropertyValues.newString(KNOWN_VALUE);
            }
            if (p2 != null) {
                if (p2.isArray()) {
                    // TODO support join on multi-valued properties
                    p2 = null;
                }
            }
            // always set the condition, even if unkown ( -> is not null)
            String p1n = normalizePropertyName(property1Name);
            f.restrictProperty(p1n, Operator.EQUAL, p2);
        }
        if (f.getSelector().equals(selector2)) {
            PropertyValue p1 = selector1.currentProperty(property1Name);
            if (p1 == null && f.isPreparing() && f.isPrepared(selector1)) {
                // during the prepare phase, if the selector is already
                // prepared, then we would know the value
                p1 = PropertyValues.newString(KNOWN_VALUE);
            }
            if (p1 != null) {
                if (p1.isArray()) {
                    // TODO support join on multi-valued properties
                    p1 = null;
                }
            }
            // always set the condition, even if unkown ( -> is not null)
View Full Code Here

   
    @Override
    public boolean evaluate() {
        // JCR 2.0 spec, 6.7.16 Comparison:
        // "operand1 may evaluate to an array of values"
        PropertyValue p1 = operand1.currentProperty();
        if (p1 == null) {
            return false;
        }
        PropertyValue p2 = operand2.currentValue();
        if (p2 == null) {
            // if the property doesn't exist, the result is always false
            // even for "null <> 'x'" (same as in SQL)
            return false;
        }
View Full Code Here

        return operand1 + " " + operator + " " + operand2;
    }

    @Override
    public void restrict(FilterImpl f) {
        PropertyValue v = operand2.currentValue();
        if (!PropertyValues.canConvert(
                operand2.getPropertyType(),
                operand1.getPropertyType())) {
            throw new IllegalArgumentException(
                    "Unsupported conversion from property type " +
                            PropertyType.nameFromValue(operand2.getPropertyType()) +
                            " to property type " +
                            PropertyType.nameFromValue(operand1.getPropertyType()));
        }
        if (v != null) {
            if (operator == Operator.LIKE) {
                String pattern;
                pattern = v.getValue(Type.STRING);
                LikePattern p = new LikePattern(pattern);
                String lowerBound = p.getLowerBound();
                if (lowerBound != null) {
                    String upperBound = p.getUpperBound();
                    if (lowerBound.equals(upperBound)) {
                        // no wildcards
                        operand1.restrict(f, Operator.EQUAL, v);
                    } else if (operand1.supportsRangeConditions()) {
                        if (lowerBound != null) {
                            PropertyValue pv = PropertyValues.newString(lowerBound);
                            operand1.restrict(f, Operator.GREATER_OR_EQUAL, pv);
                        }
                        if (upperBound != null) {
                            PropertyValue pv = PropertyValues.newString(upperBound);
                            operand1.restrict(f, Operator.LESS_OR_EQUAL, pv);
                        }
                    } else {
                        // path conditions
                        operand1.restrict(f, operator, v);
View Full Code Here

    @Override
    public FullTextExpression getFullTextConstraint(SelectorImpl s) {
        if (!s.equals(selector)) {
            return null;
        }
        PropertyValue v = fullTextSearchExpression.currentValue();
        try {
            String p = propertyName;
            if (relativePath != null) {
                if (p == null) {
                    p = "*";
                }
                p = PathUtils.concat(relativePath, p);
            }
            String p2 = normalizePropertyName(p);
            return FullTextParser.parse(p2, v.getValue(Type.STRING));
        } catch (ParseException e) {
            throw new IllegalArgumentException("Invalid expression: " + fullTextSearchExpression, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.PropertyValue

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.