1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package javax.mail.search; |
19 |
| |
20 |
| import java.util.Date; |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| public abstract class DateTerm extends ComparisonTerm { |
26 |
| protected Date date; |
27 |
| |
28 |
0
| protected DateTerm(int comparison, Date date) {
|
29 |
0
| super();
|
30 |
0
| this.comparison = comparison;
|
31 |
0
| this.date = date;
|
32 |
| } |
33 |
| |
34 |
0
| public Date getDate() {
|
35 |
0
| return date;
|
36 |
| } |
37 |
| |
38 |
0
| public int getComparison() {
|
39 |
0
| return comparison;
|
40 |
| } |
41 |
| |
42 |
0
| protected boolean match(Date match) {
|
43 |
0
| long matchTime = match.getTime();
|
44 |
0
| long mytime = date.getTime();
|
45 |
0
| switch (comparison) {
|
46 |
0
| case EQ:
|
47 |
0
| return matchTime == mytime;
|
48 |
0
| case NE:
|
49 |
0
| return matchTime != mytime;
|
50 |
0
| case LE:
|
51 |
0
| return matchTime <= mytime;
|
52 |
0
| case LT:
|
53 |
0
| return matchTime < mytime;
|
54 |
0
| case GT:
|
55 |
0
| return matchTime > mytime;
|
56 |
0
| case GE:
|
57 |
0
| return matchTime >= mytime;
|
58 |
0
| default:
|
59 |
0
| return false;
|
60 |
| } |
61 |
| } |
62 |
| |
63 |
0
| public boolean equals(Object other) {
|
64 |
0
| if (other == this) return true;
|
65 |
0
| if (other instanceof DateTerm == false) return false;
|
66 |
0
| final DateTerm term = (DateTerm) other;
|
67 |
0
| return this.comparison == term.comparison && this.date.equals(term.date);
|
68 |
| } |
69 |
| |
70 |
0
| public int hashCode() {
|
71 |
0
| return date.hashCode();
|
72 |
| } |
73 |
| } |