001 /**
002 *
003 * Copyright 2003-2006 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package javax.mail.event;
019
020 import javax.mail.Message;
021
022 /**
023 * @version $Rev: 421852 $ $Date: 2006-07-14 03:02:19 -0700 (Fri, 14 Jul 2006) $
024 */
025 public class MessageChangedEvent extends MailEvent {
026 /**
027 * The message's flags changed.
028 */
029 public static final int FLAGS_CHANGED = 1;
030
031 /**
032 * The messages envelope changed.
033 */
034 public static final int ENVELOPE_CHANGED = 2;
035
036 protected transient Message msg;
037 protected int type;
038
039 /**
040 * Constructor.
041 *
042 * @param source the folder that owns the message
043 * @param type the event type
044 * @param message the affected message
045 */
046 public MessageChangedEvent(Object source, int type, Message message) {
047 super(source);
048 msg = message;
049 this.type = type;
050 }
051
052 public void dispatch(Object listener) {
053 MessageChangedListener l = (MessageChangedListener) listener;
054 l.messageChanged(this);
055 }
056
057 /**
058 * Return the affected message.
059 * @return the affected message
060 */
061 public Message getMessage() {
062 return msg;
063 }
064
065 /**
066 * Return the type of change.
067 * @return the event type
068 */
069 public int getMessageChangeType() {
070 return type;
071 }
072 }