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.event;
019    
020    import echopoint.tucana.FileUploadSelector;
021    import org.apache.commons.fileupload.FileItem;
022    
023    /**
024     * An event indicating that a file upload has finished.
025    
026     * <p><b>Note:</b> Development of this component was sponsored by <a
027     * href='http://tcnbroadcasting.com/index.jsp' target='_top'>TCN
028     * Broadcasting</a>.  We are grateful for their support and sponsorship.</p>
029     *
030     * @author Echo File Transfer Library
031     * @version $Id: UploadFinishEvent.java 90 2008-11-11 01:41:05Z sptrakesh $
032     */
033    public class UploadFinishEvent extends UploadEvent
034    {
035      private static final long serialVersionUID = 1l;
036    
037      /** The file item that represents the file that was uploaded. */
038      private final FileItem fileItem;
039    
040      /**
041       * Creates a new {@link UploadEvent}.
042       *
043       * @param source the source of the event
044       * @param index the index of the upload
045       * @param fileName the name of the file, may not contain path information
046       * @param contentType the content type of the uploaded file
047       * @param item The file item that represents the uploaded file.
048       */
049      public UploadFinishEvent( final FileUploadSelector source,
050          final String index, final String fileName, final String contentType,
051          final FileItem item )
052      {
053        super( source, index, fileName, contentType );
054        this.fileItem = item;
055      }
056    
057      /**
058       * Accessor for property 'fileItem'.
059       *
060       * @return Value for property 'fileItem'.
061       */
062      public FileItem getFileItem()
063      {
064        return fileItem;
065      }
066    
067      /**
068       * Return the size (in bytes) of the file that was uploaded.
069       *
070       * @return The file size in bytes.
071       */
072      public long getFileSize()
073      {
074        return fileItem.getSize();
075      }
076    }