Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldQueryNode.java (working copy) @@ -25,8 +25,7 @@ /** * A {@link FieldQueryNode} represents a element that contains field/text tuple */ -public class FieldQueryNode extends QueryNodeImpl implements TextableQueryNode, - FieldableNode { +public class FieldQueryNode extends QueryNodeImpl implements FieldValuePairQueryNode, TextableQueryNode { /** * The term's field @@ -180,4 +179,14 @@ } + @Override + public CharSequence getValue() { + return getText(); + } + + @Override + public void setValue(CharSequence value) { + setText(value); + } + } Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java (revision 0) @@ -0,0 +1,5 @@ +package org.apache.lucene.queryParser.core.nodes; + +public interface FieldValuePairQueryNode extends FieldableNode, ValueQueryNode { + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/FieldValuePairQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/NumberQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/NumberQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/NumberQueryNode.java (revision 0) @@ -0,0 +1,9 @@ +package org.apache.lucene.queryParser.core.nodes; + +public interface NumberQueryNode { + + void setNumber(Number number); + + Number getNumber(); + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/NumberQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java (revision 0) @@ -0,0 +1,9 @@ +package org.apache.lucene.queryParser.core.nodes; + +public interface ValueQueryNode extends QueryNode { + + public void setValue(T value); + + public T getValue(); + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/ValueQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java (working copy) @@ -39,6 +39,8 @@ import org.apache.lucene.queryParser.standard.config.LowercaseExpandedTermsAttribute; import org.apache.lucene.queryParser.standard.config.MultiFieldAttribute; import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute; +import org.apache.lucene.queryParser.standard.config.NumericConfig; +import org.apache.lucene.queryParser.standard.config.NumericConfigMapAttribute; import org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler; import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute.Operator; @@ -299,6 +301,16 @@ FuzzyAttribute attr = getQueryConfigHandler().addAttribute(FuzzyAttribute.class); attr.setPrefixLength(fuzzyPrefixLength); } + + public void setNumericConfigMap(Map numericConfigMap) { + NumericConfigMapAttribute attr = getQueryConfigHandler().addAttribute(NumericConfigMapAttribute.class); + attr.setNumericConfigMap(numericConfigMap); + } + + public Map getNumericConfigMap() { + NumericConfigMapAttribute attr = getQueryConfigHandler().addAttribute(NumericConfigMapAttribute.class); + return attr.getNumericConfigMap(); + } /** * Set locale used by date range parsing. @@ -307,7 +319,7 @@ LocaleAttribute attr = getQueryConfigHandler().addAttribute(LocaleAttribute.class); attr.setLocale(locale); } - + /** * Returns current locale, allowing access by subclasses. */ Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/RangeQueryNodeBuilder.java (working copy) @@ -1,67 +0,0 @@ -package org.apache.lucene.queryParser.standard.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.nodes.ParametricQueryNode; -import org.apache.lucene.queryParser.core.nodes.QueryNode; -import org.apache.lucene.queryParser.core.nodes.ParametricQueryNode.CompareOperator; -import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute; -import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; -import org.apache.lucene.search.MultiTermQuery; -import org.apache.lucene.search.TermRangeQuery; - -/** - * Builds a {@link TermRangeQuery} object from a {@link RangeQueryNode} object. - */ -public class RangeQueryNodeBuilder implements StandardQueryBuilder { - - public RangeQueryNodeBuilder() { - // empty constructor - } - - public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException { - RangeQueryNode rangeNode = (RangeQueryNode) queryNode; - ParametricQueryNode upper = rangeNode.getUpperBound(); - ParametricQueryNode lower = rangeNode.getLowerBound(); - - boolean lowerInclusive = false; - boolean upperInclusive = false; - - if (upper.getOperator() == CompareOperator.LE) { - upperInclusive = true; - } - - if (lower.getOperator() == CompareOperator.GE) { - lowerInclusive = true; - } - - String field = rangeNode.getField().toString(); - - TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lower.getTextAsString(), upper.getTextAsString(), lowerInclusive, upperInclusive); - - MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID); - if (method != null) { - rangeQuery.setRewriteMethod(method); - } - - return rangeQuery; - - } - -} Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/StandardQueryTreeBuilder.java (working copy) @@ -32,7 +32,7 @@ import org.apache.lucene.queryParser.core.nodes.TokenizedPhraseQueryNode; import org.apache.lucene.queryParser.standard.nodes.MultiPhraseQueryNode; import org.apache.lucene.queryParser.standard.nodes.PrefixWildcardQueryNode; -import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; +import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode; import org.apache.lucene.queryParser.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryParser.standard.nodes.StandardBooleanQueryNode; import org.apache.lucene.queryParser.standard.nodes.WildcardQueryNode; @@ -63,7 +63,7 @@ setBuilder(MatchNoDocsQueryNode.class, new MatchNoDocsQueryNodeBuilder()); setBuilder(PrefixWildcardQueryNode.class, new PrefixWildcardQueryNodeBuilder()); - setBuilder(RangeQueryNode.class, new RangeQueryNodeBuilder()); + setBuilder(TermRangeQueryNode.class, new TermRangeQueryNodeBuilder()); setBuilder(RegexpQueryNode.class, new RegexpQueryNodeBuilder()); setBuilder(SlopQueryNode.class, new SlopQueryNodeBuilder()); setBuilder(StandardBooleanQueryNode.class, Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java (revision 0) @@ -0,0 +1,58 @@ +package org.apache.lucene.queryParser.standard.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.nodes.FieldQueryNode; +import org.apache.lucene.queryParser.core.nodes.QueryNode; +import org.apache.lucene.queryParser.core.util.StringUtils; +import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute; +import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode; +import org.apache.lucene.search.MultiTermQuery; +import org.apache.lucene.search.TermRangeQuery; + +/** + * Builds a {@link TermRangeQuery} object from a {@link TermRangeQueryNode} object. + */ +public class TermRangeQueryNodeBuilder implements StandardQueryBuilder { + + public TermRangeQueryNodeBuilder() { + // empty constructor + } + + public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException { + TermRangeQueryNode rangeNode = (TermRangeQueryNode) queryNode; + FieldQueryNode upper = rangeNode.getUpperBound(); + FieldQueryNode lower = rangeNode.getLowerBound(); + + String field = StringUtils.toString(rangeNode.getField()); + + TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lower + .getTextAsString(), upper.getTextAsString(), rangeNode + .isLowerInclusive(), rangeNode.isUpperInclusive()); + + MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodAttribute.TAG_ID); + if (method != null) { + rangeQuery.setRewriteMethod(method); + } + + return rangeQuery; + + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/builders/TermRangeQueryNodeBuilder.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/DateResolutionAttribute.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/DateResolutionAttribute.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/DateResolutionAttribute.java (working copy) @@ -20,7 +20,7 @@ import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools.Resolution; import org.apache.lucene.queryParser.core.config.QueryConfigHandler; -import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; +import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode; import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor; import org.apache.lucene.util.Attribute; @@ -32,7 +32,7 @@ */ public interface DateResolutionAttribute extends Attribute { /** - * Sets the default date resolution used by {@link RangeQueryNode}s for + * Sets the default date resolution used by {@link TermRangeQueryNode}s for * fields for which no specific date resolutions has been set. Field * specific resolutions can be set with * Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java (revision 0) @@ -0,0 +1,36 @@ +package org.apache.lucene.queryParser.standard.config; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.Date; + +public class NumberDateFormat extends NumberFormat { + + private static final long serialVersionUID = 964823936071308283L; + + final private DateFormat dateFormat; + + public NumberDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + return dateFormat.format(new Date((long) number), toAppendTo, pos); + } + + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + return dateFormat.format(new Date(number), toAppendTo, pos); + } + + @Override + public Number parse(String source, ParsePosition parsePosition) { + return dateFormat.parse(source, parsePosition).getTime(); + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumberDateFormat.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java (revision 0) @@ -0,0 +1,59 @@ +package org.apache.lucene.queryParser.standard.config; + +import java.text.NumberFormat; + +public class NumericConfig { + + private int precisionStep; + + private NumberFormat format; + + public NumericConfig(int precisionStep, NumberFormat format) { + setPrecisionStep(precisionStep); + setNumberFormat(format); + + } + + public int getPrecisionStep() { + return precisionStep; + } + + public void setPrecisionStep(int precisionStep) { + this.precisionStep = precisionStep; + } + + public NumberFormat getNumberFormat() { + return format; + } + + public void setNumberFormat(NumberFormat format) { + + if (format == null) { + throw new IllegalArgumentException("format cannot be null!"); + } + + this.format = format; + + } + + @Override + public boolean equals(Object obj) { + + if (obj == this) + return true; + + if (obj instanceof NumericConfig) { + NumericConfig other = (NumericConfig) obj; + + if (this.precisionStep == other.precisionStep + && this.format == other.format) { + return true; + } + + } + + return false; + + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfig.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttribute.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttribute.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttribute.java (revision 0) @@ -0,0 +1,8 @@ +package org.apache.lucene.queryParser.standard.config; + +import org.apache.lucene.util.Attribute; + +public interface NumericConfigAttribute extends Attribute { + public void setNumericConfig(NumericConfig numericConfig); + public NumericConfig getNumericConfig(); +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttribute.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttributeImpl.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttributeImpl.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttributeImpl.java (revision 0) @@ -0,0 +1,61 @@ +package org.apache.lucene.queryParser.standard.config; + +import org.apache.lucene.util.AttributeImpl; + +public class NumericConfigAttributeImpl extends AttributeImpl + implements NumericConfigAttribute { + + private NumericConfig numericConfig; + + public NumericConfigAttributeImpl() {} + + public void setNumericConfig(NumericConfig numericConfig) { + this.numericConfig = numericConfig; + } + + public NumericConfig getNumericConfig() { + return this.numericConfig; + } + + @Override + public void clear() { + throw new UnsupportedOperationException(); + } + + @Override + public void copyTo(AttributeImpl target) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object other) { + + if (other instanceof NumericConfigAttributeImpl) { + NumericConfigAttributeImpl numericConfigAttr = (NumericConfigAttributeImpl) other; + + if (numericConfigAttr.numericConfig == this.numericConfig + || (this.numericConfig != null && numericConfigAttr.numericConfig != null && this.numericConfig + .equals(numericConfigAttr.numericConfig))) { + + return true; + + } + + } + + return false; + + } + + @Override + public int hashCode() { + return this.numericConfig.hashCode(); + } + + @Override + public String toString() { + return ""; + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigAttributeImpl.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttribute.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttribute.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttribute.java (revision 0) @@ -0,0 +1,13 @@ +package org.apache.lucene.queryParser.standard.config; + +import java.util.Map; + +import org.apache.lucene.util.Attribute; + +public interface NumericConfigMapAttribute extends Attribute { + + public void setNumericConfigMap(Map numericConfigMap); + + public Map getNumericConfigMap(); + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttribute.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttributeImpl.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttributeImpl.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttributeImpl.java (revision 0) @@ -0,0 +1,64 @@ +package org.apache.lucene.queryParser.standard.config; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.lucene.util.AttributeImpl; + +public class NumericConfigMapAttributeImpl extends AttributeImpl + implements NumericConfigMapAttribute { + + private Map numericConfigMap = new LinkedHashMap(); + + + public NumericConfigMapAttributeImpl() { + // empty constructor + } + + public void setNumericConfigMap(Map numericConfigMap) { + this.numericConfigMap = numericConfigMap; + } + + public Map getNumericConfigMap() { + return this.numericConfigMap; + } + + @Override + public void clear() { + throw new UnsupportedOperationException(); + } + + @Override + public void copyTo(AttributeImpl target) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object other) { + + if (other instanceof NumericConfigMapAttributeImpl + && ((NumericConfigMapAttributeImpl) other).numericConfigMap.equals(this.numericConfigMap) ) { + + return true; + + } + + return false; + + } + + @Override + public int hashCode() { + final int prime = 97; + if (this.numericConfigMap != null) + return this.numericConfigMap.hashCode() * prime; + else + return Float.valueOf(prime).hashCode(); + } + + @Override + public String toString() { + return ""; + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericConfigMapAttributeImpl.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java (revision 0) @@ -0,0 +1,38 @@ +package org.apache.lucene.queryParser.standard.config; + +import org.apache.lucene.queryParser.core.config.FieldConfig; +import org.apache.lucene.queryParser.core.config.FieldConfigListener; +import org.apache.lucene.queryParser.core.config.QueryConfigHandler; + +public class NumericFieldConfigListener implements FieldConfigListener { + + final private QueryConfigHandler config; + + public NumericFieldConfigListener(QueryConfigHandler config) { + + if (config == null) { + throw new IllegalArgumentException("config cannot be null!"); + } + + this.config = config; + + } + + @Override + public void buildFieldConfig(FieldConfig fieldConfig) { + + if (config.hasAttribute(NumericConfigMapAttribute.class)) { + NumericConfigMapAttribute numericConfigMapAtt = config.getAttribute(NumericConfigMapAttribute.class); + NumericConfig numericConfig = numericConfigMapAtt.getNumericConfigMap().get(fieldConfig.getField()); + + if (numericConfig != null) { + NumericConfigAttribute att = fieldConfig.addAttribute(NumericConfigAttribute.class); + att.setNumericConfig(numericConfig); + + } + + } + + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/NumericFieldConfigListener.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/AbstractRangeQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/AbstractRangeQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/AbstractRangeQueryNode.java (revision 0) @@ -0,0 +1,118 @@ +package org.apache.lucene.queryParser.standard.nodes; + + +import org.apache.lucene.queryParser.core.nodes.FieldValuePairQueryNode; +import org.apache.lucene.queryParser.core.nodes.FieldableNode; +import org.apache.lucene.queryParser.core.nodes.QueryNodeImpl; +import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax; +import org.apache.lucene.queryParser.core.util.StringUtils; + +public abstract class AbstractRangeQueryNode> + extends QueryNodeImpl implements FieldableNode { + + private T lower, upper; + + private boolean lowerInclusive, upperInclusive; + + @Override + public CharSequence getField() { + CharSequence field = null; + + if (lower != null) { + field = lower.getField(); + + } else if (upper != null) { + field = upper.getField(); + } + + return field; + + } + + @Override + public void setField(CharSequence fieldName) { + + if (lower != null) { + lower.setField(fieldName); + } + + if (upper != null) { + upper.setField(fieldName); + } + + } + + public T getLowerBound() { + return lower; + } + + public T getUpperBound() { + return upper; + } + + public boolean isLowerInclusive() { + return lowerInclusive; + } + + public boolean isUpperInclusive() { + return upperInclusive; + } + + public void setBounds(T lower, T upper, boolean lowerInclusive, + boolean upperInclusive) { + + if (lower != null && upper != null) { + String lowerField = StringUtils.toString(lower.getField()); + String upperField = StringUtils.toString(upper.getField()); + + if (lowerField != null && upperField != null + && !upperField.equals(lowerField) + || lowerField != upperField) { + throw new IllegalArgumentException( + "lower and upper bounds should have the same field name!"); + } + + } + + } + + @Override + public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { + StringBuilder sb = new StringBuilder(); + + if (lowerInclusive) { + sb.append('['); + + } else { + sb.append('{'); + } + + if (lower != null) { + sb.append(lower.toQueryString(escapeSyntaxParser)); + + } else { + sb.append("..."); + } + + sb.append(' '); + + + if (upper != null) { + sb.append(upper.toQueryString(escapeSyntaxParser)); + + } else { + sb.append("..."); + } + + if (upperInclusive) { + sb.append(']'); + + } else { + sb.append('}'); + } + + return sb.toString(); + + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/AbstractRangeQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericQueryNode.java (revision 0) @@ -0,0 +1,62 @@ +package org.apache.lucene.queryParser.standard.nodes; + +import java.text.NumberFormat; +import java.util.Locale; + +import org.apache.lucene.queryParser.core.nodes.FieldValuePairQueryNode; +import org.apache.lucene.queryParser.core.nodes.QueryNodeImpl; +import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax; +import org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax.Type; + +public class NumericQueryNode extends QueryNodeImpl implements + FieldValuePairQueryNode { + + private NumberFormat numberFormat; + + private CharSequence field; + + private Number value; + + @Override + public CharSequence getField() { + return this.field; + } + + @Override + public void setField(CharSequence fieldName) { + this.field = fieldName; + } + + protected CharSequence getTermEscaped(EscapeQuerySyntax escaper) { + return escaper.escape(NumberFormat.getNumberInstance().format( + this.value), Locale.ENGLISH, Type.NORMAL); + } + + @Override + public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) { + if (isDefaultField(this.field)) { + return getTermEscaped(escapeSyntaxParser); + } else { + return this.field + ":" + getTermEscaped(escapeSyntaxParser); + } + } + + public void setNumberFormat(NumberFormat format) { + this.numberFormat = format; + } + + public NumberFormat getNumberFormat() { + return this.numberFormat; + } + + @Override + public Number getValue() { + return value; + } + + @Override + public void setValue(Number value) { + this.value = value; + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericRangeQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericRangeQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericRangeQueryNode.java (revision 0) @@ -0,0 +1,9 @@ +package org.apache.lucene.queryParser.standard.nodes; + +public class NumericRangeQueryNode extends AbstractRangeQueryNode { + + public NumericRangeQueryNode(NumericQueryNode lower, NumericQueryNode upper, boolean lowerInclusive, boolean upperInclusive) { + setBounds(lower, upper, lowerInclusive, upperInclusive); + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/NumericRangeQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/RangeQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/RangeQueryNode.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/RangeQueryNode.java (working copy) @@ -1,50 +0,0 @@ -package org.apache.lucene.queryParser.standard.nodes; - -/** - * 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.nodes.ParametricQueryNode; -import org.apache.lucene.queryParser.core.nodes.ParametricRangeQueryNode; -import org.apache.lucene.queryParser.standard.processors.ParametricRangeQueryNodeProcessor; - -/** - * This query node represents a range query. - * - * @see ParametricRangeQueryNodeProcessor - * @see org.apache.lucene.search.TermRangeQuery - */ -public class RangeQueryNode extends ParametricRangeQueryNode { - - /** - * @param lower - * @param upper - */ - public RangeQueryNode(ParametricQueryNode lower, ParametricQueryNode upper) { - super(lower, upper); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("\n\t"); - sb.append(this.getUpperBound()).append("\n\t"); - sb.append(this.getLowerBound()).append("\n"); - sb.append("\n"); - - return sb.toString(); - - } -} Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/TermRangeQueryNode.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/TermRangeQueryNode.java (revision 0) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/TermRangeQueryNode.java (revision 0) @@ -0,0 +1,34 @@ +package org.apache.lucene.queryParser.standard.nodes; + +/** + * 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.nodes.FieldQueryNode; + +/** + * This query node represents a range query. + * + * @see ParametricRangeQueryNodeProcessor + * @see org.apache.lucene.search.TermRangeQuery + */ +public class TermRangeQueryNode extends AbstractRangeQueryNode { + + public TermRangeQueryNode(FieldQueryNode lower, FieldQueryNode upper, boolean lowerInclusive, boolean upperInclusive) { + setBounds(lower, upper, lowerInclusive, upperInclusive); + } + +} Property changes on: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/nodes/TermRangeQueryNode.java ___________________________________________________________________ Added: svn:keywords + Rev Date Added: svn:eol-style + native Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java =================================================================== --- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java (revision 1132489) +++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/processors/ParametricRangeQueryNodeProcessor.java (working copy) @@ -35,14 +35,14 @@ import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl; import org.apache.lucene.queryParser.standard.config.DateResolutionAttribute; import org.apache.lucene.queryParser.standard.config.LocaleAttribute; -import org.apache.lucene.queryParser.standard.nodes.RangeQueryNode; +import org.apache.lucene.queryParser.standard.nodes.TermRangeQueryNode; /** * This processor converts {@link ParametricRangeQueryNode} objects to - * {@link RangeQueryNode} objects. It reads the lower and upper bounds value + * {@link TermRangeQueryNode} objects. It reads the lower and upper bounds value * from the {@link ParametricRangeQueryNode} object and try to parse their * values using a {@link DateFormat}. If the values cannot be parsed to a date - * value, it will only create the {@link RangeQueryNode} using the non-parsed + * value, it will only create the {@link TermRangeQueryNode} using the non-parsed * values.
*
* If a {@link LocaleAttribute} is defined in the {@link QueryConfigHandler} it @@ -55,7 +55,7 @@ * * @see DateResolutionAttribute * @see LocaleAttribute - * @see RangeQueryNode + * @see TermRangeQueryNode * @see ParametricRangeQueryNode */ public class ParametricRangeQueryNodeProcessor extends QueryNodeProcessorImpl { @@ -136,11 +136,13 @@ } catch (Exception e) { // do nothing } - + lower.setText(part1); upper.setText(part2); - return new RangeQueryNode(lower, upper); + return new TermRangeQueryNode(lower, upper, + upper.getOperator() == CompareOperator.LE, upper + .getOperator() == CompareOperator.GE); }