1 23 24 package org.apache.slide.index; 25 26 import java.util.Collection ; 27 28 import org.apache.slide.content.NodeProperty.NamespaceCache; 29 import org.apache.slide.search.BadQueryException; 30 import org.apache.slide.search.PropertyProvider; 31 import org.apache.slide.search.basic.IBasicExpression; 32 import org.apache.slide.search.basic.IBasicExpressionFactory; 33 import org.apache.slide.search.basic.IBasicQuery; 34 import org.jdom.Element; 35 36 40 public class BasicExpressionFactoryTxtContainsSample implements IBasicExpressionFactory 41 { 42 43 44 private IBasicQuery query; 45 protected PropertyProvider propertyProvider; 46 47 private String rootPath; 48 49 55 public BasicExpressionFactoryTxtContainsSample (String rootPath) 56 { 57 this.rootPath = rootPath; 58 } 59 60 72 public IBasicExpression createMergeExpression (String mergeOperator, 73 String namespace, 74 Collection expressionsToMerge) 75 throws BadQueryException 76 { 77 return null; 78 } 79 80 90 public IBasicExpression createExpression (Element element) 91 throws BadQueryException 92 { 93 BasicExpressionTxtContainsSample result = null; 94 95 if (element == null) 96 { 97 throw new BadQueryException ("expected a where criteria"); 98 } 99 else 100 { 101 String namespace = element.getNamespace().getURI(); 102 if (namespace.equals (NamespaceCache.DEFAULT_URI)) 103 result = createDAVExpression (element); 104 105 } 109 result.setFactory(this); 110 return result; 111 } 112 113 114 123 private BasicExpressionTxtContainsSample createDAVExpression (Element e) 124 { 125 String name = e.getName(); 126 BasicExpressionTxtContainsSample result = null; 127 128 if (name.equals ("contains")) 129 { 130 String searchedText = e.getTextTrim(); 131 result = new BasicExpressionTxtContainsSample (searchedText, rootPath); 132 } 133 134 return result; 135 } 136 137 146 public void init(IBasicQuery query, PropertyProvider propertyProvider) 147 throws BadQueryException 148 { 149 this.query = (IBasicQuery) query; 150 this.propertyProvider = propertyProvider; 151 } 152 153 159 public PropertyProvider getPropertyProvider() 160 { 161 return propertyProvider; 162 } 163 164 170 public IBasicQuery getQuery() 171 { 172 return query; 173 } 174 175 } 176 177 | Popular Tags |