Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart9.png 37% of files have more coverage
49   144   24   7
32   87   0.49   7
7     3.43  
1    
 
  ReqExclScorer       Line # 27 49 24 85.2% 0.85227275
 
  (43)
 
1    package org.apache.lucene.search;
2   
3    /**
4    * Copyright 2005 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19    import java.io.IOException;
20   
21   
22    /** A Scorer for queries with a required subscorer and an excluding (prohibited) subscorer.
23    * <br>
24    * This <code>Scorer</code> implements {@link Scorer#skipTo(int)},
25    * and it uses the skipTo() on the given scorers.
26    */
 
27    public class ReqExclScorer extends Scorer {
28    private Scorer reqScorer, exclScorer;
29   
30    /** Construct a <code>ReqExclScorer</code>.
31    * @param reqScorer The scorer that must match, except where
32    * @param exclScorer indicates exclusion.
33    */
 
34  8957 toggle public ReqExclScorer(
35    Scorer reqScorer,
36    Scorer exclScorer) {
37  8957 super(null); // No similarity used.
38  8957 this.reqScorer = reqScorer;
39  8957 this.exclScorer = exclScorer;
40    }
41   
42    private boolean firstTime = true;
43   
 
44  11096 toggle public boolean next() throws IOException {
45  11096 if (firstTime) {
46  6767 if (! exclScorer.next()) {
47  783 exclScorer = null; // exhausted at start
48    }
49  6767 firstTime = false;
50    }
51  11096 if (reqScorer == null) {
52  0 return false;
53    }
54  11096 if (! reqScorer.next()) {
55  3768 reqScorer = null; // exhausted, nothing left
56  3768 return false;
57    }
58  7328 if (exclScorer == null) {
59  2052 return true; // reqScorer.next() already returned true
60    }
61  5276 return toNonExcluded();
62    }
63   
64    /** Advance to non excluded doc.
65    * <br>On entry:
66    * <ul>
67    * <li>reqScorer != null,
68    * <li>exclScorer != null,
69    * <li>reqScorer was advanced once via next() or skipTo()
70    * and reqScorer.doc() may still be excluded.
71    * </ul>
72    * Advances reqScorer a non excluded required doc, if any.
73    * @return true iff there is a non excluded required doc.
74    */
 
75