diff --git a/src/java/org/apache/lucene/search/NumericRangeQuery.java b/src/java/org/apache/lucene/search/NumericRangeQuery.java index c34d19872cb..e78912ebf19 100644 --- a/src/java/org/apache/lucene/search/NumericRangeQuery.java +++ b/src/java/org/apache/lucene/search/NumericRangeQuery.java @@ -227,7 +227,8 @@ public final class NumericRangeQuery extends MultiTermQuery { //@Override public final boolean equals(final Object o) { if (o==this) return true; - if (o==null) return false; + if (!super.equals(o)) + return false; if (o instanceof NumericRangeQuery) { final NumericRangeQuery q=(NumericRangeQuery)o; return ( @@ -236,8 +237,7 @@ public final class NumericRangeQuery extends MultiTermQuery { (q.max == null ? max == null : q.max.equals(max)) && minInclusive == q.minInclusive && maxInclusive == q.maxInclusive && - precisionStep == q.precisionStep && - getBoost() == q.getBoost() + precisionStep == q.precisionStep ); } return false; @@ -245,11 +245,11 @@ public final class NumericRangeQuery extends MultiTermQuery { //@Override public final int hashCode() { - int hash = Float.floatToIntBits(getBoost()) ^ field.hashCode(); - hash += precisionStep^0x64365465; + int hash = super.hashCode(); + hash += field.hashCode()^0x4565fd66 + precisionStep^0x64365465; if (min != null) hash += min.hashCode()^0x14fa55fb; if (max != null) hash += max.hashCode()^0x733fa5fe; - return hash+ + return hash + (Boolean.valueOf(minInclusive).hashCode()^0x14fa55fb)+ (Boolean.valueOf(maxInclusive).hashCode()^0x733fa5fe); } diff --git a/src/java/org/apache/lucene/search/TermRangeFilter.java b/src/java/org/apache/lucene/search/TermRangeFilter.java index e5571933b2e..44ff6489c2e 100644 --- a/src/java/org/apache/lucene/search/TermRangeFilter.java +++ b/src/java/org/apache/lucene/search/TermRangeFilter.java @@ -85,4 +85,22 @@ public class TermRangeFilter extends MultiTermQueryWrapperFilter { public static TermRangeFilter More(String fieldName, String lowerTerm) { return new TermRangeFilter(fieldName, lowerTerm, null, true, false); } + + /** Returns the field name for this filter */ + public String getField() { return ((TermRangeQuery) query).getField(); } + + /** Returns the lower value of this range filter */ + public String getLowerTerm() { return ((TermRangeQuery) query).getLowerTerm(); } + + /** Returns the upper value of this range filter */ + public String getUpperTerm() { return ((TermRangeQuery) query).getUpperTerm(); } + + /** Returns true if the lower endpoint is inclusive */ + public boolean includesLower() { return ((TermRangeQuery) query).includesLower(); } + + /** Returns true if the upper endpoint is inclusive */ + public boolean includesUpper() { return ((TermRangeQuery) query).includesUpper(); } + + /** Returns the collator used to determine range inclusion, if any. */ + public Collator getCollator() { return ((TermRangeQuery) query).getCollator(); } } diff --git a/src/java/org/apache/lucene/search/TermRangeQuery.java b/src/java/org/apache/lucene/search/TermRangeQuery.java index 4ebae13cdb2..b588551aefa 100644 --- a/src/java/org/apache/lucene/search/TermRangeQuery.java +++ b/src/java/org/apache/lucene/search/TermRangeQuery.java @@ -113,9 +113,7 @@ public class TermRangeQuery extends MultiTermQuery { } /** Returns the field name for this query */ - public String getField() { - return field; - } + public String getField() { return field; } /** Returns the lower value of this range query */ public String getLowerTerm() { return lowerTerm; } @@ -133,8 +131,8 @@ public class TermRangeQuery extends MultiTermQuery { public Collator getCollator() { return collator; } protected FilteredTermEnum getEnum(IndexReader reader) throws IOException { - return new TermRangeTermEnum(reader, collator, field, lowerTerm, - upperTerm, includeLower, includeUpper); + return new TermRangeTermEnum(reader, field, lowerTerm, + upperTerm, includeLower, includeUpper, collator); } /** Prints a user-readable version of this query. */ diff --git a/src/java/org/apache/lucene/search/TermRangeTermEnum.java b/src/java/org/apache/lucene/search/TermRangeTermEnum.java index ebb13c3d364..c5f65c92249 100644 --- a/src/java/org/apache/lucene/search/TermRangeTermEnum.java +++ b/src/java/org/apache/lucene/search/TermRangeTermEnum.java @@ -50,10 +50,6 @@ public class TermRangeTermEnum extends FilteredTermEnum { * explicitly specifying the term to exclude.) * * @param reader - * @param collator - * The collator to use to collate index Terms, to determine their - * membership in the range bounded by lowerTerm and - * upperTerm. * @param field * An interned field that holds both lower and upper terms. * @param lowerTermText @@ -64,11 +60,15 @@ public class TermRangeTermEnum extends FilteredTermEnum { * If true, the lowerTerm is included in the range. * @param includeUpper * If true, the upperTerm is included in the range. + * @param collator + * The collator to use to collate index Terms, to determine their + * membership in the range bounded by lowerTerm and + * upperTerm. * * @throws IOException */ - public TermRangeTermEnum(IndexReader reader, Collator collator, String field, - String lowerTermText, String upperTermText, boolean includeLower, boolean includeUpper) throws IOException { + public TermRangeTermEnum(IndexReader reader, String field, String lowerTermText, String upperTermText, + boolean includeLower, boolean includeUpper, Collator collator) throws IOException { this.collator = collator; this.upperTermText = upperTermText; this.lowerTermText = lowerTermText;