MtasSpanMatchNoneSpans.java
package mtas.search.spans;
import java.io.IOException;
import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.spans.SpanCollector;
import mtas.search.spans.util.MtasSpanQuery;
import mtas.search.spans.util.MtasSpans;
/**
* The Class MtasSpanMatchNoneSpans.
*/
public class MtasSpanMatchNoneSpans extends MtasSpans {
/** The query. */
private MtasSpanQuery query;
/** The current start position. */
private int currentStartPosition;
/** The current end position. */
private int currentEndPosition;
/** The doc id. */
private int docId;
/**
* Instantiates a new mtas span match none spans.
*
* @param query the query
*/
public MtasSpanMatchNoneSpans(MtasSpanQuery query) {
currentStartPosition = NO_MORE_POSITIONS;
currentEndPosition = NO_MORE_POSITIONS;
docId = -1;
this.query = query;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.spans.Spans#nextStartPosition()
*/
@Override
public int nextStartPosition() throws IOException {
return currentStartPosition;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.spans.Spans#startPosition()
*/
@Override
public int startPosition() {
return currentStartPosition;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.spans.Spans#endPosition()
*/
@Override
public int endPosition() {
return currentEndPosition;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.spans.Spans#width()
*/
@Override
public int width() {
return 0;
}
/*
* (non-Javadoc)
*
* @see
* org.apache.lucene.search.spans.Spans#collect(org.apache.lucene.search.spans
* .SpanCollector)
*/
@Override
public void collect(SpanCollector collector) throws IOException {
// do nothing
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.DocIdSetIterator#docID()
*/
@Override
public int docID() {
return docId;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.DocIdSetIterator#nextDoc()
*/
@Override
public int nextDoc() throws IOException {
docId = NO_MORE_DOCS;
currentStartPosition = NO_MORE_POSITIONS;
currentEndPosition = NO_MORE_POSITIONS;
return docId;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.DocIdSetIterator#advance(int)
*/
@Override
public int advance(int target) throws IOException {
docId = NO_MORE_DOCS;
currentStartPosition = NO_MORE_POSITIONS;
currentEndPosition = NO_MORE_POSITIONS;
return docId;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.DocIdSetIterator#cost()
*/
@Override
public long cost() {
return 0;
}
/*
* (non-Javadoc)
*
* @see org.apache.lucene.search.spans.Spans#positionsCost()
*/
@Override
public float positionsCost() {
return 0;
}
/*
* (non-Javadoc)
*
* @see mtas.search.spans.util.MtasSpans#asTwoPhaseIterator()
*/
@Override
public TwoPhaseIterator asTwoPhaseIterator() {
if (!query.twoPhaseIteratorAllowed()) {
return null;
} else {
// TODO
return null;
}
}
}