01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.search;
19:
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: import org.apache.lucene.document.Document;
25:
26: public class SearchResultCollectorChain implements
27: SearchResultCollector {
28:
29: private List collectors = new ArrayList();
30:
31: public SearchResultCollectorChain() {
32: }
33:
34: public SearchResultCollectorChain(SearchResultCollector first,
35: SearchResultCollector second) {
36: collectors.add(first);
37: collectors.add(second);
38: }
39:
40: public void add(SearchResultCollector collector) {
41: collectors.add(collector);
42: }
43:
44: /**
45: *
46: * @return true if the item should be included
47: */
48: public boolean collect(Document document, float score) {
49: Iterator iterator = collectors.iterator();
50: while (iterator.hasNext()) {
51: SearchResultCollector collector = (SearchResultCollector) iterator
52: .next();
53: if (!collector.collect(document, score)) {
54: return false;
55: }
56: }
57: return true;
58: }
59: }
|