/*
 * @(#)FtpRenameFileEvent.java
 *
 * Copyright (c) 2001-2004 JScape
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JScape. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JScape.
 */
package com.jscape.inet.ftp;

/**
 * Fired when a file is renamed on remote server.
 */
public class FtpRenameFileEvent
        extends FtpEvent {

    private String oldName;
    private String newName;
    private String path;

    /**
     * Creates a new FtpRenameFileEvent instance
     *
     * @param source  the event source
     * @param oldName the old file name
     * @param newName the new file name
     */
    public FtpRenameFileEvent(Object source, String oldName, String newName, String path) {
        super(source);
        this.oldName = oldName;
        this.newName = newName;
        this.path = path;
    }


    /**
     * Method accept
     *
     * @see FtpEvent#accept(FtpListener)
     */
    public void accept(FtpListener listener) {
        if (listener != null) {
            listener.renameFile(this);
        }
    }

    /**
     * Gets remote directory path that this file was renamed from.
     *
     * @return remote directory path
     */
    public String getPath() {
        return path;
    }

    /**
     * Gets old file name
     *
     * @return old file name
     */
    public String getOldName() {
        return oldName;
    }

    /**
     * Gets new file name
     *
     * @return new file name
     */
    public String getNewName() {
        return newName;
    }

    /**
     * Gets String representation of this event
     *
     * @return event message
     */
    public String toString() {
        return "Renamed file " + oldName + " to " + newName + " from remote directory path of " + path;
    }
}
