KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > mail > search > SentDateTerm


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)SentDateTerm.java 1.8 05/08/29
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package javax.mail.search;
29
30 import java.util.Date JavaDoc;
31 import javax.mail.Message JavaDoc;
32
33 /**
34  * This class implements comparisons for the Message SentDate.
35  *
36  * @author Bill Shannon
37  * @author John Mani
38  */

39 public final class SentDateTerm extends DateTerm JavaDoc {
40
41     private static final long serialVersionUID = 5647755030530907263L;
42
43     /**
44      * Constructor.
45      *
46      * @param comparison the Comparison type
47      * @param date the date to be compared
48      */

49     public SentDateTerm(int comparison, Date JavaDoc date) {
50     super(comparison, date);
51     }
52
53     /**
54      * The match method.
55      *
56      * @param msg the date comparator is applied to this Message's
57      * sent date
58      * @return true if the comparison succeeds, otherwise false
59      */

60     public boolean match(Message JavaDoc msg) {
61     Date JavaDoc d;
62
63     try {
64         d = msg.getSentDate();
65     } catch (Exception JavaDoc e) {
66         return false;
67     }
68
69     if (d == null)
70         return false;
71
72     return super.match(d);
73     }
74
75     /**
76      * Equality comparison.
77      */

78     public boolean equals(Object JavaDoc obj) {
79     if (!(obj instanceof SentDateTerm JavaDoc))
80         return false;
81     return super.equals(obj);
82     }
83 }
84
Popular Tags