001    /**
002     *
003     * Copyright 2003-2004 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.Store;
021    
022    /**
023     * Event representing motifications from the Store connection.
024     *
025     * @version $Rev: 125583 $ $Date: 2005-01-18 19:44:27 -0800 (Tue, 18 Jan 2005) $
026     */
027    public class StoreEvent extends MailEvent {
028        /**
029         * Indicates that this message is an alert.
030         */
031        public static final int ALERT = 1;
032    
033        /**
034         * Indicates that this message is a notice.
035         */
036        public static final int NOTICE = 2;
037    
038        /**
039         * The message type.
040         */
041        protected int type;
042    
043        /**
044         * The text to be presented to the user.
045         */
046        protected String message;
047    
048        /**
049         * Construct a new event.
050         *
051         * @param store   the Store that initiated the notification
052         * @param type    the message type
053         * @param message the text to be presented to the user
054         */
055        public StoreEvent(Store store, int type, String message) {
056            super(store);
057            this.type = type;
058            this.message = message;
059        }
060    
061        /**
062         * Return the message type.
063         *
064         * @return the message type
065         */
066        public int getMessageType() {
067            return type;
068        }
069    
070        /**
071         * Return the text to be displayed to the user.
072         *
073         * @return the text to be displayed to the user
074         */
075        public String getMessage() {
076            return message;
077        }
078    
079        public void dispatch(Object listener) {
080            ((StoreListener) listener).notification(this);
081        }
082    }