/*
 * @(#)FileTransferRenameFileEvent.java
 *
 * Copyright (c) 1999-2007 JSCAPE LLC
 *
 * 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.filetransfer;

/**
 * Fired when a file is renamed on server.
 */
public class FileTransferRenameFileEvent
        extends FileTransferEvent {

    private final String oldFile;
    private final String newFile;
    private final String path;

    /**
     * Creates <code>FileTransferRenameFileEvent</code>.
     *
     * @param source  the source of the event
     * @param oldFile the file to be renamed
     * @param newFile the new file name
     * @param path    the remote directory path the file was renamed from
     */
    public FileTransferRenameFileEvent(FileTransfer source,
                                       String oldFile,
                                       String newFile,
                                       String path) {
        super(source);
        this.oldFile = oldFile;
        this.newFile = newFile;
        this.path = path;
    }

    /**
     * Gets the old file name.
     *
     * @return the old file name
     */
    public String getOldFile() {
        return this.oldFile;
    }

    /**
     * Gets the new file name.
     *
     * @return the new file name
     */
    public String getNewFile() {
        return this.newFile;
    }

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

    /**
     * {@inheritDoc}
     */
    public void accept(FileTransferListener listener) {
        listener.renameFile(this);
    }

    @Override
    public String toString() {
        return "FileTransferRenameFileEvent {"
                + "oldFile='" + this.oldFile + '\''
                + ", newFile='" + this.newFile + '\''
                + ", path='" + this.path + '\''
                + '}';
    }
}
