/*
 * @(#)FileTransferResponseEvent.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 response is received from FTP server.  This event is only fired when communicating
 * with an FTP/FTPS server.  This event is not fired when using SFTP (FTP over SSH) protocol.
 */
public class FileTransferResponseEvent
        extends FileTransferEvent {

    private final String response;

    /**
     * Creates FileTransferResponseEvent.
     *
     * @param source   the source of the event
     * @param response the response received from FTP server
     */
    public FileTransferResponseEvent(FileTransfer source, String response) {
        super(source);
        this.response = response;
    }

    /**
     * Gets response received from FTP server.
     *
     * @return the response received from FTP server
     */
    public String getResponse() {
        return this.response;
    }

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

    @Override
    public String toString() {
        return "FileTransferResponseEvent {"
                + "response='" + this.response + '\''
                + '}';
    }
}
