Object rVal = walkExpr(stringNode);
if (!(rVal instanceof String)) {
throw new IllegalStateException("LIKE operator requires String literal on right hand side.");
}
ColumnReference colRef = getColumnReference(colNode);
PropertyDefinition<?> pd = colRef.getPropertyDefinition();
PropertyType propType = pd.getPropertyType();
if (propType != PropertyType.STRING && propType != PropertyType.HTML && propType != PropertyType.ID
&& propType != PropertyType.URI) {
throw new IllegalStateException("Property type " + propType.value() + " is not allowed FOR LIKE");
}
if (pd.getCardinality() != Cardinality.SINGLE) {
throw new IllegalStateException("LIKE is not allowed for multi-value properties ");
}
String propVal = (String) so.getProperties().get(colRef.getPropertyId()).getFirstValue();
String pattern = translatePattern((String) rVal); // SQL to Java
// regex
// syntax
Pattern p = Pattern.compile(pattern);
return p.matcher(propVal).matches();