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.event;
  6. import java.util.*;
  7. import javax.mail.*;
  8. /**
  9. * This class models notifications from the Store connection. These
  10. * notifications can be ALERTS or NOTICES. ALERTS must be presented
  11. * to the user in a fashion that calls the user's attention to the
  12. * message.
  13. *
  14. * @author John Mani
  15. */
  16. public class StoreEvent extends MailEvent {
  17. /**
  18. * Indicates that this message is an ALERT.
  19. */
  20. public static final int ALERT = 1;
  21. /**
  22. * Indicates that this message is a NOTICE.
  23. */
  24. public static final int NOTICE = 2;
  25. /**
  26. * The event type.
  27. *
  28. * @serial
  29. */
  30. protected int type;
  31. /**
  32. * The message text to be presented to the user.
  33. *
  34. * @serial
  35. */
  36. protected String message;
  37. /**
  38. * Constructor.
  39. * @param source The source Store
  40. */
  41. public StoreEvent(Store store, int type, String message) {
  42. super(store);
  43. this.type = type;
  44. this.message = message;
  45. }
  46. /**
  47. * Return the type of this event.
  48. *
  49. * @return type
  50. * @see #ALERT
  51. * @see #NOTICE
  52. */
  53. public int getMessageType() {
  54. return type;
  55. }
  56. /**
  57. * Get the message from the Store.
  58. *
  59. * @return message from the Store
  60. */
  61. public String getMessage() {
  62. return message;
  63. }
  64. /**
  65. * Invokes the appropriate StoreListener method.
  66. */
  67. public void dispatch(Object listener) {
  68. ((StoreListener)listener).notification(this);
  69. }
  70. }