1 23 package org.apache.slide.store.impl.rdbms.expression; 24 25 import org.apache.slide.content.NodeProperty.NamespaceCache; 26 import org.apache.slide.search.basic.Literals; 27 import org.jdom.Element; 28 29 public class RDBMSNotPropContainsExpression extends RDBMSCompareExpression { 30 31 public RDBMSNotPropContainsExpression(Element element, RDBMSQueryContext context) { 32 super(element, context); 33 } 34 35 protected String compile() { 36 Element property = (Element) _element.getChild(Literals.PROP, NamespaceCache.DEFAULT_NAMESPACE).getChildren().get(0); 37 Element literal = _element.getChild(Literals.LITERAL, NamespaceCache.DEFAULT_NAMESPACE); 38 return "NOT (p" + _tableIndex + ".PROPERTY_NAME = '" + property.getName() + "' AND " + 39 "p" + _tableIndex + ".PROPERTY_NAMESPACE = '" + property.getNamespaceURI() + "' AND " + 40 "p" + _tableIndex + ".PROPERTY_VALUE LIKE '%" + getPropertyValue(literal) + "%')"; 41 } 42 43 private String getPropertyValue(Element literal) { 44 String value = literal.getTextNormalize(); 45 StringBuffer sb = new StringBuffer (value.length() + 10); 46 for (int i = 0, l = value.length(); i < l; i++) { 47 char c = value.charAt(i); 48 if (c == '_' || c == '%') { 49 sb.append("\\\\"); 50 } 51 sb.append(c); 52 } 53 return sb.toString(); 54 } 55 56 } 57 | Popular Tags |