    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.fileupload;
    018
    019/**
    020 * <p>High level API for processing file uploads.</p>
    021 *
    022 * <p>This class handles multiple files per single HTML widget, sent using
    023 * <code>multipart/mixed</code> encoding type, as specified by
    024 * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>.  Use {@link
    025 * #parseRequest(RequestContext)} to acquire a list
    026 * of {@link org.apache.commons.fileupload.FileItem FileItems} associated
    027 * with a given HTML widget.</p>
    028 *
    029 * <p>How the data for individual parts is stored is determined by the factory
    030 * used to create them; a given part may be in memory, on disk, or somewhere
    031 * else.</p>
    032 */
    033public class FileUpload
    034    extends FileUploadBase {
    035
    036    // ----------------------------------------------------------- Data members
    037
    038    /**
    039     * The factory to use to create new form items.
    040     */
    041    private FileItemFactory fileItemFactory;
    042
    043    // ----------------------------------------------------------- Constructors
    044
    045    /**
    046     * Constructs an uninitialised instance of this class.
    047     *
    048     * A factory must be
    049     * configured, using <code>setFileItemFactory()</code>, before attempting
    050     * to parse requests.
    051     *
    052     * @see #FileUpload(FileItemFactory)
    053     */
    054    public FileUpload() {
    055        super();
    056    }
    057
    058    /**
    059     * Constructs an instance of this class which uses the supplied factory to
    060     * create <code>FileItem</code> instances.
    061     *
    062     * @see #FileUpload()
    063     * @param fileItemFactory The factory to use for creating file items.
    064     */
    065    public FileUpload(FileItemFactory fileItemFactory) {
    066        super();
    067        this.fileItemFactory = fileItemFactory;
    068    }
    069
    070    // ----------------------------------------------------- Property accessors
    071
    072    /**
    073     * Returns the factory class used when creating file items.
    074     *
    075     * @return The factory class for new file items.
    076     */
    077    @Override
    078    public FileItemFactory getFileItemFactory() {
    079        return fileItemFactory;
    080    }
    081
    082    /**
    083     * Sets the factory class to use when creating file items.
    084     *
    085     * @param factory The factory class for new file items.
    086     */
    087    @Override
    088    public void setFileItemFactory(FileItemFactory factory) {
    089        this.fileItemFactory = factory;
    090    }
    091
    092}