Package org.apache.jackrabbit.oak.api

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


    @Override
    public PropertyValue currentProperty() {
        boolean asterisk = PathUtils.getName(propertyName).equals("*");
        if (!asterisk) {
            PropertyValue p = selector.currentProperty(propertyName);
            return matchesPropertyType(p) ? p : null;
        }
        Tree tree = selector.currentTree();
        if (tree == null || !tree.exists()) {
            return null;
        }
        if (!asterisk) {
            String name = PathUtils.getName(propertyName);
            name = normalizePropertyName(name);
            PropertyState p = tree.getProperty(name);
            if (p == null) {
                return null;
            }
            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


                if (readIf("ESCAPE")) {
                    StaticOperandImpl esc = parseStaticOperand();
                    if (!(esc instanceof LiteralImpl)) {
                        throw getSyntaxError("only ESCAPE '\' is supported");
                    }
                    PropertyValue v = ((LiteralImpl) esc).getLiteralValue();
                    if (!v.getValue(Type.STRING).equals("\\")) {
                        throw getSyntaxError("only ESCAPE '\' is supported");
                    }
                }
            }
        } else if (readIf("IN")) {
View Full Code Here

            StaticOperandImpl op = parseStaticOperand();
            if (!(op instanceof LiteralImpl)) {
                throw getSyntaxError("literal");
            }
            LiteralImpl literal = (LiteralImpl) op;
            PropertyValue value = literal.getLiteralValue();
            read("AS");
            value = parseCastAs(value);
            read(")");
            // CastLiteral
            literal = factory.literal(value);
            return literal;
        } else {
            if (supportSQL1) {
                if (readIf("TIMESTAMP")) {
                    StaticOperandImpl op = parseStaticOperand();
                    if (!(op instanceof LiteralImpl)) {
                        throw getSyntaxError("literal");
                    }
                    LiteralImpl literal = (LiteralImpl) op;
                    PropertyValue value = literal.getLiteralValue();
                    value = PropertyValues.newDate(value.getValue(Type.DATE));
                    literal = factory.literal(value);
                    return literal;
                }
            }
            throw getSyntaxError("static operand");
View Full Code Here

            throw getSyntaxError("data type (STRING|BINARY|...)");
        }
        int propertyType = getPropertyTypeFromName(currentToken);
        read();

        PropertyValue v = PropertyValues.convert(value, propertyType, null);
        if (v == null) {
            throw getSyntaxError("data type (STRING|BINARY|...)");
        }
        return v;
    }
View Full Code Here

    private PropertyValue readString() throws ParseException {
        if (currentTokenType != VALUE) {
            throw getSyntaxError("string value");
        }
        PropertyValue value = currentValue;
        read();
        return value;
    }
View Full Code Here

        }
    }

    public void restrictProperty(String propertyName, Operator op, PropertyValue v) {
        PropertyRestriction x = addRestricition(propertyName);
        PropertyValue oldFirst = x.first;
        PropertyValue oldLast = x.last;
        switch (op) {
        case EQUAL:
            if (x.first != null && x.last == x.first && x.firstIncluding && x.lastIncluding) {
                // we keep the old equality condition if there is one;
                // we can not use setAlwaysFalse, as this would not be correct
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() == selector1) {
            PropertyValue p2 = selector2.currentProperty(property2Name);
            if (p2 == null && f.isPreparing() && selector2.isPrepared()) {
                // 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() == selector2) {
            PropertyValue p1 = selector1.currentProperty(property1Name);
            if (p1 == null && f.isPreparing() && selector1.isPrepared()) {
                // 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 FullTextExpression getFullTextConstraint(SelectorImpl s) {
        if (s != 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

        if (selector.index instanceof FulltextQueryIndex) {
            // first verify if a property level condition exists and if that
            // condition checks out, this takes out some extra rows from the index
            // aggregation bits
            if (relativePath == null && propertyName != null) {
                PropertyValue p = selector.currentProperty(propertyName);
                if (p == null) {
                    return false;
                }
            }
            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 {
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.