pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / src / java / org / apache / lucene / search / SpanFilterResult.java
1 package org.apache.lucene.search;
2 /**
3  * Copyright 2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 import java.util.ArrayList;
19
20 import java.util.List;
21
22
23 /**
24  *  The results of a SpanQueryFilter.  Wraps the BitSet and the position information from the SpanQuery
25  *
26  * @lucene.experimental 
27  *
28  **/
29 public class SpanFilterResult {
30   private DocIdSet docIdSet;
31   private List<PositionInfo> positions;//Spans spans;
32   
33   /**
34   *
35   * @param docIdSet The DocIdSet for the Filter
36   * @param positions A List of {@link org.apache.lucene.search.SpanFilterResult.PositionInfo} objects
37   */
38   public SpanFilterResult(DocIdSet docIdSet, List<PositionInfo> positions) {
39     this.docIdSet = docIdSet;
40     this.positions = positions;
41   }
42   
43   /**
44    * The first entry in the array corresponds to the first "on" bit.
45    * Entries are increasing by document order
46    * @return A List of PositionInfo objects
47    */
48   public List<PositionInfo> getPositions() {
49     return positions;
50   }
51
52   /** Returns the docIdSet */
53   public DocIdSet getDocIdSet() {
54     return docIdSet;
55   }
56
57   public static class PositionInfo {
58     private int doc;
59     private List<StartEnd> positions;
60
61
62     public PositionInfo(int doc) {
63       this.doc = doc;
64       positions = new ArrayList<StartEnd>();
65     }
66
67     public void addPosition(int start, int end)
68     {
69       positions.add(new StartEnd(start, end));
70     }
71
72     public int getDoc() {
73       return doc;
74     }
75
76     /**
77      *
78      * @return Positions
79      */
80     public List<StartEnd> getPositions() {
81       return positions;
82     }
83   }
84
85   public static class StartEnd
86   {
87     private int start;
88     private int end;
89
90
91     public StartEnd(int start, int end) {
92       this.start = start;
93       this.end = end;
94     }
95
96     /**
97      *
98      * @return The end position of this match
99      */
100     public int getEnd() {
101       return end;
102     }
103
104     /**
105      * The Start position
106      * @return The start position of this match
107      */
108     public int getStart() {
109       return start;
110     }
111
112   }
113 }
114
115
116