lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r328729 - in /lucene/java/trunk/src/java/org/apache/lucene/search: CachingWrapperFilter.java QueryFilter.java RangeFilter.java
Date Wed, 26 Oct 2005 21:05:49 GMT
Author: yonik
Date: Wed Oct 26 14:05:35 2005
New Revision: 328729

URL: http://svn.apache.org/viewcvs?rev=328729&view=rev
Log:
add hashCode and equals to filters LUCENE-439

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java?rev=328729&r1=328728&r2=328729&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/CachingWrapperFilter.java Wed Oct
26 14:05:35 2005
@@ -68,4 +68,13 @@
   public String toString() {
     return "CachingWrapperFilter("+filter+")";
   }
+
+  public boolean equals(Object o) {
+    if (!(o instanceof CachingWrapperFilter)) return false;
+    return this.filter.equals(((CachingWrapperFilter)o).filter);
+  }
+
+  public int hashCode() {
+    return filter.hashCode() ^ 0x1117BF25;  
+  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java?rev=328729&r1=328728&r2=328729&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java Wed Oct 26 14:05:35
2005
@@ -75,4 +75,13 @@
   public String toString() {
     return "QueryFilter("+query+")";
   }
+
+  public boolean equals(Object o) {
+    if (!(o instanceof QueryFilter)) return false;
+    return this.query.equals(((QueryFilter)o).query);
+  }
+
+  public int hashCode() {
+    return query.hashCode() ^ 0x923F64B9;  
+  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java?rev=328729&r1=328728&r2=328729&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RangeFilter.java Wed Oct 26 14:05:35
2005
@@ -167,4 +167,30 @@
         buffer.append(includeUpper ? "]" : "}");
         return buffer.toString();
     }
+
+    /** Returns true if <code>o</code> is equal to this. */
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof RangeFilter)) return false;
+        RangeFilter other = (RangeFilter) o;
+
+        if (!this.fieldName.equals(other.fieldName)
+            || this.includeLower != other.includeLower
+            || this.includeUpper != other.includeUpper
+           ) { return false; }
+        if (this.lowerTerm != null ? !this.lowerTerm.equals(other.lowerTerm) : other.lowerTerm
!= null) return false;
+        if (this.upperTerm != null ? !this.upperTerm.equals(other.upperTerm) : other.upperTerm
!= null) return false;
+        return true;
+    }
+
+    /** Returns a hash code value for this object.*/
+    public int hashCode() {
+      int h = fieldName.hashCode();
+      h ^= lowerTerm != null ? lowerTerm.hashCode() : 0xB6ECE882;
+      h = (h << 1) | (h >>> 31);  // rotate to distinguish lower from upper
+      h ^= (upperTerm != null ? (upperTerm.hashCode()) : 0x91BEC2C2);
+      h ^= (includeLower ? 0xD484B933 : 0)
+         ^ (includeUpper ? 0x6AE423AC : 0);
+      return h;
+    }
 }



Mime
View raw message