FileDocCategorySizeDatePackage
SpanFirstQuery.javaAPI DocApache Lucene 1.4.32710Mon Feb 02 13:27:52 GMT 2004org.apache.lucene.search.spans

SpanFirstQuery

public class SpanFirstQuery extends SpanQuery
Matches spans near the beginning of a field.

Fields Summary
private SpanQuery
match
private int
end
Constructors Summary
public SpanFirstQuery(SpanQuery match, int end)
Construct a SpanFirstQuery matching spans in match whose end position is less than or equal to end.

    this.match = match;
    this.end = end;
  
Methods Summary
public intgetEnd()
Return the maximum end position permitted in a match.

 return end; 
public java.lang.StringgetField()

 return match.getField(); 
public org.apache.lucene.search.spans.SpanQuerygetMatch()
Return the SpanQuery whose matches are filtered.

 return match; 
public org.apache.lucene.search.spans.SpansgetSpans(org.apache.lucene.index.IndexReader reader)

    return new Spans() {
        private Spans spans = match.getSpans(reader);

        public boolean next() throws IOException {
          while (spans.next()) {                  // scan to next match
            if (end() <= end)
              return true;
          }
          return false;
        }

        public boolean skipTo(int target) throws IOException {
          if (!spans.skipTo(target))
            return false;

          if (spans.end() <= end)                 // there is a match
            return true;

          return next();                          // scan to next match
        }

        public int doc() { return spans.doc(); }
        public int start() { return spans.start(); }
        public int end() { return spans.end(); }

        public String toString() {
          return "spans(" + SpanFirstQuery.this.toString() + ")";
        }

      };
  
public java.util.CollectiongetTerms()

 return match.getTerms(); 
public java.lang.StringtoString(java.lang.String field)

    StringBuffer buffer = new StringBuffer();
    buffer.append("spanFirst(");
    buffer.append(match.toString(field));
    buffer.append(", ");
    buffer.append(end);
    buffer.append(")");
    return buffer.toString();