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

/**
 * Fired when the remote directory path is changed.
 */
public class FtpChangeDirEvent
        extends FtpEvent {

    private String dir;

    /**
     * Creates a new FtpChangeDirEvent instance.
     *
     * @param source the source of the event
     * @param dir    the new remote directory path
     */
    public FtpChangeDirEvent(Object source, String dir) {
        super(source);
        this.dir = dir;

    }

    /**
     * Method accept
     *
     * @see FtpEvent#accept(FtpListener)
     */
    public void accept(FtpListener listener) {
        if (listener != null) {
            listener.changeDir(this);
        }
    }

    /**
     * Gets new remote directory path
     *
     * @return remote directory path
     */
    public String getDirectory() {
        return dir;
    }

    /**
     * Gets String representation of this event.
     *
     * @return event message
     */
    public String toString() {
        return "Changed directory path to " + dir;
    }
}
