javax.mail.search
abstract public class: DateTerm [javadoc |
source]
java.lang.Object
javax.mail.search.SearchTerm
javax.mail.search.ComparisonTerm
javax.mail.search.DateTerm
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ReceivedDateTerm, SentDateTerm
This class implements comparisons for Dates
- author:
Bill
- Shannon
- author:
John
- Mani
Field Summary |
---|
protected Date | date | The date. |
Constructor: |
protected DateTerm(int comparison,
Date date) {
this.comparison = comparison;
this.date = date;
}
Parameters:
comparison - the comparison type
date - The Date to be compared against
|
Methods from javax.mail.search.SearchTerm: |
---|
match |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.mail.search.DateTerm Detail: |
public boolean equals(Object obj) {
if (!(obj instanceof DateTerm))
return false;
DateTerm dt = (DateTerm)obj;
return dt.date.equals(this.date) && super.equals(obj);
}
|
public int getComparison() {
return comparison;
}
Return the type of comparison. |
public Date getDate() {
return new Date(date.getTime());
}
Return the Date to compare with. |
public int hashCode() {
return date.hashCode() + super.hashCode();
}
Compute a hashCode for this object. |
protected boolean match(Date d) {
switch (comparison) {
case LE:
return d.before(date) || d.equals(date);
case LT:
return d.before(date);
case EQ:
return d.equals(date);
case NE:
return !d.equals(date);
case GT:
return d.after(date);
case GE:
return d.after(date) || d.equals(date);
default:
return false;
}
}
The date comparison method. |