bug fixes
[IRC.git] / Robust / src / Benchmarks / Distributed / SpamFilter / HashEntry.java
1 public class HashEntry {
2   GString engine;
3   GString signature;
4   HashStat stats;
5   public HashEntry() {
6   }
7
8   /**
9    * hashCode that combines two strings using xor.
10    * @return a hash code value on the entire object.
11    */
12   public int hashCode() {
13     int result=0;
14     // this will not work well if some of the strings are equal.
15     result = engine.hashCode();
16     result ^= signature.hashCode();
17     //result ^= stats.hashCode();
18     //System.out.println("HashEntry: hashCode= " + result);
19     return result;
20   }
21
22   public void setengine(GString engine) {
23     this.engine=engine;
24   }
25
26   public void setstats(HashStat stats) {
27     this.stats=stats;
28   }
29
30   public void setsig(GString signature) {
31     this.signature=signature;
32   }
33
34   public GString getEngine() {
35     return engine;
36   }
37
38   public GString getSignature() {
39     return signature;
40   }
41
42   public HashStat getStats() {
43     return stats;
44   }
45
46   public boolean equals(Object o) {
47     if(o.getType()!=getType())
48       return false;
49     HashEntry he = (HashEntry)o;
50     if(!(he.getEngine().equals(engine)))
51       return false;
52     if(!(he.getSignature().equals(signature)))
53       return false;
54     //if(!(he.getStats().equals(stats)))
55     //  return false;
56     return true;
57   }
58
59   public int askForSpam() {
60     int[] users = stats.getUsers();
61     int spamConfidence=0;
62     for(int i=0; i<users.length; i++) {
63       int userid = users[i];
64       spamConfidence += stats.userstat[userid].getChecked();
65     }
66     return spamConfidence;
67   }
68 }