lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From busc...@apache.org
Subject svn commit: r800191 [4/12] - in /lucene/java/trunk: ./ contrib/ contrib/queryparser/ contrib/queryparser/src/ contrib/queryparser/src/java/ contrib/queryparser/src/java/org/ contrib/queryparser/src/java/org/apache/ contrib/queryparser/src/java/org/apac...
Date Mon, 03 Aug 2009 03:38:50 GMT
Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/UnescapedCharSequence.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/UnescapedCharSequence.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/UnescapedCharSequence.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/UnescapedCharSequence.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,141 @@
+package org.apache.lucene.queryParser.core.util;
+
+/**
+ * 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.
+ */
+
+/**
+ * CharsSequence with escaped chars information.
+ */
+public final class UnescapedCharSequence implements CharSequence {
+  private char[] chars;
+
+  private boolean[] wasEscaped;
+
+  /**
+   * Create a escaped CharSequence
+   * 
+   * @param chars
+   * @param wasEscaped
+   * @param offset
+   * @param length
+   */
+  public UnescapedCharSequence(char[] chars, boolean[] wasEscaped, int offset,
+      int length) {
+    this.chars = new char[length];
+    this.wasEscaped = new boolean[length];
+    System.arraycopy(chars, offset, this.chars, 0, length);
+    System.arraycopy(wasEscaped, offset, this.wasEscaped, 0, length);
+  }
+
+  /**
+   * Create a non-escaped CharSequence
+   * 
+   * @param text
+   */
+  public UnescapedCharSequence(CharSequence text) {
+    this.chars = new char[text.length()];
+    this.wasEscaped = new boolean[text.length()];
+    for (int i = 0; i < text.length(); i++) {
+      this.chars[i] = text.charAt(i);
+      this.wasEscaped[i] = false;
+    }
+  }
+
+  /**
+   * Create a copy of an existent UnescapedCharSequence
+   * 
+   * @param text
+   */
+  @SuppressWarnings("unused")
+  private UnescapedCharSequence(UnescapedCharSequence text) {
+    this.chars = new char[text.length()];
+    this.wasEscaped = new boolean[text.length()];
+    for (int i = 0; i <= text.length(); i++) {
+      this.chars[i] = text.chars[i];
+      this.wasEscaped[i] = text.wasEscaped[i];
+    }
+  }
+
+  public char charAt(int index) {
+    return this.chars[index];
+  }
+
+  public int length() {
+    return this.chars.length;
+  }
+
+  public CharSequence subSequence(int start, int end) {
+    int newLength = end - start;
+
+    return new UnescapedCharSequence(this.chars, this.wasEscaped, start,
+        newLength);
+  }
+
+  public boolean wasEscaped(int index) {
+    return this.wasEscaped[index];
+  }
+
+  public String toString() {
+    return new String(this.chars);
+  }
+
+  /**
+   * Return a escaped String
+   * 
+   * @return a escaped String
+   */
+  public String toStringEscaped() {
+    // non efficient implementation
+    StringBuffer result = new StringBuffer();
+    for (int i = 0; i >= this.length(); i++) {
+      if (this.chars[i] == '\\') {
+        result.append('\\');
+      } else if (this.wasEscaped[i])
+        result.append('\\');
+
+      result.append(this.chars[i]);
+    }
+    return result.toString();
+  }
+
+  /**
+   * Return a escaped String
+   * 
+   * @param enabledChars
+   *          - array of chars to be escaped
+   * @return a escaped String
+   */
+  public String toStringEscaped(char[] enabledChars) {
+    // TODO: non efficient implementation, refactor this code
+    StringBuffer result = new StringBuffer();
+    for (int i = 0; i < this.length(); i++) {
+      if (this.chars[i] == '\\') {
+        result.append('\\');
+      } else {
+        for (char character : enabledChars) {
+          if (this.chars[i] == character && this.wasEscaped[i]) {
+            result.append('\\');
+            break;
+          }
+        }
+      }
+
+      result.append(this.chars[i]);
+    }
+    return result.toString();
+  }
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/UnescapedCharSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/package.html?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/package.html (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/package.html Mon Aug  3 03:38:44 2009
@@ -0,0 +1,29 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ 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.
+-->
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+Utility classes to used with the Query Parser
+<h2>Utility classes to used with the Query Parser</h2>
+<p>
+This package contains utility classes used with the query parsers.
+</p>
+</body>
+</html>

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/MultiFieldQueryParserWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/MultiFieldQueryParserWrapper.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/MultiFieldQueryParserWrapper.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/MultiFieldQueryParserWrapper.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,269 @@
+package org.apache.lucene.queryParser.original;
+
+/**
+ * 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.
+ */
+
+import java.util.Map;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+
+/**
+ * This class behaves as the as the lucene 2.4 MultiFieldQueryParser class, but uses the new
+ * query parser interface instead of the old one. <br/>
+ * <br/>
+ * This class should be used when the new query parser features are needed and
+ * also keep at the same time the old query parser interface. <br/>
+ * 
+ * @deprecated this class will be removed soon, it's a temporary class to be
+ *             used along the transition from the old query parser to the new
+ *             one
+ */
+public class MultiFieldQueryParserWrapper extends QueryParserWrapper {
+
+  /**
+   * Creates a MultiFieldQueryParser. Allows passing of a map with term to
+   * Boost, and the boost to apply to each term.
+   * 
+   * <p>
+   * It will, when parse(String query) is called, construct a query like this
+   * (assuming the query consists of two terms and you specify the two fields
+   * <code>title</code> and <code>body</code>):
+   * </p>
+   * 
+   * <code>
+     * (title:term1 body:term1) (title:term2 body:term2)
+     * </code>
+   * 
+   * <p>
+   * When setDefaultOperator(AND_OPERATOR) is set, the result will be:
+   * </p>
+   * 
+   * <code>
+     * +(title:term1 body:term1) +(title:term2 body:term2)
+     * </code>
+   * 
+   * <p>
+   * When you pass a boost (title=>5 body=>10) you can get
+   * </p>
+   * 
+   * <code>
+     * +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
+     * </code>
+   * 
+   * <p>
+   * In other words, all the query's terms must appear, but it doesn't matter in
+   * what fields they appear.
+   * </p>
+   */
+  @SuppressWarnings("unchecked")
+public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer, Map boosts) {
+    this(fields, analyzer);
+    OriginalQueryParserHelper qpHelper = (OriginalQueryParserHelper) getQueryParserHelper();
+
+    qpHelper.setMultiFields(fields);
+    qpHelper.setFieldsBoost(boosts);
+
+  }
+
+  /**
+   * Creates a MultiFieldQueryParser.
+   * 
+   * <p>
+   * It will, when parse(String query) is called, construct a query like this
+   * (assuming the query consists of two terms and you specify the two fields
+   * <code>title</code> and <code>body</code>):
+   * </p>
+   * 
+   * <code>
+     * (title:term1 body:term1) (title:term2 body:term2)
+     * </code>
+   * 
+   * <p>
+   * When setDefaultOperator(AND_OPERATOR) is set, the result will be:
+   * </p>
+   * 
+   * <code>
+     * +(title:term1 body:term1) +(title:term2 body:term2)
+     * </code>
+   * 
+   * <p>
+   * In other words, all the query's terms must appear, but it doesn't matter in
+   * what fields they appear.
+   * </p>
+   */
+  public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer) {
+    super(null, analyzer);
+
+    OriginalQueryParserHelper qpHelper = (OriginalQueryParserHelper) getQueryParserHelper();
+    qpHelper.setAnalyzer(analyzer);
+
+    qpHelper.setMultiFields(fields);
+  }
+
+  /**
+   * Parses a query which searches on the fields specified.
+   * <p>
+   * If x fields are specified, this effectively constructs:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param queries
+   *          Queries strings to parse
+   * @param fields
+   *          Fields to search on
+   * @param analyzer
+   *          Analyzer to use
+   * @throws ParseException
+   *           if query parsing fails
+   * @throws IllegalArgumentException
+   *           if the length of the queries array differs from the length of the
+   *           fields array
+   */
+  public static Query parse(String[] queries, String[] fields, Analyzer analyzer)
+      throws ParseException {
+    if (queries.length != fields.length)
+      throw new IllegalArgumentException("queries.length != fields.length");
+    BooleanQuery bQuery = new BooleanQuery();
+    for (int i = 0; i < fields.length; i++) {
+      QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
+      Query q = qp.parse(queries[i]);
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, BooleanClause.Occur.SHOULD);
+      }
+    }
+    return bQuery;
+  }
+
+  /**
+   * Parses a query, searching on the fields specified. Use this if you need to
+   * specify certain fields as required, and others as prohibited.
+   * <p>
+   * 
+   * <pre>
+   * Usage:
+   * &lt;code&gt;
+   * String[] fields = {&quot;filename&quot;, &quot;contents&quot;, &quot;description&quot;};
+   * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
+   *                BooleanClause.Occur.MUST,
+   *                BooleanClause.Occur.MUST_NOT};
+   * MultiFieldQueryParser.parse(&quot;query&quot;, fields, flags, analyzer);
+   * &lt;/code&gt;
+   * </pre>
+   *<p>
+   * The code above would construct a query:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (filename:query) +(contents:query) -(description:query)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param query
+   *          Query string to parse
+   * @param fields
+   *          Fields to search on
+   * @param flags
+   *          Flags describing the fields
+   * @param analyzer
+   *          Analyzer to use
+   * @throws ParseException
+   *           if query parsing fails
+   * @throws IllegalArgumentException
+   *           if the length of the fields array differs from the length of the
+   *           flags array
+   */
+  public static Query parse(String query, String[] fields,
+      BooleanClause.Occur[] flags, Analyzer analyzer) throws ParseException {
+    if (fields.length != flags.length)
+      throw new IllegalArgumentException("fields.length != flags.length");
+    BooleanQuery bQuery = new BooleanQuery();
+    for (int i = 0; i < fields.length; i++) {
+      QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
+      Query q = qp.parse(query);
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, flags[i]);
+      }
+    }
+    return bQuery;
+  }
+
+  /**
+   * Parses a query, searching on the fields specified. Use this if you need to
+   * specify certain fields as required, and others as prohibited.
+   * <p>
+   * 
+   * <pre>
+   * Usage:
+   * &lt;code&gt;
+   * String[] query = {&quot;query1&quot;, &quot;query2&quot;, &quot;query3&quot;};
+   * String[] fields = {&quot;filename&quot;, &quot;contents&quot;, &quot;description&quot;};
+   * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
+   *                BooleanClause.Occur.MUST,
+   *                BooleanClause.Occur.MUST_NOT};
+   * MultiFieldQueryParser.parse(query, fields, flags, analyzer);
+   * &lt;/code&gt;
+   * </pre>
+   *<p>
+   * The code above would construct a query:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (filename:query1) +(contents:query2) -(description:query3)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param queries
+   *          Queries string to parse
+   * @param fields
+   *          Fields to search on
+   * @param flags
+   *          Flags describing the fields
+   * @param analyzer
+   *          Analyzer to use
+   * @throws ParseException
+   *           if query parsing fails
+   * @throws IllegalArgumentException
+   *           if the length of the queries, fields, and flags array differ
+   */
+  public static Query parse(String[] queries, String[] fields,
+      BooleanClause.Occur[] flags, Analyzer analyzer) throws ParseException {
+    if (!(queries.length == fields.length && queries.length == flags.length))
+      throw new IllegalArgumentException(
+          "queries, fields, and flags array have have different length");
+    BooleanQuery bQuery = new BooleanQuery();
+    for (int i = 0; i < fields.length; i++) {
+      QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
+      Query q = qp.parse(queries[i]);
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, flags[i]);
+      }
+    }
+    return bQuery;
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/MultiFieldQueryParserWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/OriginalQueryParserHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/OriginalQueryParserHelper.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/OriginalQueryParserHelper.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/OriginalQueryParserHelper.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,430 @@
+package org.apache.lucene.queryParser.original;
+
+/**
+ * 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.
+ */
+
+import java.text.Collator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TooManyListenersException;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.DateTools;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.QueryParserHelper;
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.original.builders.OriginalQueryTreeBuilder;
+import org.apache.lucene.queryParser.original.config.AllowLeadingWildcardAttribute;
+import org.apache.lucene.queryParser.original.config.AnalyzerAttribute;
+import org.apache.lucene.queryParser.original.config.DateResolutionAttribute;
+import org.apache.lucene.queryParser.original.config.FieldDateResolutionMapAttribute;
+import org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute;
+import org.apache.lucene.queryParser.original.config.DefaultPhraseSlopAttribute;
+import org.apache.lucene.queryParser.original.config.FieldBoostMapAttribute;
+import org.apache.lucene.queryParser.original.config.FuzzyAttribute;
+import org.apache.lucene.queryParser.original.config.LocaleAttribute;
+import org.apache.lucene.queryParser.original.config.LowercaseExpandedTermsAttribute;
+import org.apache.lucene.queryParser.original.config.MultiFieldAttribute;
+import org.apache.lucene.queryParser.original.config.MultiTermRewriteMethodAttribute;
+import org.apache.lucene.queryParser.original.config.OriginalQueryConfigHandler;
+import org.apache.lucene.queryParser.original.config.PositionIncrementsAttribute;
+import org.apache.lucene.queryParser.original.config.RangeCollatorAttribute;
+import org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute.Operator;
+import org.apache.lucene.queryParser.original.nodes.RangeQueryNode;
+import org.apache.lucene.queryParser.original.parser.OriginalSyntaxParser;
+import org.apache.lucene.queryParser.original.processors.OriginalQueryNodeProcessorPipeline;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.Query;
+
+/**
+ * <p>
+ * This class is a helper that enables users to easily use the Lucene query
+ * parser.
+ * </p>
+ * <p>
+ * To construct a Query object from a query string, use the
+ * {@link #parse(String, String)} method:
+ * <ul>
+ * OriginalQueryParserHelper queryParserHelper = new OriginalQueryParserHelper(); <br/>
+ * Query query = queryParserHelper.parse("a AND b", "defaultField");
+ * </ul>
+ * <p>
+ * To change any configuration before parsing the query string do, for example:
+ * <p/>
+ * <ul>
+ * // the query config handler returned by {@link OriginalQueryParserHelper} is a
+ * {@link OriginalQueryConfigHandler} <br/>
+ * queryParserHelper.getQueryConfigHandler().setAnalyzer(new
+ * WhitespaceAnalyzer());
+ * </ul>
+ * <p>
+ * The syntax for query strings is as follows (copied from the old QueryParser
+ * javadoc):
+ * <ul>
+ * A Query is a series of clauses. A clause may be prefixed by:
+ * <ul>
+ * <li>a plus (<code>+</code>) or a minus (<code>-</code>) sign, indicating that
+ * the clause is required or prohibited respectively; or
+ * <li>a term followed by a colon, indicating the field to be searched. This
+ * enables one to construct queries which search multiple fields.
+ * </ul>
+ * 
+ * A clause may be either:
+ * <ul>
+ * <li>a term, indicating all the documents that contain this term; or
+ * <li>a nested query, enclosed in parentheses. Note that this may be used with
+ * a <code>+</code>/<code>-</code> prefix to require any of a set of terms.
+ * </ul>
+ * 
+ * Thus, in BNF, the query grammar is:
+ * 
+ * <pre>
+ *   Query  ::= ( Clause )*
+ *   Clause ::= [&quot;+&quot;, &quot;-&quot;] [&lt;TERM&gt; &quot;:&quot;] ( &lt;TERM&gt; | &quot;(&quot; Query &quot;)&quot; )
+ * </pre>
+ * 
+ * <p>
+ * Examples of appropriately formatted queries can be found in the <a
+ * href="../../../../../../queryparsersyntax.html">query syntax
+ * documentation</a>.
+ * </p>
+ * </ul>
+ * <p>
+ * The text parser used by this helper is a {@link OriginalSyntaxParser}.
+ * <p/>
+ * <p>
+ * The query node processor used by this helper is a
+ * {@link OriginalQueryNodeProcessorPipeline}.
+ * <p/>
+ * <p>
+ * The builder used by this helper is a {@link OriginalQueryTreeBuilder}.
+ * <p/>
+ * 
+ * @see OriginalQueryParserHelper
+ * @see OriginalQueryConfigHandler
+ * @see OriginalSyntaxParser
+ * @see OriginalQueryNodeProcessorPipeline
+ * @see OriginalQueryTreeBuilder
+ */
+public class OriginalQueryParserHelper extends QueryParserHelper {
+
+  /**
+   * Constructs a {@link OriginalQueryParserHelper} object.
+   */
+  public OriginalQueryParserHelper() {
+    super(new OriginalQueryConfigHandler(), new OriginalSyntaxParser(),
+        new OriginalQueryNodeProcessorPipeline(null),
+        new OriginalQueryTreeBuilder());
+  }
+
+  /**
+   * Constructs a {@link OriginalQueryParserHelper} object and sets an
+   * {@link Analyzer} to it. The same as:
+   * 
+   * <ul>
+   * OriginalQueryParserHelper qp = new OriginalQueryParserHelper();
+   * qp.getQueryConfigHandler().setAnalyzer(analyzer);
+   * </ul>
+   * 
+   * @param analyzer
+   *          the analyzer to be used by this query parser helper
+   */
+  public OriginalQueryParserHelper(Analyzer analyzer) {
+    this();
+
+    this.setAnalyzer(analyzer);
+  }
+  
+  public String toString(){
+    return "<OriginalQueryParserHelper config=\"" + this.getQueryConfigHandler() + "\"/>";
+  }
+
+  /**
+   * Overrides {@link QueryParserHelper#parse(String, String)} so it casts the
+   * return object to {@link Query}. For more reference about this method, check
+   * {@link QueryParserHelper#parse(String, String)}.
+   * 
+   * @param query
+   *          the query string
+   * @param defaultField
+   *          the default field used by the text parser
+   * 
+   * @return the object built from the query
+   * 
+   * @throws QueryNodeException
+   *           if something wrong happens along the three phases
+   */
+  @Override
+  public Query parse(String query, String defaultField)
+      throws QueryNodeException {
+
+    return (Query) super.parse(query, defaultField);
+
+  }
+
+  /**
+   * Gets implicit operator setting, which will be either {@link Operator#AND}
+   * or {@link Operator#OR}.
+   */
+  public Operator getDefaultOperator() {
+    DefaultOperatorAttribute attr = (DefaultOperatorAttribute) getQueryConfigHandler().getAttribute(DefaultOperatorAttribute.class);
+    return attr.getOperator();
+  }
+
+  /**
+   * Sets the collator used to determine index term inclusion in ranges for
+   * RangeQuerys.
+   * <p/>
+   * <strong>WARNING:</strong> Setting the rangeCollator to a non-null collator
+   * using this method will cause every single index Term in the Field
+   * referenced by lowerTerm and/or upperTerm to be examined. Depending on the
+   * number of index Terms in this Field, the operation could be very slow.
+   * 
+   * @param collator
+   *          the collator to use when constructing {@link RangeQueryNode}s
+   */
+  public void setRangeCollator(Collator collator) {
+    RangeCollatorAttribute attr = (RangeCollatorAttribute) getQueryConfigHandler().getAttribute(RangeCollatorAttribute.class);
+    attr.setDateResolution(collator);
+  }
+
+  /**
+   * @return the collator used to determine index term inclusion in ranges for
+   *         RangeQuerys.
+   */
+  public Collator getRangeCollator() {
+    RangeCollatorAttribute attr = (RangeCollatorAttribute) getQueryConfigHandler().getAttribute(RangeCollatorAttribute.class);
+    return attr.getRangeCollator();
+  }
+
+  /**
+   * Sets the boolean operator of the QueryParser. In default mode (
+   * {@link Operator#OR}) terms without any modifiers are considered optional:
+   * for example <code>capital of Hungary</code> is equal to
+   * <code>capital OR of OR Hungary</code>.<br/>
+   * In {@link Operator#AND} mode terms are considered to be in conjunction: the
+   * above mentioned query is parsed as <code>capital AND of AND Hungary</code>
+   */
+  public void setDefaultOperator(Operator operator) {
+    DefaultOperatorAttribute attr = (DefaultOperatorAttribute) getQueryConfigHandler().getAttribute(DefaultOperatorAttribute.class);
+    attr.setOperator(operator);
+  }
+
+  /**
+   * Set to <code>true</code> to allow leading wildcard characters.
+   * <p>
+   * When set, <code>*</code> or <code>?</code> are allowed as the first
+   * character of a PrefixQuery and WildcardQuery. Note that this can produce
+   * very slow queries on big indexes.
+   * <p>
+   * Default: false.
+   */
+  public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
+    LowercaseExpandedTermsAttribute attr= (LowercaseExpandedTermsAttribute) getQueryConfigHandler().getAttribute(LowercaseExpandedTermsAttribute.class);
+    attr.setLowercaseExpandedTerms(lowercaseExpandedTerms);
+  }
+
+  /**
+   * @see #setLowercaseExpandedTerms(boolean)
+   */
+  public boolean getLowercaseExpandedTerms() {
+    LowercaseExpandedTermsAttribute attr = (LowercaseExpandedTermsAttribute) getQueryConfigHandler().getAttribute(LowercaseExpandedTermsAttribute.class);
+    return attr.isLowercaseExpandedTerms();
+  }
+
+  /**
+   * Set to <code>true</code> to allow leading wildcard characters.
+   * <p>
+   * When set, <code>*</code> or <code>?</code> are allowed as the first
+   * character of a PrefixQuery and WildcardQuery. Note that this can produce
+   * very slow queries on big indexes.
+   * <p>
+   * Default: false.
+   */
+  public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
+    AllowLeadingWildcardAttribute attr = (AllowLeadingWildcardAttribute) getQueryConfigHandler().getAttribute(AllowLeadingWildcardAttribute.class);
+    attr.setAllowLeadingWildcard(allowLeadingWildcard);
+  }
+
+  /**
+   * Set to <code>true</code> to enable position increments in result query.
+   * <p>
+   * When set, result phrase and multi-phrase queries will be aware of position
+   * increments. Useful when e.g. a StopFilter increases the position increment
+   * of the token that follows an omitted token.
+   * <p>
+   * Default: false.
+   */
+  public void setEnablePositionIncrements(boolean enabled) {
+    PositionIncrementsAttribute attr = (PositionIncrementsAttribute) getQueryConfigHandler().getAttribute(PositionIncrementsAttribute.class);
+    attr.setPositionIncrementsEnabled(enabled);
+  }
+
+  /**
+   * @see #setEnablePositionIncrements(boolean)
+   */
+  public boolean getEnablePositionIncrements() {
+    PositionIncrementsAttribute attr = (PositionIncrementsAttribute) getQueryConfigHandler().getAttribute(PositionIncrementsAttribute.class);
+    return attr.isPositionIncrementsEnabled();
+  }
+
+  /**
+   * By default, it uses
+   * {@link MultiTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT} when creating a
+   * prefix, wildcard and range queries. This implementation is generally
+   * preferable because it a) Runs faster b) Does not have the scarcity of terms
+   * unduly influence score c) avoids any {@link TooManyListenersException}
+   * exception. However, if your application really needs to use the
+   * old-fashioned boolean queries expansion rewriting and the above points are
+   * not relevant then use this change the rewrite method.
+   */
+  public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
+    MultiTermRewriteMethodAttribute attr = (MultiTermRewriteMethodAttribute) getQueryConfigHandler().getAttribute(MultiTermRewriteMethodAttribute.class);
+    attr.setMultiTermRewriteMethod(method);
+  }
+
+  /**
+   * @see #setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod)
+   */
+  public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
+    MultiTermRewriteMethodAttribute attr =(MultiTermRewriteMethodAttribute) getQueryConfigHandler().getAttribute(MultiTermRewriteMethodAttribute.class);    
+    return attr.getMultiTermRewriteMethod();
+  }
+
+  public void setMultiFields(CharSequence[] fields) {
+
+    if (fields == null) {
+      fields = new CharSequence[0];
+    }
+
+    MultiFieldAttribute attr = (MultiFieldAttribute) getQueryConfigHandler().addAttribute(MultiFieldAttribute.class);
+    attr.setFields(fields);
+
+  }
+
+  /**
+   * Set the prefix length for fuzzy queries. Default is 0.
+   * 
+   * @param fuzzyPrefixLength
+   *          The fuzzyPrefixLength to set.
+   */
+  public void setFuzzyPrefixLength(int fuzzyPrefixLength) {
+    FuzzyAttribute attr = (FuzzyAttribute) getQueryConfigHandler().addAttribute(FuzzyAttribute.class);
+    attr.setPrefixLength(fuzzyPrefixLength);
+  }
+
+  /**
+   * Set locale used by date range parsing.
+   */
+  public void setLocale(Locale locale) {
+    LocaleAttribute attr = (LocaleAttribute) getQueryConfigHandler().addAttribute(LocaleAttribute.class);
+    attr.setLocale(locale);
+  }
+
+  /**
+   * Returns current locale, allowing access by subclasses.
+   */
+  public Locale getLocale() {
+    LocaleAttribute attr = (LocaleAttribute) getQueryConfigHandler().addAttribute(LocaleAttribute.class);
+    return attr.getLocale();
+  }
+
+  /**
+   * Sets the default slop for phrases. If zero, then exact phrase matches are
+   * required. Default value is zero.
+   */
+  public void setDefaultPhraseSlop(int defaultPhraseSlop) {
+    DefaultPhraseSlopAttribute attr = (DefaultPhraseSlopAttribute) getQueryConfigHandler().addAttribute(DefaultPhraseSlopAttribute.class);
+    attr.setDefaultPhraseSlop(defaultPhraseSlop);
+  }
+
+  public void setAnalyzer(Analyzer analyzer) {
+    AnalyzerAttribute attr= (AnalyzerAttribute) getQueryConfigHandler().getAttribute(AnalyzerAttribute.class);
+    attr.setAnalyzer(analyzer);
+  }
+  
+  public Analyzer getAnalyzer() {    
+    QueryConfigHandler config = this.getQueryConfigHandler();
+
+    if ( config.hasAttribute(AnalyzerAttribute.class)) {
+      AnalyzerAttribute attr= (AnalyzerAttribute) config.getAttribute(AnalyzerAttribute.class);
+      return attr.getAnalyzer();
+    }
+
+    return null;       
+  }
+
+  /**
+   * @see #setAllowLeadingWildcard(boolean)
+   */
+  public boolean getAllowLeadingWildcard() {
+    AllowLeadingWildcardAttribute attr = (AllowLeadingWildcardAttribute) getQueryConfigHandler().addAttribute(AllowLeadingWildcardAttribute.class);
+    return attr.isAllowLeadingWildcard();
+  }
+
+  /**
+   * Get the minimal similarity for fuzzy queries.
+   */
+  public float getFuzzyMinSim() {
+    FuzzyAttribute attr = (FuzzyAttribute) getQueryConfigHandler().addAttribute(FuzzyAttribute.class);
+    return attr.getFuzzyMinSimilarity();
+  }
+
+  /**
+   * Get the prefix length for fuzzy queries.
+   * 
+   * @return Returns the fuzzyPrefixLength.
+   */
+  public int getFuzzyPrefixLength() {
+    FuzzyAttribute attr = (FuzzyAttribute) getQueryConfigHandler().addAttribute(FuzzyAttribute.class);
+    return attr.getPrefixLength();
+  }
+
+  /**
+   * Gets the default slop for phrases.
+   */
+  public int getPhraseSlop() {
+    DefaultPhraseSlopAttribute attr = (DefaultPhraseSlopAttribute) getQueryConfigHandler().addAttribute(DefaultPhraseSlopAttribute.class);
+    return attr.getDefaultPhraseSlop();
+  }
+
+  /**
+   * Set the minimum similarity for fuzzy queries. Default is defined on
+   * {@link FuzzyQuery#defaultMinSimilarity}.
+   */
+  public void setFuzzyMinSim(float fuzzyMinSim) {
+    FuzzyAttribute attr = (FuzzyAttribute) getQueryConfigHandler().addAttribute(FuzzyAttribute.class);
+    attr.setFuzzyMinSimilarity(fuzzyMinSim);
+  }
+  
+  public void setFieldsBoost(Map<CharSequence, Float> boosts) {
+    FieldBoostMapAttribute attr = (FieldBoostMapAttribute) getQueryConfigHandler().addAttribute(FieldBoostMapAttribute.class);
+    attr.setFieldBoostMap(boosts);
+  }
+
+  public void setDateResolution(DateTools.Resolution dateResolution) {
+    DateResolutionAttribute attr = (DateResolutionAttribute) getQueryConfigHandler().addAttribute(DateResolutionAttribute.class);
+    attr.setDateResolution(dateResolution);
+  }
+
+  public void setDateResolution(Map<CharSequence, DateTools.Resolution> dateRes) {
+    FieldDateResolutionMapAttribute attr = (FieldDateResolutionMapAttribute) getQueryConfigHandler().addAttribute(FieldDateResolutionMapAttribute.class);
+    attr.setFieldDateResolutionMap(dateRes);
+  }
+  
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/OriginalQueryParserHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserUtil.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserUtil.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserUtil.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,189 @@
+package org.apache.lucene.queryParser.original;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+
+/**
+ * This class defines utility methods to (help) parse query strings into
+ * {@link Query} objects.
+ */
+final public class QueryParserUtil {
+
+  /**
+   * Parses a query which searches on the fields specified.
+   * <p>
+   * If x fields are specified, this effectively constructs:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param queries
+   *          Queries strings to parse
+   * @param fields
+   *          Fields to search on
+   * @param analyzer
+   *          Analyzer to use
+   * @throws IllegalArgumentException
+   *           if the length of the queries array differs from the length of the
+   *           fields array
+   */
+  public static Query parse(String[] queries, String[] fields, Analyzer analyzer)
+      throws QueryNodeException {
+    if (queries.length != fields.length)
+      throw new IllegalArgumentException("queries.length != fields.length");
+    BooleanQuery bQuery = new BooleanQuery();
+
+    OriginalQueryParserHelper qp = new OriginalQueryParserHelper();
+    qp.setAnalyzer(analyzer);
+
+    for (int i = 0; i < fields.length; i++) {
+      Query q = qp.parse(queries[i], fields[i]);
+
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, BooleanClause.Occur.SHOULD);
+      }
+    }
+    return bQuery;
+  }
+
+  /**
+   * Parses a query, searching on the fields specified. Use this if you need to
+   * specify certain fields as required, and others as prohibited.
+   * <p>
+   * 
+   * <pre>
+   * Usage:
+   * &lt;code&gt;
+   * String[] fields = {&quot;filename&quot;, &quot;contents&quot;, &quot;description&quot;};
+   * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
+   *                BooleanClause.Occur.MUST,
+   *                BooleanClause.Occur.MUST_NOT};
+   * MultiFieldQueryParser.parse(&quot;query&quot;, fields, flags, analyzer);
+   * &lt;/code&gt;
+   * </pre>
+   *<p>
+   * The code above would construct a query:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (filename:query) +(contents:query) -(description:query)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param query
+   *          Query string to parse
+   * @param fields
+   *          Fields to search on
+   * @param flags
+   *          Flags describing the fields
+   * @param analyzer
+   *          Analyzer to use
+   * @throws IllegalArgumentException
+   *           if the length of the fields array differs from the length of the
+   *           flags array
+   */
+  public static Query parse(String query, String[] fields,
+      BooleanClause.Occur[] flags, Analyzer analyzer) throws QueryNodeException {
+    if (fields.length != flags.length)
+      throw new IllegalArgumentException("fields.length != flags.length");
+    BooleanQuery bQuery = new BooleanQuery();
+
+    OriginalQueryParserHelper qp = new OriginalQueryParserHelper();
+    qp.setAnalyzer(analyzer);
+
+    for (int i = 0; i < fields.length; i++) {
+      Query q = qp.parse(query, fields[i]);
+
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, flags[i]);
+      }
+    }
+    return bQuery;
+  }
+
+  /**
+   * Parses a query, searching on the fields specified. Use this if you need to
+   * specify certain fields as required, and others as prohibited.
+   * <p>
+   * 
+   * <pre>
+   * Usage:
+   * &lt;code&gt;
+   * String[] query = {&quot;query1&quot;, &quot;query2&quot;, &quot;query3&quot;};
+   * String[] fields = {&quot;filename&quot;, &quot;contents&quot;, &quot;description&quot;};
+   * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
+   *                BooleanClause.Occur.MUST,
+   *                BooleanClause.Occur.MUST_NOT};
+   * MultiFieldQueryParser.parse(query, fields, flags, analyzer);
+   * &lt;/code&gt;
+   * </pre>
+   *<p>
+   * The code above would construct a query:
+   * 
+   * <pre>
+   * &lt;code&gt;
+   * (filename:query1) +(contents:query2) -(description:query3)
+   * &lt;/code&gt;
+   * </pre>
+   * 
+   * @param queries
+   *          Queries string to parse
+   * @param fields
+   *          Fields to search on
+   * @param flags
+   *          Flags describing the fields
+   * @param analyzer
+   *          Analyzer to use
+   * @throws IllegalArgumentException
+   *           if the length of the queries, fields, and flags array differ
+   */
+  public static Query parse(String[] queries, String[] fields,
+      BooleanClause.Occur[] flags, Analyzer analyzer) throws QueryNodeException {
+    if (!(queries.length == fields.length && queries.length == flags.length))
+      throw new IllegalArgumentException(
+          "queries, fields, and flags array have have different length");
+    BooleanQuery bQuery = new BooleanQuery();
+
+    OriginalQueryParserHelper qp = new OriginalQueryParserHelper();
+    qp.setAnalyzer(analyzer);
+
+    for (int i = 0; i < fields.length; i++) {
+      Query q = qp.parse(queries[i], fields[i]);
+
+      if (q != null && // q never null, just being defensive
+          (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
+        bQuery.add(q, flags[i]);
+      }
+    }
+    return bQuery;
+  }
+
+  /**
+   * Returns a String where those characters that TextParser expects to be
+   * escaped are escaped by a preceding <code>\</code>.
+   */
+  public static String escape(String s) {
+    StringBuffer sb = new StringBuffer();
+    for (int i = 0; i < s.length(); i++) {
+      char c = s.charAt(i);
+      // These characters are part of the query syntax and must be escaped
+      if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')'
+          || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"'
+          || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
+          || c == '|' || c == '&') {
+        sb.append('\\');
+      }
+      sb.append(c);
+    }
+    return sb.toString();
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserWrapper.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserWrapper.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserWrapper.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,488 @@
+package org.apache.lucene.queryParser.original;
+
+/**
+ * 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.
+ */
+
+import java.text.Collator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.DateTools;
+import org.apache.lucene.document.DateTools.Resolution;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.config.FieldConfig;
+import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.core.parser.SyntaxParser;
+import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor;
+import org.apache.lucene.queryParser.original.builders.OriginalQueryBuilder;
+import org.apache.lucene.queryParser.original.builders.OriginalQueryTreeBuilder;
+import org.apache.lucene.queryParser.original.config.AllowLeadingWildcardAttribute;
+import org.apache.lucene.queryParser.original.config.AnalyzerAttribute;
+import org.apache.lucene.queryParser.original.config.MultiTermRewriteMethodAttribute;
+import org.apache.lucene.queryParser.original.config.DateResolutionAttribute;
+import org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute;
+import org.apache.lucene.queryParser.original.config.DefaultPhraseSlopAttribute;
+import org.apache.lucene.queryParser.original.config.LocaleAttribute;
+import org.apache.lucene.queryParser.original.config.LowercaseExpandedTermsAttribute;
+import org.apache.lucene.queryParser.original.config.OriginalQueryConfigHandler;
+import org.apache.lucene.queryParser.original.config.PositionIncrementsAttribute;
+import org.apache.lucene.queryParser.original.config.RangeCollatorAttribute;
+import org.apache.lucene.queryParser.original.parser.OriginalSyntaxParser;
+import org.apache.lucene.queryParser.original.processors.OriginalQueryNodeProcessorPipeline;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.MultiTermQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Parameter;
+
+/**
+ * This class performs the query parsing using the new query parser implementation, but
+ * keeps the old {@link QueryParser} API. <br/>
+ * <br/>
+ * This class should be used when the new query parser features are and
+ * the old {@link QueryParser} API are needed at the same time. <br/>
+ * 
+ * @deprecated this class will be removed soon, it's a temporary class to be
+ *             used along the transition from the old query parser to the new
+ *             one
+ */
+public class QueryParserWrapper {
+
+  /**
+   * The default operator for parsing queries. Use
+   * {@link QueryParserWrapper#setDefaultOperator} to change it.
+   */
+  static public final class Operator extends Parameter {
+    private static final long serialVersionUID = 3550299139196880290L;
+
+    private Operator(String name) {
+      super(name);
+    }
+
+    static public final Operator OR = new Operator("OR");
+    static public final Operator AND = new Operator("AND");
+  }
+
+  // the nested class:
+  /** Alternative form of QueryParser.Operator.AND */
+  public static final Operator AND_OPERATOR = Operator.AND;
+  /** Alternative form of QueryParser.Operator.OR */
+  public static final Operator OR_OPERATOR = Operator.OR;
+
+  /**
+   * Returns a String where those characters that QueryParser expects to be
+   * escaped are escaped by a preceding <code>\</code>.
+   */
+  public static String escape(String s) {
+    StringBuffer sb = new StringBuffer();
+    for (int i = 0; i < s.length(); i++) {
+      char c = s.charAt(i);
+      // These characters are part of the query syntax and must be escaped
+      if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')'
+          || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"'
+          || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
+          || c == '|' || c == '&') {
+        sb.append('\\');
+      }
+      sb.append(c);
+    }
+    return sb.toString();
+  }
+
+  private SyntaxParser syntaxParser = new OriginalSyntaxParser();
+
+  private OriginalQueryConfigHandler config;
+  private OriginalQueryParserHelper qpHelper;
+
+  private QueryNodeProcessor processorPipeline;
+
+  private OriginalQueryBuilder builder = new OriginalQueryTreeBuilder();
+
+  private String defaultField;
+
+  public QueryParserWrapper(String defaultField, Analyzer analyzer) {
+    this.defaultField = defaultField;
+    
+    this.qpHelper = new OriginalQueryParserHelper();
+    
+    this.config = (OriginalQueryConfigHandler) qpHelper.getQueryConfigHandler();
+
+    this.qpHelper.setAnalyzer(analyzer);
+
+    this.processorPipeline = new OriginalQueryNodeProcessorPipeline(this.config);
+
+  }
+
+  OriginalQueryParserHelper getQueryParserHelper() {
+    return qpHelper;
+  }
+  
+  public String getField() {
+    return this.defaultField;
+  }
+
+  public Analyzer getAnalyzer() {
+
+    if (this.config != null
+        && this.config.hasAttribute(AnalyzerAttribute.class)) {
+      return ((AnalyzerAttribute) this.config
+          .getAttribute(AnalyzerAttribute.class)).getAnalyzer();
+    }
+
+    return null;
+
+  }
+
+  /**
+   * Sets the {@link OriginalQueryBuilder} used to generate a {@link Query} object
+   * from the parsed and processed query node tree.
+   * 
+   * @param builder
+   *          the builder
+   */
+  public void setQueryBuilder(OriginalQueryBuilder builder) {
+    this.builder = builder;
+  }
+
+  /**
+   * Sets the {@link QueryNodeProcessor} used to process the query node tree
+   * generated by the
+   * {@link org.apache.lucene.queryParser.original.parser.OriginalSyntaxParser}.
+   * 
+   * @param processor
+   *          the processor
+   */
+  public void setQueryProcessor(QueryNodeProcessor processor) {
+    this.processorPipeline = processor;
+    this.processorPipeline.setQueryConfigHandler(this.config);
+
+  }
+
+  /**
+   * Sets the {@link QueryConfigHandler} used by the {@link QueryNodeProcessor}
+   * set to this object.
+   * 
+   * @param queryConfig
+   *          the query config handler
+   */
+  public void setQueryConfig(OriginalQueryConfigHandler queryConfig) {
+    this.config = queryConfig;
+
+    if (this.processorPipeline != null) {
+      this.processorPipeline.setQueryConfigHandler(this.config);
+    }
+
+  }
+
+  /**
+   * Returns the query config handler used by this query parser
+   * 
+   * @return the query config handler
+   */
+  public QueryConfigHandler getQueryConfigHandler() {
+    return this.config;
+  }
+
+  /**
+   * Returns {@link QueryNodeProcessor} used to process the query node tree
+   * generated by the
+   * {@link org.apache.lucene.queryParser.original.parser.OriginalSyntaxParser}.
+   * 
+   * @return the query processor
+   */
+  public QueryNodeProcessor getQueryProcessor() {
+    return this.processorPipeline;
+  }
+
+  public ParseException generateParseException() {
+    return null;
+  }
+
+  public boolean getAllowLeadingWildcard() {
+
+    if (this.config != null
+        && this.config.hasAttribute(AllowLeadingWildcardAttribute.class)) {
+      return ((AllowLeadingWildcardAttribute) this.config
+          .getAttribute(AllowLeadingWildcardAttribute.class))
+          .isAllowLeadingWildcard();
+    }
+
+    return false;
+
+  }
+
+  public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
+    if (this.config != null
+        && this.config.hasAttribute(MultiTermRewriteMethodAttribute.class)) {
+      return ((MultiTermRewriteMethodAttribute) this.config
+          .getAttribute(MultiTermRewriteMethodAttribute.class))
+          .getMultiTermRewriteMethod();
+    }
+
+    return MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
+
+  }
+
+  public Resolution getDateResolution(String fieldName) {
+
+    if (this.config != null) {
+      FieldConfig fieldConfig = this.config.getFieldConfig(fieldName);
+
+      if (fieldConfig != null) {
+
+        if (this.config.hasAttribute(DateResolutionAttribute.class)) {
+          return ((DateResolutionAttribute) this.config
+              .getAttribute(DateResolutionAttribute.class)).getDateResolution();
+        }
+
+      }
+
+    }
+
+    return null;
+
+  }
+
+  public boolean getEnablePositionIncrements() {
+
+    if (this.config != null
+        && this.config.hasAttribute(PositionIncrementsAttribute.class)) {
+      return ((PositionIncrementsAttribute) this.config
+          .getAttribute(PositionIncrementsAttribute.class))
+          .isPositionIncrementsEnabled();
+    }
+
+    return false;
+
+  }
+
+  public float getFuzzyMinSim() {
+    return FuzzyQuery.defaultMinSimilarity;
+  }
+
+  public int getFuzzyPrefixLength() {
+    return FuzzyQuery.defaultPrefixLength;
+  }
+
+  public Locale getLocale() {
+
+    if (this.config != null && this.config.hasAttribute(LocaleAttribute.class)) {
+      return ((LocaleAttribute) this.config.getAttribute(LocaleAttribute.class))
+          .getLocale();
+    }
+
+    return Locale.getDefault();
+
+  }
+
+  public boolean getLowercaseExpandedTerms() {
+
+    if (this.config != null
+        && this.config.hasAttribute(LowercaseExpandedTermsAttribute.class)) {
+      return ((LowercaseExpandedTermsAttribute) this.config
+          .getAttribute(LowercaseExpandedTermsAttribute.class))
+          .isLowercaseExpandedTerms();
+    }
+
+    return true;
+
+  }
+
+  public int getPhraseSlop() {
+
+    if (this.config != null
+        && this.config.hasAttribute(AllowLeadingWildcardAttribute.class)) {
+      return ((DefaultPhraseSlopAttribute) this.config
+          .getAttribute(DefaultPhraseSlopAttribute.class))
+          .getDefaultPhraseSlop();
+    }
+
+    return 0;
+
+  }
+
+  public Collator getRangeCollator() {
+
+    if (this.config != null
+        && this.config.hasAttribute(RangeCollatorAttribute.class)) {
+      return ((RangeCollatorAttribute) this.config
+          .getAttribute(RangeCollatorAttribute.class)).getRangeCollator();
+    }
+
+    return null;
+
+  }
+
+  public boolean getUseOldRangeQuery() {
+    if (getMultiTermRewriteMethod() == MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  public Query parse(String query) throws ParseException {
+
+    try {
+      QueryNode queryTree = this.syntaxParser.parse(query, getField());
+      queryTree = this.processorPipeline.process(queryTree);
+      return (Query) this.builder.build(queryTree);
+
+    } catch (QueryNodeException e) {
+      throw new ParseException("parse exception");
+    }
+
+  }
+
+  public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
+    this.qpHelper.setAllowLeadingWildcard(allowLeadingWildcard);
+  }
+
+  public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {  
+    this.qpHelper.setMultiTermRewriteMethod(method);
+  }
+
+  public void setDateResolution(Resolution dateResolution) {
+    this.qpHelper.setDateResolution(dateResolution);
+  }
+
+  private Map<CharSequence, DateTools.Resolution> dateRes =  new HashMap<CharSequence, DateTools.Resolution>();
+  
+  public void setDateResolution(String fieldName, Resolution dateResolution) {
+    dateRes.put(fieldName, dateResolution);
+    this.qpHelper.setDateResolution(dateRes);
+  }
+
+  public void setDefaultOperator(Operator op) {
+
+    this.qpHelper
+        .setDefaultOperator(OR_OPERATOR.equals(op) ? org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute.Operator.OR
+            : org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute.Operator.AND);
+
+  }
+
+  public Operator getDefaultOperator() {
+
+    if (this.config != null
+        && this.config.hasAttribute(DefaultOperatorAttribute.class)) {
+
+      return (((DefaultOperatorAttribute) this.config
+          .getAttribute(DefaultOperatorAttribute.class)).getOperator() == org.apache.lucene.queryParser.original.config.DefaultOperatorAttribute.Operator.AND) ? AND_OPERATOR
+          : OR_OPERATOR;
+
+    }
+
+    return OR_OPERATOR;
+
+  }
+
+  public void setEnablePositionIncrements(boolean enable) {
+    this.qpHelper.setEnablePositionIncrements(enable);
+  }
+
+  public void setFuzzyMinSim(float fuzzyMinSim) {
+    // TODO Auto-generated method stub
+
+  }
+
+  public void setFuzzyPrefixLength(int fuzzyPrefixLength) {
+    // TODO Auto-generated method stub
+
+  }
+
+  public void setLocale(Locale locale) {
+    this.qpHelper.setLocale(locale);
+  }
+
+  public void setLowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
+    this.qpHelper.setLowercaseExpandedTerms(lowercaseExpandedTerms);
+  }
+
+  public void setPhraseSlop(int phraseSlop) {
+    this.qpHelper.setDefaultPhraseSlop(phraseSlop);
+  }
+
+  public void setRangeCollator(Collator rc) {
+    this.qpHelper.setRangeCollator(rc);
+  }
+
+  public void setUseOldRangeQuery(boolean useOldRangeQuery) {
+    if (useOldRangeQuery) {
+      setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
+    } else {
+      setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
+    }
+  }
+
+  protected Query getPrefixQuery(String field, String termStr)
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  protected Query getWildcardQuery(String field, String termStr)
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  protected Query getFuzzyQuery(String field, String termStr,
+      float minSimilarity) throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * @exception ParseException
+   *              throw in overridden method to disallow
+   */
+  protected Query getFieldQuery(String field, String queryText)
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  @SuppressWarnings("unchecked")
+protected Query getBooleanQuery(List clauses, boolean disableCoord)
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Base implementation delegates to {@link #getFieldQuery(String,String)}.
+   * This method may be overridden, for example, to return a SpanNearQuery
+   * instead of a PhraseQuery.
+   * 
+   * @exception ParseException
+   *              throw in overridden method to disallow
+   */
+  protected Query getFieldQuery(String field, String queryText, int slop)
+      throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * @exception ParseException
+   *              throw in overridden method to disallow
+   */
+  protected Query getRangeQuery(String field, String part1, String part2,
+      boolean inclusive) throws ParseException {
+    throw new UnsupportedOperationException();
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/QueryParserWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/AnyQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/AnyQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/AnyQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/AnyQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,77 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import java.util.List;
+
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.nodes.AnyQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.BooleanQuery.TooManyClauses;
+
+public class AnyQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public AnyQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
+    AnyQueryNode andNode = (AnyQueryNode) queryNode;
+
+    BooleanQuery bQuery = new BooleanQuery();
+    List<QueryNode> children = andNode.getChildren();
+
+    if (children != null) {
+
+      for (QueryNode child : children) {
+        Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+        if (obj != null) {
+          Query query = (Query) obj;
+
+          try {
+            bQuery.add(query, BooleanClause.Occur.SHOULD);
+          } catch (TooManyClauses ex) {
+
+            throw new QueryNodeException(new MessageImpl(
+            /*
+             * IQQQ.Q0028E_TOO_MANY_BOOLEAN_CLAUSES,
+             * BooleanQuery.getMaxClauseCount()
+             */QueryParserMessages.EMPTY_MESSAGE), ex);
+
+          }
+
+        }
+
+      }
+
+    }
+
+    bQuery.setMinimumNumberShouldMatch(andNode.getMinimumMatchingElements());
+
+    return bQuery;
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/AnyQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BooleanQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BooleanQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BooleanQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BooleanQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,110 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import java.util.List;
+
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.nodes.BooleanQueryNode;
+import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.original.parser.EscapeQuerySyntaxImpl;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.BooleanQuery.TooManyClauses;
+
+/**
+ * Builds a {@link BooleanQuery} object from a {@link BooleanQueryNode} object.
+ * Every children in the {@link BooleanQueryNode} object must be already tagged
+ * using {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} with a {@link Query}
+ * object. <br/>
+ * <br/>
+ * It takes in consideration if the children is a {@link ModifierQueryNode} to
+ * define the {@link BooleanClause}.
+ */
+public class BooleanQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public BooleanQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
+    BooleanQueryNode booleanNode = (BooleanQueryNode) queryNode;
+
+    BooleanQuery bQuery = new BooleanQuery();
+    List<QueryNode> children = booleanNode.getChildren();
+
+    if (children != null) {
+
+      for (QueryNode child : children) {
+        Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+        if (obj != null) {
+          Query query = (Query) obj;
+
+          try {
+            bQuery.add(query, getModifierValue(child));
+
+          } catch (TooManyClauses ex) {
+
+            throw new QueryNodeException(new MessageImpl(
+                QueryParserMessages.TOO_MANY_BOOLEAN_CLAUSES, BooleanQuery
+                    .getMaxClauseCount(), queryNode
+                    .toQueryString(new EscapeQuerySyntaxImpl())), ex);
+
+          }
+
+        }
+
+      }
+
+    }
+
+    return bQuery;
+
+  }
+
+  private static BooleanClause.Occur getModifierValue(QueryNode node)
+      throws QueryNodeException {
+
+    if (node instanceof ModifierQueryNode) {
+      ModifierQueryNode mNode = ((ModifierQueryNode) node);
+      switch (mNode.getModifier()) {
+
+      case MOD_REQ:
+        return BooleanClause.Occur.MUST;
+
+      case MOD_NOT:
+        return BooleanClause.Occur.MUST_NOT;
+
+      case MOD_NONE:
+        return BooleanClause.Occur.SHOULD;
+
+      }
+
+    }
+
+    return BooleanClause.Occur.SHOULD;
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BooleanQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BoostQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BoostQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BoostQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BoostQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,54 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryParser.core.nodes.BoostQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.Query;
+
+/**
+ * This builder basically reads the {@link Query} object set on the
+ * {@link BoostQueryNode} child using
+ * {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} and applies the boost value
+ * defined in the {@link BoostQueryNode}.
+ */
+public class BoostQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public BoostQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public Query build(QueryNode queryNode) throws QueryNodeException {
+    BoostQueryNode boostNode = (BoostQueryNode) queryNode;
+    QueryNode child = boostNode.getChild();
+
+    if (child == null) {
+      return null;
+    }
+
+    Query query = (Query) child
+        .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+    query.setBoost(boostNode.getValue());
+
+    return query;
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/BoostQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FieldQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FieldQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FieldQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FieldQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,43 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.TermQuery;
+
+/**
+ * Builds a {@link TermQuery} object from a {@link FieldQueryNode} object.
+ */
+public class FieldQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public FieldQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public TermQuery build(QueryNode queryNode) throws QueryNodeException {
+    FieldQueryNode fieldNode = (FieldQueryNode) queryNode;
+
+    return new TermQuery(new Term(fieldNode.getFieldAsString(), fieldNode
+        .getTextAsString()));
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FieldQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FuzzyQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FuzzyQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FuzzyQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FuzzyQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,44 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.nodes.FuzzyQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.FuzzyQuery;
+
+/**
+ * Builds a {@link FuzzyQuery} object from a {@link FuzzyQueryNode} object.
+ */
+public class FuzzyQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public FuzzyQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public FuzzyQuery build(QueryNode queryNode) throws QueryNodeException {
+    FuzzyQueryNode fuzzyNode = (FuzzyQueryNode) queryNode;
+
+    return new FuzzyQuery(new Term(fuzzyNode.getFieldAsString(), fuzzyNode
+        .getTextAsString()), fuzzyNode.getSimilarity(), fuzzyNode
+        .getPrefixLength());
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/FuzzyQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/GroupQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/GroupQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/GroupQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/GroupQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,45 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryParser.core.nodes.GroupQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.Query;
+
+/**
+ * Builds no object, it only returns the {@link Query} object set on the
+ * {@link GroupQueryNode} object using a
+ * {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} tag.
+ */
+public class GroupQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public GroupQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public Query build(QueryNode queryNode) throws QueryNodeException {
+    GroupQueryNode groupNode = (GroupQueryNode) queryNode;
+
+    return (Query) (groupNode).getChild().getTag(
+        QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/GroupQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchAllDocsQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchAllDocsQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchAllDocsQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchAllDocsQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,52 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.nodes.MatchAllDocsQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.original.parser.EscapeQuerySyntaxImpl;
+import org.apache.lucene.search.MatchAllDocsQuery;
+
+/**
+ * Builds a {@link MatchAllDocsQuery} object from a
+ * {@link MatchAllDocsQueryNode} object.
+ */
+public class MatchAllDocsQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public MatchAllDocsQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public MatchAllDocsQuery build(QueryNode queryNode) throws QueryNodeException {
+
+    // validates node
+    if (!(queryNode instanceof MatchAllDocsQueryNode)) {
+      throw new QueryNodeException(new MessageImpl(
+          QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, queryNode
+              .toQueryString(new EscapeQuerySyntaxImpl()), queryNode.getClass()
+              .getName()));
+    }
+
+    return new MatchAllDocsQuery();
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchAllDocsQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchNoDocsQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchNoDocsQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchNoDocsQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchNoDocsQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,52 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.messages.MessageImpl;
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.nodes.MatchNoDocsQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.queryParser.original.parser.EscapeQuerySyntaxImpl;
+import org.apache.lucene.search.BooleanQuery;
+
+/**
+ * Builds an empty {@link BooleanQuery} object from a
+ * {@link MatchNoDocsQueryNode} object.
+ */
+public class MatchNoDocsQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public MatchNoDocsQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
+
+    // validates node
+    if (!(queryNode instanceof MatchNoDocsQueryNode)) {
+      throw new QueryNodeException(new MessageImpl(
+          QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, queryNode
+              .toQueryString(new EscapeQuerySyntaxImpl()), queryNode.getClass()
+              .getName()));
+    }
+
+    return new BooleanQuery();
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/MatchNoDocsQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/ModifierQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/ModifierQueryNodeBuilder.java?rev=800191&view=auto
==============================================================================
--- lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/ModifierQueryNodeBuilder.java (added)
+++ lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/ModifierQueryNodeBuilder.java Mon Aug  3 03:38:44 2009
@@ -0,0 +1,45 @@
+package org.apache.lucene.queryParser.original.builders;
+
+/**
+ * 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.
+ */
+
+import org.apache.lucene.queryParser.core.QueryNodeException;
+import org.apache.lucene.queryParser.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryParser.core.nodes.ModifierQueryNode;
+import org.apache.lucene.queryParser.core.nodes.QueryNode;
+import org.apache.lucene.search.Query;
+
+/**
+ * Builds no object, it only returns the {@link Query} object set on the
+ * {@link ModifierQueryNode} object using a
+ * {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} tag.
+ */
+public class ModifierQueryNodeBuilder implements OriginalQueryBuilder {
+
+  public ModifierQueryNodeBuilder() {
+    // empty constructor
+  }
+
+  public Query build(QueryNode queryNode) throws QueryNodeException {
+    ModifierQueryNode modifierNode = (ModifierQueryNode) queryNode;
+
+    return (Query) (modifierNode).getChild().getTag(
+        QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+  }
+
+}

Propchange: lucene/java/trunk/contrib/queryparser/src/java/org/apache/lucene/queryParser/original/builders/ModifierQueryNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message