0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A *
292N/A * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
0N/A *
0N/A * The contents of this file are subject to the terms of either the GNU
0N/A * General Public License Version 2 only ("GPL") or the Common Development
0N/A * and Distribution License("CDDL") (collectively, the "License"). You
292N/A * may not use this file except in compliance with the License. You can
292N/A * obtain a copy of the License at
292N/A * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
292N/A * or packager/legal/LICENSE.txt. See the License for the specific
0N/A * language governing permissions and limitations under the License.
0N/A *
0N/A * When distributing the software, include this License Header Notice in each
292N/A * file and include the License file at packager/legal/LICENSE.txt.
292N/A *
292N/A * GPL Classpath Exception:
292N/A * Oracle designates this particular file as subject to the "Classpath"
292N/A * exception as provided by Oracle in the GPL Version 2 section of the License
292N/A * file that accompanied this code.
292N/A *
292N/A * Modifications:
292N/A * If applicable, add the following below the License Header, with the fields
292N/A * enclosed by brackets [] replaced by your own identifying information:
292N/A * "Portions Copyright [year] [name of copyright owner]"
0N/A *
0N/A * Contributor(s):
0N/A * If you wish your version of this file to be governed by only the CDDL or
0N/A * only the GPL Version 2, indicate your decision by adding "[Contributor]
0N/A * elects to include this software in this distribution under the [CDDL or GPL
0N/A * Version 2] license." If you don't indicate a single choice of license, a
0N/A * recipient has the option to distribute your version of this file under
0N/A * either the CDDL, the GPL Version 2 or to extend the choice of license to
0N/A * its licensees as provided above. However, if you add GPL Version 2 code
0N/A * and therefore, elected the GPL Version 2 license, then the option applies
0N/A * only if the new code is made subject to such option by the copyright
0N/A * holder.
0N/A */
0N/A
0N/Apackage javax.mail.event;
0N/A
0N/Aimport java.util.*;
0N/Aimport javax.mail.*;
0N/A
0N/A/**
0N/A * This class models Folder <em>existence</em> events. FolderEvents are
0N/A * delivered to FolderListeners registered on the affected Folder as
0N/A * well as the containing Store. <p>
0N/A *
0N/A * Service providers vary widely in their ability to notify clients of
0N/A * these events. At a minimum, service providers must notify listeners
0N/A * registered on the same Store or Folder object on which the operation
0N/A * occurs. Service providers may also notify listeners when changes
0N/A * are made through operations on other objects in the same virtual
0N/A * machine, or by other clients in the same or other hosts. Such
0N/A * notifications are not required and are typically not supported
0N/A * by mail protocols (including IMAP).
0N/A *
0N/A * @author John Mani
0N/A * @author Bill Shannon
0N/A */
0N/A
0N/Apublic class FolderEvent extends MailEvent {
0N/A
0N/A /** The folder was created. */
0N/A public static final int CREATED = 1;
0N/A /** The folder was deleted. */
0N/A public static final int DELETED = 2;
0N/A /** The folder was renamed. */
0N/A public static final int RENAMED = 3;
0N/A
0N/A /**
0N/A * The event type.
0N/A *
0N/A * @serial
0N/A */
0N/A protected int type;
0N/A
0N/A /**
0N/A * The folder the event occurred on.
0N/A */
0N/A transient protected Folder folder;
0N/A
0N/A /**
0N/A * The folder that represents the new name, in case of a RENAMED event.
0N/A *
0N/A * @since JavaMail 1.1
0N/A */
0N/A transient protected Folder newFolder;
0N/A
0N/A private static final long serialVersionUID = 5278131310563694307L;
0N/A
0N/A /**
0N/A * Constructor. <p>
0N/A *
0N/A * @param source The source of the event
0N/A * @param folder The affected folder
0N/A * @param type The event type
0N/A */
0N/A public FolderEvent(Object source, Folder folder, int type) {
0N/A this(source, folder, folder, type);
0N/A }
0N/A
0N/A /**
0N/A * Constructor. Use for RENAMED events.
0N/A *
0N/A * @param source The source of the event
0N/A * @param oldFolder The folder that is renamed
0N/A * @param newFolder The folder that represents the new name
0N/A * @param type The event type
0N/A * @since JavaMail 1.1
0N/A */
0N/A public FolderEvent(Object source, Folder oldFolder,
0N/A Folder newFolder, int type) {
0N/A super(source);
0N/A this.folder = oldFolder;
0N/A this.newFolder = newFolder;
0N/A this.type = type;
0N/A }
0N/A
0N/A /**
0N/A * Return the type of this event.
0N/A *
0N/A * @return type
0N/A */
0N/A public int getType() {
0N/A return type;
0N/A }
0N/A
0N/A /**
0N/A * Return the affected folder.
0N/A *
0N/A * @return the affected folder
0N/A * @see #getNewFolder
0N/A */
0N/A public Folder getFolder() {
0N/A return folder;
0N/A }
0N/A
0N/A /**
0N/A * If this event indicates that a folder is renamed, (i.e, the event type
0N/A * is RENAMED), then this method returns the Folder object representing the
0N/A * new name. <p>
0N/A *
0N/A * The <code>getFolder()</code> method returns the folder that is renamed.
0N/A *
0N/A * @return Folder representing the new name.
0N/A * @see #getFolder
0N/A * @since JavaMail 1.1
0N/A */
0N/A public Folder getNewFolder() {
0N/A return newFolder;
0N/A }
0N/A
0N/A /**
0N/A * Invokes the appropriate FolderListener method
0N/A */
0N/A public void dispatch(Object listener) {
0N/A if (type == CREATED)
0N/A ((FolderListener)listener).folderCreated(this);
0N/A else if (type == DELETED)
0N/A ((FolderListener)listener).folderDeleted(this);
0N/A else if (type == RENAMED)
0N/A ((FolderListener)listener).folderRenamed(this);
0N/A }
0N/A}