/*
 * @(#)SftpListingEvent.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.sftp.events;

import com.jscape.inet.sftp.Sftp;

import java.util.Enumeration;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * This event is fired when directory listing is retrieved from SSH server.
 */
public class SftpListingEvent
        extends SftpEvent {

    private final Enumeration files;

    /**
     * Creates a new event instance.
     *
     * @param source the source of the event
     * @param files  an enumeration of <code>SftpFile</code> objects
     */
    public SftpListingEvent(Sftp source, Enumeration files) {
        super(source);

        assertNotNull(files);
        this.files = files;
    }

    /**
     * Obtains the file listing.
     *
     * @return a java.util.Enumeration of SftpFile
     */
    public Enumeration getFiles() {
        return this.files;
    }

    /**
     * The "backwards dispatching" support.
     *
     * @param listener the event listener
     */
    public void accept(SftpListener listener) {
        listener.dirListing(this);
    }

}
