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

/**
 * This event is fired when the remote directory path is changed on the server.
 */
public class SftpChangeDirEvent
        extends SftpEvent {

    private final String directory;

    /**
     * Creates a new SftpChangeDirEvent instance
     *
     * @param source    the source of this event
     * @param directory the new remote directory name
     */
    public SftpChangeDirEvent(Sftp source, String directory) {
        super(source);
        this.directory = directory;
    }

    /**
     * Gets the new remote directory name
     *
     * @return remote directory name
     */
    public String getDirectory() {
        return this.directory;
    }

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