KickJava   Java API By Example, From Geeks To Geeks.

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

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

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

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

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

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

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