lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adrianocrest...@apache.org
Subject svn commit: r1063095 - in /lucene/dev/trunk/lucene/contrib/queryparser/src: java/org/apache/lucene/queryParser/core/builders/ java/org/apache/lucene/queryParser/core/config/ java/org/apache/lucene/queryParser/core/nodes/ java/org/apache/lucene/queryPar...
Date Tue, 25 Jan 2011 01:22:35 GMT
Author: adrianocrestani
Date: Tue Jan 25 01:22:35 2011
New Revision: 1063095

URL: http://svn.apache.org/viewvc?rev=1063095&view=rev
Log:
applying patches from LUCENE-2855 and LUCENE-2867 to trunk

Added:
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/StringUtils.java
  (with props)
    lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/
    lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
  (with props)
Modified:
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/FieldConfig.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/QueryConfigHandler.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNode.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapFCListener.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldDateResolutionFCListener.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/MultiTermRewriteMethodAttribute.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/BoostQueryNodeProcessor.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java
    lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/SpansQueryConfigHandler.java

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/QueryTreeBuilder.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/builders/QueryTreeBuilder.java
Tue Jan 25 01:22:35 2011
@@ -61,7 +61,7 @@ public class QueryTreeBuilder implements
 
   private HashMap<Class<? extends QueryNode>, QueryBuilder> queryNodeBuilders;
 
