001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    package echopoint.tucana;
019    
020    import java.io.IOException;
021    import java.io.OutputStream;
022    import java.io.Serializable;
023    
024    /**
025     * An interface to be implemented by the class providing the data to be
026     * downloaded.
027     *
028     * @author Echo File Transfer Library
029     * @version $Id: DownloadProvider.java 185 2009-05-06 19:13:15Z sptrakesh $
030     */
031    public interface DownloadProvider extends Serializable
032    {
033      /**
034       * Returns the content type, for example "text/plain".
035       *
036       * @return the content type.
037       */
038      String getContentType();
039    
040      /**
041       * Returns the value of the disposition-type in the Content-Disposition
042       * parameter of the response header.  {@code null} indicates that a
043       * Content-Disposition parameter should not be included in the reponse
044       * header.  See RFC 2183 for more info.  The following values are most
045       * commonly used:
046       *
047       * <ul>
048       *   <li>{@code inline} - Indicates that the browser should attempt to
049       *     display the content.</li>
050       *   <li>{@code attachment} - Usually the default action.  The browser
051       *     will display a save content dialogue.</li>
052       * </ul>
053       *
054       * @return The file's Content-Disposition
055       */
056      String getContentDisposition();
057    
058      /**
059       * Returns the file name, for example "my-file.txt".
060       *
061       * @return the file name.
062       */
063      String getFileName();
064    
065      /**
066       * Returns the size of the data to be downloaded.
067       *
068       * @return the size of the data to be downloaded.
069       */
070      long getSize();
071    
072      /**
073       * Writes the file data to the output stream.
074       *
075       * @param out the output stream to which the file data must be written.
076       * @throws IOException If errors are encountered while writing to the
077       *   output stream.
078       */
079      void writeFile( final OutputStream out ) throws IOException;
080    
081      /**
082       * Return the status of the download action.
083       *
084       * @return A status indicator regarding progress of the download.
085       */
086      Status getStatus();
087    }