/*
 * @(#)FileTransferConnectedEvent.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 connection to server is established.
 */
public class FileTransferConnectedEvent
        extends FileTransferEvent {

    private final String hostname;

    /**
     * Creates <code>FileTransferConnectedEvent</code>.
     *
     * @param source   the source of the event
     * @param hostname the server hostname or ip address
     */
    public FileTransferConnectedEvent(FileTransfer source, String hostname) {
        super(source);

        this.hostname = hostname;
    }

    /**
     * Gets server hostname.
     *
     * @return hostname
     */
    public String getHostname() {
        return this.hostname;
    }

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

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