lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r170853 - /lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
Date Thu, 19 May 2005 01:30:45 GMT
Author: ehatcher
Date: Wed May 18 18:30:43 2005
New Revision: 170853

URL: http://svn.apache.org/viewcvs?rev=170853&view=rev
Log:
add .equals/.hashCode to SpanTermQuery to allow comparison and collections to work logically.
 The other SpanQuery subclasses should probably have a similar adjustment and I will take
care of those as I run into cases where it is necessary

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java?rev=170853&r1=170852&r2=170853&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanTermQuery.java Wed May 18
18:30:43 2005
@@ -50,6 +50,20 @@
       return term.toString();
   }
 
+  /** Returns true iff <code>o</code> is equal to this. */
+  public boolean equals(Object o) {
+    if (!(o instanceof SpanTermQuery))
+      return false;
+    SpanTermQuery other = (SpanTermQuery)o;
+    return (this.getBoost() == other.getBoost())
+      && this.term.equals(other.term);
+  }
+
+  /** Returns a hash code value for this object.*/
+  public int hashCode() {
+    return Float.floatToIntBits(getBoost()) ^ term.hashCode();
+  }
+
   public Spans getSpans(final IndexReader reader) throws IOException {
     return new Spans() {
         private TermPositions positions = reader.termPositions(term);



Mime
View raw message