1 23 24 package org.apache.slide.search.basic.expression; 25 26 import java.util.Iterator ; 27 28 import org.apache.slide.search.InvalidQueryException; 29 import org.apache.slide.search.PropertyProvider; 30 import org.apache.slide.search.SearchException; 31 import org.apache.slide.search.basic.BasicResultSetImpl; 32 import org.apache.slide.search.basic.ComparableResource; 33 import org.apache.slide.search.basic.ComparableResourcesPool; 34 import org.apache.slide.search.basic.IBasicResultSet; 35 import org.jdom.Element; 36 37 42 public abstract class CompareExpression extends GenericBasicExpression { 43 44 47 protected ComparableResourcesPool requestedResourcesPool = null; 48 49 52 protected PropertyProvider propertyProvider = null; 53 54 55 61 CompareExpression (Element e, ComparableResourcesPool requestedResourcesPool) throws InvalidQueryException { 62 super (e); 63 this.requestedResourcesPool = requestedResourcesPool; 64 ((BasicResultSetImpl)resultSet).setPartialResultSet(requestedResourcesPool.partialResult()); 65 } 66 67 74 public IBasicResultSet execute () throws SearchException { 75 76 Iterator iterator = getRequestedResourcePool().getPool().iterator(); 77 while (iterator.hasNext()) { 78 ComparableResource item = 79 (ComparableResource)iterator.next(); 80 81 if (compare (item)) 82 resultSet.add (item); 83 } 84 return resultSet; 85 } 86 87 92 public ComparableResourcesPool getRequestedResourcePool() { 93 return requestedResourcesPool; 94 } 95 96 104 protected abstract boolean compare (ComparableResource item); 105 } 106 107 | Popular Tags |