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 Message change events.
  10. *
  11. * @author John Mani
  12. */
  13. public class MessageChangedEvent extends MailEvent {
  14. /** The message's flags changed. */
  15. public static final int FLAGS_CHANGED = 1;
  16. /** The message's envelope (headers, but not body) changed. */
  17. public static final int ENVELOPE_CHANGED = 2;
  18. /**
  19. * The event type.
  20. *
  21. * @serial
  22. */
  23. protected int type;
  24. /**
  25. * The message that changed.
  26. */
  27. transient protected Message msg;
  28. /**
  29. * Constructor.
  30. * @param source The folder that owns the message
  31. * @param type The change type
  32. * @param msg The changed message
  33. */
  34. public MessageChangedEvent(Object source, int type, Message msg) {
  35. super(source);
  36. this.msg = msg;
  37. this.type = type;
  38. }
  39. /**
  40. * Return the type of this event.
  41. * @return type
  42. */
  43. public int getMessageChangeType() {
  44. return type;
  45. }
  46. /**
  47. * Return the changed Message.
  48. * @return the message
  49. */
  50. public Message getMessage() {
  51. return msg;
  52. }
  53. /**
  54. * Invokes the appropriate MessageChangedListener method.
  55. */
  56. public void dispatch(Object listener) {
  57. ((MessageChangedListener)listener).messageChanged(this);
  58. }
  59. }