1 21 22 27 28 package javax.mail.search; 29 30 import java.util.Date ; 31 32 38 public abstract class DateTerm extends ComparisonTerm { 39 44 protected Date date; 45 46 private static final long serialVersionUID = 4818873430063720043L; 47 48 53 protected DateTerm(int comparison, Date date) { 54 this.comparison = comparison; 55 this.date = date; 56 } 57 58 61 public Date getDate() { 62 return new Date (date.getTime()); 63 } 64 65 68 public int getComparison() { 69 return comparison; 70 } 71 72 78 protected boolean match(Date d) { 79 switch (comparison) { 80 case LE: 81 return d.before(date) || d.equals(date); 82 case LT: 83 return d.before(date); 84 case EQ: 85 return d.equals(date); 86 case NE: 87 return !d.equals(date); 88 case GT: 89 return d.after(date); 90 case GE: 91 return d.after(date) || d.equals(date); 92 default: 93 return false; 94 } 95 } 96 97 100 public boolean equals(Object obj) { 101 if (!(obj instanceof DateTerm )) 102 return false; 103 DateTerm dt = (DateTerm )obj; 104 return dt.date.equals(this.date) && super.equals(obj); 105 } 106 107 110 public int hashCode() { 111 return date.hashCode() + super.hashCode(); 112 } 113 } 114 | Popular Tags |