/*
 * @(#)FileTransferUploadEvent.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 file is uploaded to server.
 */
public class FileTransferErrorEvent
        extends FileTransferEvent {

    private final String filename;
    private final String path;
    private final String localPath;
    private final int mode;

    /**
     * Creates a new event instance.
     *
     * @param source    the source of the event
     * @param filename  the file uploaded
     * @param path      the remote path the file was uploaded to
     * @param localPath the local file path
     */
    public FileTransferErrorEvent(FileTransfer source, String filename, String path, String localPath, int mode) {
        super(source);

        this.filename = filename;
        this.path = path;
        this.localPath = localPath;
        this.mode = mode;
    }

    /**
     * Gets name of file uploaded.
     *
     * @return filename
     */
    public String getFilename() {
        return this.filename;
    }

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

    /**
     * Returns uploaded file local path.
     *
     * @return uploaded file local path
     */
    public String getLocalPath() {
        return this.localPath;
    }

    public long getMode() {
        return this.mode;
    }

    /**
     * {@inheritDoc}
     */
    public void accept(FileTransferListener listener) {
        if (listener instanceof FileTransferErrorListener) {
            ((FileTransferErrorListener) listener).error(this);
        }
    }

    @Override
    public String toString() {
        return "FileTransferErrorEvent {"
                + "filename='" + this.filename + '\''
                + ", path='" + this.path + '\''
                + ", localPath='" + this.localPath + '\''
                + ", mode=" + this.mode
                + '}';
    }
}
