001: /*
002: * Copyright 2001-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package net.jforum.util.legacy.commons.fileupload;
017:
018: import java.io.File;
019:
020: import net.jforum.util.legacy.commons.fileupload.disk.DiskFileItemFactory;
021:
022: /**
023: * <p>The default {@link org.apache.commons.fileupload.FileItemFactory}
024: * implementation. This implementation creates
025: * {@link org.apache.commons.fileupload.FileItem} instances which keep their
026: * content either in memory, for smaller items, or in a temporary file on disk,
027: * for larger items. The size threshold, above which content will be stored on
028: * disk, is configurable, as is the directory in which temporary files will be
029: * created.</p>
030: *
031: * <p>If not otherwise configured, the default configuration values are as
032: * follows:
033: * <ul>
034: * <li>Size threshold is 10KB.</li>
035: * <li>Repository is the system default temp directory, as returned by
036: * <code>System.getProperty("java.io.tmpdir")</code>.</li>
037: * </ul>
038: * </p>
039: *
040: * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
041: *
042: * @version $Id: DefaultFileItemFactory.java,v 1.3 2005/07/26 03:04:59 rafaelsteil Exp $
043: *
044: * @deprecated Use <code>DiskFileItemFactory</code> instead.
045: */
046: public class DefaultFileItemFactory extends DiskFileItemFactory {
047:
048: // ----------------------------------------------------------- Constructors
049:
050: /**
051: * Constructs an unconfigured instance of this class. The resulting factory
052: * may be configured by calling the appropriate setter methods.
053: *
054: * @deprecated Use <code>DiskFileItemFactory</code> instead.
055: */
056: public DefaultFileItemFactory() {
057: super ();
058: }
059:
060: /**
061: * Constructs a preconfigured instance of this class.
062: *
063: * @param sizeThreshold The threshold, in bytes, below which items will be
064: * retained in memory and above which they will be
065: * stored as a file.
066: * @param repository The data repository, which is the directory in
067: * which files will be created, should the item size
068: * exceed the threshold.
069: *
070: * @deprecated Use <code>DiskFileItemFactory</code> instead.
071: */
072: public DefaultFileItemFactory(int sizeThreshold, File repository) {
073: super (sizeThreshold, repository);
074: }
075:
076: // --------------------------------------------------------- Public Methods
077:
078: /**
079: * Create a new {@link org.apache.commons.fileupload.DefaultFileItem}
080: * instance from the supplied parameters and the local factory
081: * configuration.
082: *
083: * @param fieldName The name of the form field.
084: * @param contentType The content type of the form field.
085: * @param isFormField <code>true</code> if this is a plain form field;
086: * <code>false</code> otherwise.
087: * @param fileName The name of the uploaded file, if any, as supplied
088: * by the browser or other client.
089: *
090: * @return The newly created file item.
091: *
092: * @deprecated Use <code>DiskFileItemFactory</code> instead.
093: */
094: public FileItem createItem(String fieldName, String contentType,
095: boolean isFormField, String fileName) {
096: return new DefaultFileItem(fieldName, contentType, isFormField,
097: fileName, getSizeThreshold(), getRepository());
098: }
099:
100: }
|