FileDocCategorySizeDatePackage
ComposedQuery.javaAPI DocApache Lucene 2.1.03688Wed Feb 14 10:45:42 GMT 2007org.apache.lucene.queryParser.surround.query

ComposedQuery

public abstract class ComposedQuery extends SrndQuery
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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 String
opName
private List
queries
private boolean
operatorInfix
Constructors Summary
public ComposedQuery(List qs, boolean operatorInfix, String opName)

    recompose(qs);
    this.operatorInfix = operatorInfix;
    this.opName = opName;
  
Methods Summary
protected java.lang.StringgetBracketClose()

 return ")";
protected java.lang.StringgetBracketOpen()

 return "(";
public intgetNrSubQueries()

return queries.size();
public java.lang.StringgetOperatorName()

return opName;
protected java.lang.StringgetPrefixSeparator()

 return ", ";
public java.util.IteratorgetSubQueriesIterator()

return queries.listIterator();
public SrndQuerygetSubQuery(int qn)

return (SrndQuery) queries.get(qn);
protected voidinfixToString(java.lang.StringBuffer r)

    /* Brackets are possibly redundant in the result. */
    Iterator sqi = getSubQueriesIterator();
    r.append(getBracketOpen());
    if (sqi.hasNext()) {
      r.append(sqi.next().toString());
      while (sqi.hasNext()) {
        r.append(" ");
        r.append(getOperatorName()); /* infix operator */
        r.append(" ");
        r.append(sqi.next().toString());
      }
    }
    r.append(getBracketClose());
  
public booleanisFieldsSubQueryAcceptable()

    /* at least one subquery should be acceptable */
    Iterator sqi = getSubQueriesIterator();
    while (sqi.hasNext()) {
      if (((SrndQuery) sqi.next()).isFieldsSubQueryAcceptable()) {
        return true;
      }
    }
    return false;
  
public booleanisOperatorInfix()

 return operatorInfix; 
public java.util.ListmakeLuceneSubQueriesField(java.lang.String fn, BasicQueryFactory qf)

    ArrayList luceneSubQueries = new ArrayList();
    Iterator sqi = getSubQueriesIterator();
    while (sqi.hasNext()) {
      luceneSubQueries.add( ((SrndQuery) sqi.next()).makeLuceneQueryField(fn, qf));
    }
    return luceneSubQueries;
  
protected voidprefixToString(java.lang.StringBuffer r)

    Iterator sqi = getSubQueriesIterator();
    r.append(getOperatorName()); /* prefix operator */
    r.append(getBracketOpen());
    if (sqi.hasNext()) {
      r.append(sqi.next().toString());
      while (sqi.hasNext()) {
        r.append(getPrefixSeparator());
        r.append(sqi.next().toString());
      }
    }
    r.append(getBracketClose());
  
protected voidrecompose(java.util.List queries)

    if (queries.size() < 2) throw new AssertionError("Too few subqueries"); 
    this.queries = queries;
  
public java.lang.StringtoString()

    StringBuffer r = new StringBuffer();
    if (isOperatorInfix()) {
      infixToString(r);
    } else {
      prefixToString(r);
    }
    weightToString(r);
    return r.toString();