@Override
  public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
    MtasSpanQuery newQuery = query.rewrite(reader);
    if (maximumLeft == 0 && maximumRight == 0) {
      return newQuery;
    } else if (((maximumLeft == 0) || (maximumLeft == minimumLeft))
        && ((maximumRight == 0) || (maximumRight == minimumRight))) {
      MtasSpanQuery maximumExpandedQuery = new MtasMaximumExpandSpanQuery(
          newQuery, minimumLeft, maximumLeft, minimumRight, maximumRight);
      return maximumExpandedQuery.rewrite(reader);
    } else if (!query.equals(newQuery)) {
      return new MtasExpandSpanQuery(newQuery, minimumLeft, maximumLeft,
          minimumRight, maximumRight);
    } else {
      return super.rewrite(reader);
    }
  }
@ Override public MtasSpanQuery rewrite ( IndexReader reader ) throws IOException { MtasSpanQuery newQuery = query . rewrite ( reader ) ; if ( maximumLeft == 0 && maximumRight == 0 ) { return newQuery ; } else if ( ( ( maximumLeft == 0 ) || ( maximumLeft == minimumLeft ) ) && ( ( maximumRight == 0 ) || ( maximumRight == minimumRight ) ) ) { MtasSpanQuery maximumExpandedQuery = new MtasMaximumExpandSpanQuery ( newQuery , minimumLeft , maximumLeft , minimumRight , maximumRight ) ; return maximumExpandedQuery . rewrite ( reader ) ; } else if ( ! query . equals ( newQuery ) ) { return new MtasExpandSpanQuery ( newQuery , minimumLeft , maximumLeft , minimumRight , maximumRight ) ; } else { return super . rewrite ( reader ) ; } }
/*
(non-Javadoc)

@see mtas.search.spans.util.MtasSpanQuery#rewrite(org.apache.lucene.index.
IndexReader)