DiskFileUpload.java

00001 /*
00002  * $Header: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DiskFileUpload.java,v 1.3 2003/06/01 00:18:13 martinc Exp $
00003  * $Revision: 1.3 $
00004  * $Date: 2003/06/01 00:18:13 $
00005  *
00006  * ====================================================================
00007  *
00008  * The Apache Software License, Version 1.1
00009  *
00010  * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
00011  * reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions
00015  * are met:
00016  *
00017  * 1. Redistributions of source code must retain the above copyright
00018  *    notice, this list of conditions and the following disclaimer.
00019  *
00020  * 2. Redistributions in binary form must reproduce the above copyright
00021  *    notice, this list of conditions and the following disclaimer in
00022  *    the documentation and/or other materials provided with the
00023  *    distribution.
00024  *
00025  * 3. The end-user documentation included with the redistribution, if
00026  *    any, must include the following acknowlegement:
00027  *       "This product includes software developed by the
00028  *        Apache Software Foundation (http://www.apache.org/)."
00029  *    Alternately, this acknowlegement may appear in the software itself,
00030  *    if and wherever such third-party acknowlegements normally appear.
00031  *
00032  * 4. The names "The Jakarta Project", "Commons", and "Apache Software
00033  *    Foundation" must not be used to endorse or promote products derived
00034  *    from this software without prior written permission. For written
00035  *    permission, please contact apache@apache.org.
00036  *
00037  * 5. Products derived from this software may not be called "Apache"
00038  *    nor may "Apache" appear in their names without prior written
00039  *    permission of the Apache Group.
00040  *
00041  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00042  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00043  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00044  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00045  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00046  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00047  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00048  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00049  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00050  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00051  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00052  * SUCH DAMAGE.
00053  * ====================================================================
00054  *
00055  * This software consists of voluntary contributions made by many
00056  * individuals on behalf of the Apache Software Foundation.  For more
00057  * information on the Apache Software Foundation, please see
00058  * <http://www.apache.org/>.
00059  *
00060  */
00061 
00062 
00063 package org.apache.commons.fileupload;
00064 
00065 
00066 import java.io.File;
00067 import java.util.List;
00068 import javax.servlet.http.HttpServletRequest;
00069 
00070 
00094 public class DiskFileUpload
00095     extends FileUploadBase
00096  {
00097 
00098     // ----------------------------------------------------------- Data members
00099 
00100 
00104     private DefaultFileItemFactory fileItemFactory;
00105 
00106 
00107     // ----------------------------------------------------------- Constructors
00108 
00109 
00116     public DiskFileUpload()
00117     {
00118         super();
00119         this.fileItemFactory = new DefaultFileItemFactory();
00120     }
00121 
00122 
00129     public DiskFileUpload(DefaultFileItemFactory fileItemFactory)
00130     {
00131         super();
00132         this.fileItemFactory = fileItemFactory;
00133     }
00134 
00135 
00136     // ----------------------------------------------------- Property accessors
00137 
00138 
00144     public FileItemFactory getFileItemFactory()
00145     {
00146         return fileItemFactory;
00147     }
00148 
00149 
00157     public void setFileItemFactory(FileItemFactory factory)
00158     {
00159         this.fileItemFactory = (DefaultFileItemFactory) factory;
00160     }
00161 
00162 
00171     public int getSizeThreshold()
00172     {
00173         return fileItemFactory.getSizeThreshold();
00174     }
00175 
00176 
00184     public void setSizeThreshold(int sizeThreshold)
00185     {
00186         fileItemFactory.setSizeThreshold(sizeThreshold);
00187     }
00188 
00189 
00198     public String getRepositoryPath()
00199     {
00200         return fileItemFactory.getRepository().getPath();
00201     }
00202 
00203 
00212     public void setRepositoryPath(String repositoryPath)
00213     {
00214         fileItemFactory.setRepository(new File(repositoryPath));
00215     }
00216 
00217 
00218     // --------------------------------------------------------- Public methods
00219 
00220 
00237     public List /* FileItem */ parseRequest(HttpServletRequest req,
00238                                             int sizeThreshold,
00239                                             long sizeMax, String path)
00240         throws FileUploadException
00241     {
00242         setSizeThreshold(sizeThreshold);
00243         setSizeMax(sizeMax);
00244         setRepositoryPath(path);
00245         return parseRequest(req);
00246     }
00247 
00248 }

Generated on Mon Jan 11 21:19:14 2010 for OpenMobileIS by  doxygen 1.5.4