use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class FullTextSearchImpl method evaluate.
@Override
public boolean evaluate() {
// such as index aggregation
if (selector.getIndex() instanceof FulltextQueryIndex) {
// aggregation bits
if (relativePath == null && propertyName != null) {
return enforcePropertyExistence(propertyName, selector);
}
return true;
}
// OAK-2050
if (!query.getSettings().getFullTextComparisonWithoutIndex()) {
return false;
}
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 (!PathUtils.denotesRoot(path)) {
appendString(buff, PropertyValues.newString(PathUtils.getName(path)));
}
if (relativePath != null) {
String rp = normalizePath(relativePath);
path = PathUtils.concat(path, rp);
}
Tree tree = selector.getTree(path);
if (tree == null || !tree.exists()) {
return false;
}
if (propertyName != null) {
String pn = normalizePropertyName(propertyName);
PropertyState p = tree.getProperty(pn);
if (p == null) {
return false;
}
appendString(buff, PropertyValues.create(p));
} else {
for (PropertyState p : tree.getProperties()) {
appendString(buff, PropertyValues.create(p));
}
}
}
return getFullTextConstraint(selector).evaluate(buff.toString());
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class InImpl method evaluate.
@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 s : operand2) {
PropertyValue p2 = s.currentValue();
if (p2 == null) {
// if the property doesn't exist, the result is false
continue;
}
// "the value of operand2 is converted to the
// property type of the value of operand1"
p2 = convertValueToType(p2, p1);
if (PropertyValues.match(p1, p2)) {
return true;
}
}
return false;
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class ResultRowImpl method hashCodeOfValues.
private int hashCodeOfValues() {
int result = 1;
for (int i = 0; i < values.length; i++) {
if (distinctValues == null || distinctValues[i]) {
PropertyValue v = values[i];
result = 31 * result + (v == null ? 0 : v.hashCode());
}
}
return result;
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class SQL2Parser method parseCastAs.
private PropertyValue parseCastAs(PropertyValue value) throws ParseException {
if (currentTokenQuoted) {
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;
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class SQL2Parser method parseCondition.
private ConstraintImpl parseCondition(DynamicOperandImpl left) throws ParseException {
ConstraintImpl c;
if (readIf("=")) {
c = factory.comparison(left, Operator.EQUAL, parseStaticOperand());
} else if (readIf("<>")) {
c = factory.comparison(left, Operator.NOT_EQUAL, parseStaticOperand());
} else if (readIf("<")) {
c = factory.comparison(left, Operator.LESS_THAN, parseStaticOperand());
} else if (readIf(">")) {
c = factory.comparison(left, Operator.GREATER_THAN, parseStaticOperand());
} else if (readIf("<=")) {
c = factory.comparison(left, Operator.LESS_OR_EQUAL, parseStaticOperand());
} else if (readIf(">=")) {
c = factory.comparison(left, Operator.GREATER_OR_EQUAL, parseStaticOperand());
} else if (readIf("LIKE")) {
c = factory.comparison(left, Operator.LIKE, parseStaticOperand());
if (supportSQL1) {
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")) {
read("(");
ArrayList<StaticOperandImpl> list = new ArrayList<StaticOperandImpl>();
do {
StaticOperandImpl x = parseStaticOperand();
list.add(x);
} while (readIf(","));
read(")");
c = factory.in(left, list);
} else if (readIf("IS")) {
boolean not = readIf("NOT");
read("NULL");
if (!(left instanceof PropertyValueImpl)) {
throw getSyntaxError("propertyName (NOT NULL is only supported for properties)");
}
PropertyValueImpl p = (PropertyValueImpl) left;
if (not) {
c = getPropertyExistence(p);
} else {
c = getPropertyInexistence(p);
}
} else if (readIf("NOT")) {
if (readIf("IS")) {
read("NULL");
if (!(left instanceof PropertyValueImpl)) {
throw new ParseException("Only property values can be tested for NOT IS NULL; got: " + left.getClass().getName(), parseIndex);
}
PropertyValueImpl pv = (PropertyValueImpl) left;
c = getPropertyExistence(pv);
} else {
read("LIKE");
c = factory.comparison(left, Operator.LIKE, parseStaticOperand());
c = factory.not(c);
}
} else {
throw getSyntaxError();
}
return c;
}
Aggregations