001: package org.apache.lucene.search;
002:
003: /**
004: * Copyright 2005 The Apache Software Foundation
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.util.ArrayList;
020: import java.util.BitSet;
021: import java.util.List;
022:
023: /**
024: * The results of a SpanQueryFilter. Wraps the BitSet and the position infomration from the SpanQuery
025: *
026: *<p/>
027: * NOTE: This API is still experimental and subject to change.
028: *
029: **/
030: public class SpanFilterResult {
031: private BitSet bits;
032: private List positions;//Spans spans;
033:
034: /**
035: *
036: * @param bits The bits for the Filter
037: * @param positions A List of {@link org.apache.lucene.search.SpanFilterResult.PositionInfo} objects
038: */
039: public SpanFilterResult(BitSet bits, List positions) {
040: this .bits = bits;
041: this .positions = positions;
042: }
043:
044: /**
045: * The first entry in the array corresponds to the first "on" bit.
046: * Entries are increasing by document order
047: * @return A List of PositionInfo objects
048: */
049: public List getPositions() {
050: return positions;
051: }
052:
053: public BitSet getBits() {
054: return bits;
055: }
056:
057: public static class PositionInfo {
058: private int doc;
059: private List positions;
060:
061: public PositionInfo(int doc) {
062: this .doc = doc;
063: positions = new ArrayList();
064: }
065:
066: public void addPosition(int start, int end) {
067: positions.add(new StartEnd(start, end));
068: }
069:
070: public int getDoc() {
071: return doc;
072: }
073:
074: /**
075: *
076: * @return A List of {@link org.apache.lucene.search.SpanFilterResult.StartEnd} objects
077: */
078: public List getPositions() {
079: return positions;
080: }
081: }
082:
083: public static class StartEnd {
084: private int start;
085: private int end;
086:
087: public StartEnd(int start, int end) {
088: this .start = start;
089: this .end = end;
090: }
091:
092: /**
093: *
094: * @return The end position of this match
095: */
096: public int getEnd() {
097: return end;
098: }
099:
100: /**
101: * The Start position
102: * @return The start position of this match
103: */
104: public int getStart() {
105: return start;
106: }
107:
108: }
109: }
|