package org.apache.maven.deploy;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * ====================================================================
 */

/**
 * Holder of the variables which are used by deployers for
 * establishing connection to remote hosts and to 
 * deploy the file to correct location in remote file system
 * 
 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
 * @version $Id: DeployRequest.java,v 1.9 2004/03/02 14:59:31 evenisse Exp $
 */
public class DeployRequest
{
    /** The filename in target file system */
    private String destFile;

    /** The file name in local file system */
    private String srcFile;

    public DeployRequest(String srcFile, String destFile)
    {
        this.srcFile = srcFile;
        this.destFile = destFile;
    }

    /**
     * @return
     */
    public String getDestFile()
    {
        return destFile;
    }

    /**
     * @param destFile
     */
    public void setDestFile(String destFile)
    {
        this.destFile = destFile;
    }

    /**
     * @return
     */
    public String getSrcFile()
    {
        return srcFile;
    }

    /**
     * @param srcFile
     */
    public void setSrcFile(String srcFile)
    {
        this.srcFile = srcFile;
    }

    /**
     * Returns the directory path portion of a file specification string.
     * Matches the equally named unix command.
     * @return The directory portion excluding the ending file separator.
     */
    public String dirname()
    {
        int i = destFile.lastIndexOf("/");
        return (i >= 0 ? destFile.substring(0, i) : "");
    }

    /**
     * Returns the filename portion of a file specification string.
     * @return The filename string with extension.
     */
    public String filename()
    {
        int i = destFile.lastIndexOf("/");
        return (i >= 0 ? destFile.substring(i + 1) : destFile);
    }

}
