Package org.apache.jackrabbit.oak.api

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


        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


            return true;
        }
       
        StringBuilder buff = new StringBuilder();
        if (relativePath == null && propertyName != null) {
            PropertyValue p = selector.currentProperty(propertyName);
            if (p == null) {
                return false;
            }
            appendString(buff, p);
        } else {
            String path = selector.currentPath();
            if (relativePath != null) {
                path = PathUtils.concat(path, relativePath);
            }

            Tree tree = getTree(path);
            if (tree == null || !tree.exists()) {
                return false;
            }

            if (propertyName != null) {
                PropertyState p = tree.getProperty(propertyName);
                if (p == null) {
                    return false;
                }
                appendString(buff, PropertyValues.create(p));
            } else {
                for (PropertyState p : tree.getProperties()) {
                    appendString(buff, PropertyValues.create(p));
                }
            }
        }
        // TODO fulltext conditions: need a way to disable evaluation
        // if a fulltext index is used, to avoid filtering too much
        // (we don't know what exact options are used in the fulltext index)
        // (stop word, special characters,...)
        PropertyValue v = fullTextSearchExpression.currentValue();
        try {
            FullTextExpression expr = FullTextParser.parse(v.getValue(Type.STRING));
            return expr.evaluate(buff.toString());
        } catch (ParseException e) {
            throw new IllegalArgumentException("Invalid expression: " + fullTextSearchExpression, e);
        }
    }
View Full Code Here

    @Override
    public PropertyValue currentProperty() {
        boolean asterisk = PathUtils.getName(propertyName).equals("*");
        if (!asterisk) {
            PropertyValue p = selector.currentProperty(propertyName);
            return matchesPropertyType(p) ? p : null;
        }
        Tree tree = getTree(selector.currentPath());
        if (tree == null || !tree.exists()) {
            return null;
        }
        if (!asterisk) {
            String name = PathUtils.getName(propertyName);
            if (!tree.hasProperty(name)) {
                return null;
            }
            PropertyState p = tree.getProperty(name);
            return matchesPropertyType(p) ? PropertyValues.create(p) : null;
        }
        // asterisk - create a multi-value property
        // warning: the returned property state may have a mixed type
        // (not all values may have the same type)

        // TODO currently all property values are converted to strings -
        // this doesn't play well with the idea that the types may be different
        List<String> values = new ArrayList<String>();
        for (PropertyState p : tree.getProperties()) {
            if (matchesPropertyType(p)) {
                Iterables.addAll(values, p.getValue(Type.STRINGS));
            }
        }
        // "*"
        return PropertyValues.newString(values);
    }
View Full Code Here

        return operand.getPropertyExistence();
    }

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

        return operand.getPropertyExistence();
    }

    @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 propertyValue.getPropertyExistence();
    }

    @Override
    public PropertyValue currentProperty() {
        PropertyValue p = propertyValue.currentProperty();
        if (p == null) {
            return null;
        }
        if (!p.isArray()) {
            long length = p.size();
            return PropertyValues.newLong(length);
        }
        // TODO what is the expected result for LENGTH(multiValueProperty)?
        throw new IllegalArgumentException("LENGTH(x) on multi-valued property is not supported");
    }
View Full Code Here

        }
        return -1;
    }

    public PropertyValue getBindVariableValue(String bindVariableName) {
        PropertyValue v = bindVariableMap.get(bindVariableName);
        if (v == null) {
            throw new IllegalArgumentException("Bind variable value not set: " + bindVariableName);
        }
        return v;
    }
View Full Code Here

            // then we add plans for each restriction that could apply to us
            for (Filter.PropertyRestriction pr : restrictions) {
                String propertyName = PathUtils.getName(pr.propertyName);
                if (lookup.isIndexed(propertyName, "/", filter)) {
                    PropertyValue value = null;
                    boolean createPlan = false;
                    if (pr.first == null && pr.last == null) {
                        // open query: [property] is not null
                        value = null;
                        createPlan = true;
View Full Code Here

        }
        return -1;
    }

    public PropertyValue getBindVariableValue(String bindVariableName) {
        PropertyValue v = bindVariableMap.get(bindVariableName);
        if (v == null) {
            throw new IllegalArgumentException("Bind variable value not set: " + bindVariableName);
        }
        return v;
    }
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

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.