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 javax.mail.Message;
  7. /**
  8. * This class implements comparisons for Message numbers.
  9. *
  10. * @author Bill Shannon
  11. * @author John Mani
  12. */
  13. public final class MessageNumberTerm extends IntegerComparisonTerm {
  14. /**
  15. * Constructor.
  16. *
  17. * @param number the Message number
  18. */
  19. public MessageNumberTerm(int number) {
  20. super(EQ, number);
  21. }
  22. /**
  23. * The match method.
  24. *
  25. * @param msg the Message number is matched with this Message
  26. * @return true if the match succeeds, otherwise false
  27. */
  28. public boolean match(Message msg) {
  29. int msgno;
  30. try {
  31. msgno = msg.getMessageNumber();
  32. } catch (Exception e) {
  33. return false;
  34. }
  35. return super.match(msgno);
  36. }
  37. /**
  38. * Equality comparison.
  39. */
  40. public boolean equals(Object obj) {
  41. if (!(obj instanceof MessageNumberTerm))
  42. return false;
  43. return super.equals(obj);
  44. }
  45. }