1 20 21 package dlog4j.search; 22 23 import java.io.IOException ; 24 import java.util.ArrayList ; 25 import java.util.BitSet ; 26 import java.util.List ; 27 28 import org.apache.lucene.index.IndexReader; 29 import org.apache.lucene.search.Filter; 30 31 47 public class MultiFilter extends org.apache.lucene.search.Filter { 48 49 54 private List filterList; 55 56 59 public MultiFilter() { 60 filterList = new ArrayList (); 61 } 62 63 71 public MultiFilter(int initialCapacity) { 72 filterList = new ArrayList (initialCapacity); 73 } 74 75 80 public void add(Filter filter) { 81 filterList.add(filter); 82 } 83 84 public BitSet bits(IndexReader reader) throws IOException { 85 int filterListSize = filterList.size(); 90 if (filterListSize > 0) { 91 BitSet bits = ((Filter)filterList.get(0)).bits(reader); 92 for (int i=1; i<filterListSize; i++) { 93 bits.and( ((Filter)filterList.get(i)).bits(reader) ); 94 } 95 return bits; 96 } 97 else { 102 return new BitSet (reader.maxDoc()); 103 } 104 } 105 } | Popular Tags |