-  private HashMap<CharSequence, QueryBuilder> fieldNameBuilders;
+  private HashMap<String, QueryBuilder> fieldNameBuilders;
 
   /**
    * {@link QueryTreeBuilder} constructor.
@@ -73,28 +73,25 @@ public class QueryTreeBuilder implements
   /**
    * Associates a field name with a builder.
    * 
-   * @param fieldName
-   *          the field name
-   * @param builder
-   *          the builder to be associated
+   * @param fieldName the field name
+   * @param builder the builder to be associated
    */
   public void setBuilder(CharSequence fieldName, QueryBuilder builder) {
 
     if (this.fieldNameBuilders == null) {
-      this.fieldNameBuilders = new HashMap<CharSequence, QueryBuilder>();
+      this.fieldNameBuilders = new HashMap<String, QueryBuilder>();
     }
 
-    this.fieldNameBuilders.put(fieldName, builder);
+    this.fieldNameBuilders.put(fieldName.toString(), builder);
+
 
   }
 
   /**
    * Associates a class with a builder
    * 
-   * @param queryNodeClass
-   *          the class
-   * @param builder
-   *          the builder to be associated
+   * @param queryNodeClass the class
+   * @param builder the builder to be associated
    */
   public void setBuilder(Class<? extends QueryNode> queryNodeClass,
       QueryBuilder builder) {
@@ -135,8 +132,13 @@ public class QueryTreeBuilder implements
     QueryBuilder builder = null;
 
     if (this.fieldNameBuilders != null && node instanceof FieldableNode) {
+      CharSequence field = ((FieldableNode) node).getField();
+
+      if (field != null) {
+        field = field.toString();
+      }
 
-      builder = this.fieldNameBuilders.get(((FieldableNode) node).getField());
+      builder = this.fieldNameBuilders.get(field);
 
     }
 
@@ -203,14 +205,13 @@ public class QueryTreeBuilder implements
    * Builds some kind of object from a query tree. Each node in the query tree
    * is built using an specific builder associated to it.
    * 
-   * @param queryNode
-   *          the query tree root node
+   * @param queryNode the query tree root node
    * 
    * @return the built object
    * 
-   * @throws QueryNodeException
-   *           if some node builder throws a {@link QueryNodeException} or if
-   *           there is a node which had no builder associated to it
+   * @throws QueryNodeException if some node builder throws a
+   *         {@link QueryNodeException} or if there is a node which had no
+   *         builder associated to it
    */
   public Object build(QueryNode queryNode) throws QueryNodeException {
     process(queryNode);

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/FieldConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/FieldConfig.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/FieldConfig.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/FieldConfig.java
Tue Jan 25 01:22:35 2011
@@ -28,17 +28,15 @@ import org.apache.lucene.util.AttributeS
  */
 public class FieldConfig extends AttributeSource {
 
-  private CharSequence fieldName;
-
+  private String fieldName;
+  
   /**
    * Constructs a {@link FieldConfig}
    * 
-   * @param fieldName
-   *          the field name, it cannot be null
-   * @throws IllegalArgumentException
-   *           if the field name is null
+   * @param fieldName the field name, it cannot be null
+   * @throws IllegalArgumentException if the field name is null
    */
-  public FieldConfig(CharSequence fieldName) {
+  public FieldConfig(String fieldName) {
 
     if (fieldName == null) {
       throw new IllegalArgumentException("field name should not be null!");
@@ -53,13 +51,14 @@ public class FieldConfig extends Attribu
    * 
    * @return the field name
    */
-  public CharSequence getFieldName() {
+  public String getField() {
     return this.fieldName;
   }
-  
+
   @Override
-  public String toString(){
-    return "<fieldconfig name=\"" + this.fieldName + "\" attributes=\"" + super.toString()
+ "\"/>";
+  public String toString() {
+    return "<fieldconfig name=\"" + this.fieldName + "\" attributes=\""
+        + super.toString() + "\"/>";
   }
 
 }

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/QueryConfigHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/QueryConfigHandler.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/QueryConfigHandler.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/config/QueryConfigHandler.java
Tue Jan 25 01:22:35 2011
@@ -46,7 +46,7 @@ import org.apache.lucene.util.AttributeS
 public abstract class QueryConfigHandler extends AttributeSource {
 
   private LinkedList<FieldConfigListener> listeners = new LinkedList<FieldConfigListener>();
-
+  
   /**
    * Returns an implementation of
    * {@link FieldConfig} for a specific field name. If the implemented
@@ -60,7 +60,7 @@ public abstract class QueryConfigHandler
    *         configuration or <code>null</code>, if the implemented
    *         {@link QueryConfigHandler} has no configuration for that field
    */
-  public FieldConfig getFieldConfig(CharSequence fieldName) {
+  public FieldConfig getFieldConfig(String fieldName) {
     FieldConfig fieldConfig = new FieldConfig(fieldName);
 
     for (FieldConfigListener listener : this.listeners) {

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNode.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNode.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNode.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNode.java
Tue Jan 25 01:22:35 2011
@@ -43,14 +43,14 @@ public interface QueryNode extends Seria
   public boolean isLeaf();
 
   /** verify if a node contains a tag */
-  public boolean containsTag(CharSequence tagName);
-
+  public boolean containsTag(String tagName);
+  
   /**
    * @param tagName
    * @return of stored on under that tag name
    */
-  public Object getTag(CharSequence tagName);
-
+  public Object getTag(String tagName);
+  
   public QueryNode getParent();
 
   /**
@@ -81,15 +81,20 @@ public interface QueryNode extends Seria
    * @param tagName
    * @param value
    */
-  public void setTag(CharSequence tagName, Object value);
-
+  public void setTag(String tagName, Object value);
+  
   /**
    * Unset a tag. tagName will be converted to lowercase.
    * 
    * @param tagName
    */
-  public void unsetTag(CharSequence tagName);
-
-  public Map<CharSequence, Object> getTags();
+  public void unsetTag(String tagName);
+  
+  /**
+   * Returns a map containing all tags attached to this query node. 
+   * 
+   * @return a map containing all tags attached to this query node
+   */
+  public Map<String, Object> getTagMap();
 
 }

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java
Tue Jan 25 01:22:35 2011
@@ -25,6 +25,7 @@ import java.util.ResourceBundle;
 
 import org.apache.lucene.messages.NLS;
 import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
+import org.apache.lucene.queryParser.core.util.StringUtils;
 
 /**
  * A {@link QueryNodeImpl} is the default implementation of the interface
@@ -40,7 +41,7 @@ public abstract class QueryNodeImpl impl
 
   private boolean isLeaf = true;
 
-  private Hashtable<CharSequence, Object> tags = new Hashtable<CharSequence, Object>();
+  private Hashtable<String, Object> tags = new Hashtable<String, Object>();
 
   private List<QueryNode> clauses = null;
 
@@ -117,7 +118,7 @@ public abstract class QueryNodeImpl impl
     clone.isLeaf = this.isLeaf;
 
     // Reset all tags
-    clone.tags = new Hashtable<CharSequence, Object>();
+    clone.tags = new Hashtable<String, Object>();
 
     // copy children
     if (this.clauses != null) {
@@ -151,19 +152,20 @@ public abstract class QueryNodeImpl impl
     return this.clauses;
   }
 
-  public void setTag(CharSequence tagName, Object value) {
-    this.tags.put(tagName.toString().toLowerCase(), value);
+  public void setTag(String tagName, Object value) {
+    this.tags.put(tagName.toLowerCase(), value);
   }
 
-  public void unsetTag(CharSequence tagName) {
-    this.tags.remove(tagName.toString().toLowerCase());
+  public void unsetTag(String tagName) {
+    this.tags.remove(tagName.toLowerCase());
   }
 
-  public boolean containsTag(CharSequence tagName) {
-    return this.tags.containsKey(tagName.toString().toLowerCase());
+  /** verify if a node contains a tag */
+  public boolean containsTag(String tagName) {
+    return this.tags.containsKey(tagName);
   }
 
-  public Object getTag(CharSequence tagName) {
+  public Object getTag(String tagName) {
     return this.tags.get(tagName.toString().toLowerCase());
   }
 
@@ -189,16 +191,20 @@ public abstract class QueryNodeImpl impl
   /**
    * This method is use toQueryString to detect if fld is the default field
    * 
-   * @param fld
-   *          - field name
+   * @param fld - field name
    * @return true if fld is the default field
    */
+  // TODO: remove this method, it's commonly used by {@link
+  // #toQueryString(org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax)}
+  // to figure out what is the default field, however, {@link
+  // #toQueryString(org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax)}
+  // should receive the default field value directly by parameter
   protected boolean isDefaultField(CharSequence fld) {
     if (this.toQueryStringIgnoreFields)
       return true;
     if (fld == null)
       return true;
-    if (QueryNodeImpl.PLAINTEXT_FIELD_NAME.equals(fld.toString()))
+    if (QueryNodeImpl.PLAINTEXT_FIELD_NAME.equals(StringUtils.toString(fld)))
       return true;
     return false;
   }
@@ -216,12 +222,13 @@ public abstract class QueryNodeImpl impl
   }
 
   /**
-   * @see org.apache.lucene.queryParser.core.nodes.QueryNode#getTag(CharSequence)
-   * @return a Map with all tags for this QueryNode
+   * Returns a map containing all tags attached to this query node.
+   * 
+   * @return a map containing all tags attached to this query node
    */
-  @SuppressWarnings( { "unchecked" })
-  public Map<CharSequence, Object> getTags() {
-    return (Map<CharSequence, Object>) this.tags.clone();
+  @SuppressWarnings("unchecked")
+  public Map<String, Object> getTagMap() {
+    return (Map<String, Object>) this.tags.clone();
   }
 
 } // end class QueryNodeImpl

Added: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/StringUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/StringUtils.java?rev=1063095&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/StringUtils.java
(added)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/util/StringUtils.java
Tue Jan 25 01:22:35 2011
@@ -0,0 +1,33 @@
+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.
+ */
+
+final public class StringUtils {
+
+  public static String toString(Object obj) {
+    
+    if (obj != null) {
+      return obj.toString();
+      
+    } else {
+      return null;
+    }
+    
+  }
+  
+}

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapFCListener.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapFCListener.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapFCListener.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapFCListener.java
Tue Jan 25 01:22:35 2011
@@ -47,7 +47,7 @@ public class FieldBoostMapFCListener imp
       FieldBoostMapAttribute fieldBoostMapAttr = this.config.getAttribute(FieldBoostMapAttribute.class);
       BoostAttribute boostAttr = fieldConfig.addAttribute(BoostAttribute.class);
       
-      Float boost = fieldBoostMapAttr.getFieldBoostMap().get(fieldConfig.getFieldName());
+      Float boost = fieldBoostMapAttr.getFieldBoostMap().get(fieldConfig.getField());
 
       if (boost != null) {
         boostAttr.setBoost(boost.floatValue());

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldDateResolutionFCListener.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldDateResolutionFCListener.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldDateResolutionFCListener.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldDateResolutionFCListener.java
Tue Jan 25 01:22:35 2011
@@ -53,7 +53,7 @@ public class FieldDateResolutionFCListen
       FieldDateResolutionMapAttribute dateResMapAttr = this.config
           .addAttribute(FieldDateResolutionMapAttribute.class);
       dateRes = dateResMapAttr.getFieldDateResolutionMap().get(
-          fieldConfig.getFieldName().toString());
+          fieldConfig.getField());
     }
 
     if (dateRes == null) {

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/MultiTermRewriteMethodAttribute.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/MultiTermRewriteMethodAttribute.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/MultiTermRewriteMethodAttribute.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/MultiTermRewriteMethodAttribute.java
Tue Jan 25 01:22:35 2011
@@ -32,7 +32,7 @@ import org.apache.lucene.util.Attribute;
  */
 public interface MultiTermRewriteMethodAttribute extends Attribute {
   
-  public static final CharSequence TAG_ID = "MultiTermRewriteMethodAttribute";
+  public static final String TAG_ID = "MultiTermRewriteMethodAttribute";
   
   public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method);
 

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/BoostQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/BoostQueryNodeProcessor.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/BoostQueryNodeProcessor.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/BoostQueryNodeProcessor.java
Tue Jan 25 01:22:35 2011
@@ -26,6 +26,7 @@ import org.apache.lucene.queryParser.cor
 import org.apache.lucene.queryParser.core.nodes.FieldableNode;
 import org.apache.lucene.queryParser.core.nodes.QueryNode;
 import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
+import org.apache.lucene.queryParser.core.util.StringUtils;
 import org.apache.lucene.queryParser.standard.config.BoostAttribute;
 
 /**
@@ -49,7 +50,8 @@ public class BoostQueryNodeProcessor ext
       QueryConfigHandler config = getQueryConfigHandler();
 
       if (config != null) {
-        FieldConfig fieldConfig = config.getFieldConfig(fieldNode.getField());
+        CharSequence field = fieldNode.getField();
+        FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field));
 
         if (fieldConfig != null && fieldConfig.hasAttribute(BoostAttribute.class))
{
           BoostAttribute boostAttr = fieldConfig.getAttribute(BoostAttribute.class);

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java
Tue Jan 25 01:22:35 2011
@@ -97,8 +97,15 @@ public class ParametricRangeQueryNodePro
 
       }
 
-      FieldConfig fieldConfig = getQueryConfigHandler().getFieldConfig(
-          parametricRangeNode.getField());
+      CharSequence field = parametricRangeNode.getField();
+      String fieldStr = null;
+
+      if (field != null) {
+        fieldStr = field.toString();
+      }
+
+      FieldConfig fieldConfig = getQueryConfigHandler()
+          .getFieldConfig(fieldStr);
 
       if (fieldConfig != null) {
 

Added: lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java?rev=1063095&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
(added)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/builders/TestQueryTreeBuilder.java
Tue Jan 25 01:22:35 2011
@@ -0,0 +1,31 @@
+package org.apache.lucene.queryParser.core.builders;
+
+import junit.framework.Assert;
+
+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.queryParser.core.util.UnescapedCharSequence;
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
+
+public class TestQueryTreeBuilder extends LuceneTestCase {
+  
+  @Test
+  public void testSetFieldBuilder() throws QueryNodeException {
+    QueryTreeBuilder qtb = new QueryTreeBuilder();
+    qtb.setBuilder("field", new DummyBuilder());
+    Object result = qtb.build(new FieldQueryNode(new UnescapedCharSequence("field"), "foo",
0, 0));
+    Assert.assertEquals("OK", result);
+    
+  }
+  
+  private static class DummyBuilder implements QueryBuilder {
+
+    public Object build(QueryNode queryNode) throws QueryNodeException {
+      return "OK";
+    }
+    
+  }
+
+}

Modified: lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/SpansQueryConfigHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/SpansQueryConfigHandler.java?rev=1063095&r1=1063094&r2=1063095&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/SpansQueryConfigHandler.java
(original)
+++ lucene/dev/trunk/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/spans/SpansQueryConfigHandler.java
Tue Jan 25 01:22:35 2011
@@ -33,7 +33,7 @@ public class SpansQueryConfigHandler ext
   }
 
   @Override
-  public FieldConfig getFieldConfig(CharSequence fieldName) {
+  public FieldConfig getFieldConfig(String fieldName) {
 
     // there is no field configuration, always return null
     return null;



Mime
View raw message