KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jforum > util > legacy > commons > fileupload > DefaultFileItemFactory


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.jforum.util.legacy.commons.fileupload;
17
18 import java.io.File JavaDoc;
19
20 import net.jforum.util.legacy.commons.fileupload.disk.DiskFileItemFactory;
21
22 /**
23  * <p>The default {@link org.apache.commons.fileupload.FileItemFactory}
24  * implementation. This implementation creates
25  * {@link org.apache.commons.fileupload.FileItem} instances which keep their
26  * content either in memory, for smaller items, or in a temporary file on disk,
27  * for larger items. The size threshold, above which content will be stored on
28  * disk, is configurable, as is the directory in which temporary files will be
29  * created.</p>
30  *
31  * <p>If not otherwise configured, the default configuration values are as
32  * follows:
33  * <ul>
34  * <li>Size threshold is 10KB.</li>
35  * <li>Repository is the system default temp directory, as returned by
36  * <code>System.getProperty("java.io.tmpdir")</code>.</li>
37  * </ul>
38  * </p>
39  *
40  * @author <a HREF="mailto:martinc@apache.org">Martin Cooper</a>
41  *
42  * @version $Id: DefaultFileItemFactory.java,v 1.3 2005/07/26 03:04:59 rafaelsteil Exp $
43  *
44  * @deprecated Use <code>DiskFileItemFactory</code> instead.
45  */

46 public class DefaultFileItemFactory extends DiskFileItemFactory {
47
48     // ----------------------------------------------------------- Constructors
49

50
51     /**
52      * Constructs an unconfigured instance of this class. The resulting factory
53      * may be configured by calling the appropriate setter methods.
54      *
55      * @deprecated Use <code>DiskFileItemFactory</code> instead.
56      */

57     public DefaultFileItemFactory() {
58         super();
59     }
60
61
62     /**
63      * Constructs a preconfigured instance of this class.
64      *
65      * @param sizeThreshold The threshold, in bytes, below which items will be
66      * retained in memory and above which they will be
67      * stored as a file.
68      * @param repository The data repository, which is the directory in
69      * which files will be created, should the item size
70      * exceed the threshold.
71      *
72      * @deprecated Use <code>DiskFileItemFactory</code> instead.
73      */

74     public DefaultFileItemFactory(int sizeThreshold, File JavaDoc repository) {
75         super(sizeThreshold, repository);
76     }
77
78
79     // --------------------------------------------------------- Public Methods
80

81     /**
82      * Create a new {@link org.apache.commons.fileupload.DefaultFileItem}
83      * instance from the supplied parameters and the local factory
84      * configuration.
85      *
86      * @param fieldName The name of the form field.
87      * @param contentType The content type of the form field.
88      * @param isFormField <code>true</code> if this is a plain form field;
89      * <code>false</code> otherwise.
90      * @param fileName The name of the uploaded file, if any, as supplied
91      * by the browser or other client.
92      *
93      * @return The newly created file item.
94      *
95      * @deprecated Use <code>DiskFileItemFactory</code> instead.
96      */

97     public FileItem createItem(
98             String JavaDoc fieldName,
99             String JavaDoc contentType,
100             boolean isFormField,
101             String JavaDoc fileName
102             ) {
103         return new DefaultFileItem(fieldName, contentType,
104                 isFormField, fileName, getSizeThreshold(), getRepository());
105     }
106
107 }
108
Popular Tags