1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.mail.search;
  6. import java.util.Date;
  7. import javax.mail.Message;
  8. /**
  9. * This class implements comparisons for the Message SentDate.
  10. *
  11. * @author Bill Shannon
  12. * @author John Mani
  13. */
  14. public final class SentDateTerm extends DateTerm {
  15. /**
  16. * Constructor.
  17. *
  18. * @param comparison the Comparison type
  19. * @param date the date to be compared
  20. */
  21. public SentDateTerm(int comparison, Date date) {
  22. super(comparison, date);
  23. }
  24. /**
  25. * The match method.
  26. *
  27. * @param msg the date comparator is applied to this Message's
  28. * sent date
  29. * @return true if the comparison succeeds, otherwise false
  30. */
  31. public boolean match(Message msg) {
  32. Date d;
  33. try {
  34. d = msg.getSentDate();
  35. } catch (Exception e) {
  36. return false;
  37. }
  38. if (d == null)
  39. return false;
  40. return super.match(d);
  41. }
  42. /**
  43. * Equality comparison.
  44. */
  45. public boolean equals(Object obj) {
  46. if (!(obj instanceof SentDateTerm))
  47. return false;
  48. return super.equals(obj);
  49. }
  50. }