FileDocCategorySizeDatePackage
SimpleTerm.javaAPI DocApache Lucene 1.93635Mon Feb 20 09:17:42 GMT 2006org.apache.lucene.queryParser.surround.query

SimpleTerm

public abstract class SimpleTerm extends SrndQuery implements Comparable, DistanceSubQuery
Copyright 2005 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Fields Summary
private boolean
quoted
Constructors Summary
public SimpleTerm(boolean q)

quoted = q;
Methods Summary
public voidaddSpanQueries(SpanNearClauseFactory sncf)

    visitMatchingTerms(
          sncf.getIndexReader(),
          sncf.getFieldName(),
          new MatchingTermVisitor() {
            public void visitMatchingTerm(Term term) throws IOException {
              sncf.addTermWeighted(term, getWeight());
            }
          });
  
public intcompareTo(java.lang.Object o)

    /* for ordering terms and prefixes before using an index, not used */
    SimpleTerm ost = (SimpleTerm) o;
    return this.toStringUnquoted().compareTo( ost.toStringUnquoted());
  
public java.lang.StringdistanceSubQueryNotAllowed()

return null;
public java.lang.StringgetFieldOperator()

return "/";
public java.lang.StringgetQuote()

return "\"";
booleanisQuoted()

return quoted;
public org.apache.lucene.search.QuerymakeLuceneQueryFieldNoBoost(java.lang.String fieldName, BasicQueryFactory qf)

    return new Query() {
      public String toString(String fn) {
        return getClass().toString() + " " + fieldName + " (" + fn + "?)";
      }
      
      public Query rewrite(IndexReader reader) throws IOException {
        final ArrayList luceneSubQueries = new ArrayList();
        visitMatchingTerms( reader, fieldName,
            new MatchingTermVisitor() {
              public void visitMatchingTerm(Term term) throws IOException {
                luceneSubQueries.add(qf.newTermQuery(term));
              }
            });
        return  (luceneSubQueries.size() == 0) ? SrndQuery.theEmptyLcnQuery
              : (luceneSubQueries.size() == 1) ? (Query) luceneSubQueries.get(0)
              : SrndBooleanQuery.makeBooleanQuery(
                  /* luceneSubQueries all have default weight */
                  luceneSubQueries, BooleanClause.Occur.SHOULD); /* OR the subquery terms */ 
      }
    };
  
protected voidsuffixToString(java.lang.StringBuffer r)

;
public java.lang.StringtoString()

    StringBuffer r = new StringBuffer();
    if (isQuoted()) {
      r.append(getQuote());
    }
    r.append(toStringUnquoted());
    if (isQuoted()) {
      r.append(getQuote());
    }
    suffixToString(r);
    weightToString(r);
    return r.toString();
  
public abstract java.lang.StringtoStringUnquoted()

public abstract voidvisitMatchingTerms(org.apache.lucene.index.IndexReader reader, java.lang.String fieldName, org.apache.lucene.queryParser.surround.query.SimpleTerm$MatchingTermVisitor mtv)