Source Code Cross Referenced for FileItem.java in  » Forum » JForum-2.1.8 » net » jforum » util » legacy » commons » fileupload » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Forum » JForum 2.1.8 » net.jforum.util.legacy.commons.fileupload 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        import java.io.IOException;
020:        import java.io.InputStream;
021:        import java.io.OutputStream;
022:        import java.io.Serializable;
023:        import java.io.UnsupportedEncodingException;
024:
025:        /**
026:         * <p> This class represents a file or form item that was received within a
027:         * <code>multipart/form-data</code> POST request.
028:         *
029:         * <p> After retrieving an instance of this class from a {@link
030:         * org.apache.commons.fileupload.FileUpload FileUpload} instance (see
031:         * {@link org.apache.commons.fileupload.FileUpload
032:         * #parseRequest(javax.servlet.http.HttpServletRequest)}), you may
033:         * either request all contents of the file at once using {@link #get()} or
034:         * request an {@link java.io.InputStream InputStream} with
035:         * {@link #getInputStream()} and process the file without attempting to load
036:         * it into memory, which may come handy with large files.
037:         *
038:         * <p> While this interface does not extend
039:         * <code>javax.activation.DataSource</code> per se (to avoid a seldom used
040:         * dependency), several of the defined methods are specifically defined with
041:         * the same signatures as methods in that interface. This allows an
042:         * implementation of this interface to also implement
043:         * <code>javax.activation.DataSource</code> with minimal additional work.
044:         *
045:         * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
046:         * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
047:         * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
048:         * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
049:         *
050:         * @version $Id: FileItem.java,v 1.3 2005/07/26 03:05:01 rafaelsteil Exp $
051:         */
052:        public interface FileItem extends Serializable {
053:
054:            // ------------------------------- Methods from javax.activation.DataSource
055:
056:            /**
057:             * Returns an {@link java.io.InputStream InputStream} that can be
058:             * used to retrieve the contents of the file.
059:             *
060:             * @return An {@link java.io.InputStream InputStream} that can be
061:             *         used to retrieve the contents of the file.
062:             *
063:             * @exception IOException if an error occurs.
064:             */
065:            InputStream getInputStream() throws IOException;
066:
067:            /**
068:             * Returns the content type passed by the browser or <code>null</code> if
069:             * not defined.
070:             *
071:             * @return The content type passed by the browser or <code>null</code> if
072:             *         not defined.
073:             */
074:            String getContentType();
075:
076:            /**
077:             * Returns the original filename in the client's filesystem, as provided by
078:             * the browser (or other client software). In most cases, this will be the
079:             * base file name, without path information. However, some clients, such as
080:             * the Opera browser, do include path information.
081:             *
082:             * @return The original filename in the client's filesystem.
083:             */
084:            String getName();
085:
086:            // ------------------------------------------------------- FileItem methods
087:
088:            /**
089:             * Provides a hint as to whether or not the file contents will be read
090:             * from memory.
091:             *
092:             * @return <code>true</code> if the file contents will be read from memory;
093:             *         <code>false</code> otherwise.
094:             */
095:            boolean isInMemory();
096:
097:            /**
098:             * Returns the size of the file item.
099:             *
100:             * @return The size of the file item, in bytes.
101:             */
102:            long getSize();
103:
104:            /**
105:             * Returns the contents of the file item as an array of bytes.
106:             *
107:             * @return The contents of the file item as an array of bytes.
108:             */
109:            byte[] get();
110:
111:            /**
112:             * Returns the contents of the file item as a String, using the specified
113:             * encoding.  This method uses {@link #get()} to retrieve the
114:             * contents of the item.
115:             *
116:             * @param encoding The character encoding to use.
117:             *
118:             * @return The contents of the item, as a string.
119:             *
120:             * @exception UnsupportedEncodingException if the requested character
121:             *                                         encoding is not available.
122:             */
123:            String getString(String encoding)
124:                    throws UnsupportedEncodingException;
125:
126:            /**
127:             * Returns the contents of the file item as a String, using the default
128:             * character encoding.  This method uses {@link #get()} to retrieve the
129:             * contents of the item.
130:             *
131:             * @return The contents of the item, as a string.
132:             */
133:            String getString();
134:
135:            /**
136:             * A convenience method to write an uploaded item to disk. The client code
137:             * is not concerned with whether or not the item is stored in memory, or on
138:             * disk in a temporary location. They just want to write the uploaded item
139:             * to a file.
140:             * <p>
141:             * This method is not guaranteed to succeed if called more than once for
142:             * the same item. This allows a particular implementation to use, for
143:             * example, file renaming, where possible, rather than copying all of the
144:             * underlying data, thus gaining a significant performance benefit.
145:             *
146:             * @param file The <code>File</code> into which the uploaded item should
147:             *             be stored.
148:             *
149:             * @exception Exception if an error occurs.
150:             */
151:            void write(File file) throws Exception;
152:
153:            /**
154:             * Deletes the underlying storage for a file item, including deleting any
155:             * associated temporary disk file. Although this storage will be deleted
156:             * automatically when the <code>FileItem</code> instance is garbage
157:             * collected, this method can be used to ensure that this is done at an
158:             * earlier time, thus preserving system resources.
159:             */
160:            void delete();
161:
162:            /**
163:             * Returns the name of the field in the multipart form corresponding to
164:             * this file item.
165:             *
166:             * @return The name of the form field.
167:             */
168:            String getFieldName();
169:
170:            /**
171:             * Sets the field name used to reference this file item.
172:             *
173:             * @param name The name of the form field.
174:             */
175:            void setFieldName(String name);
176:
177:            /**
178:             * Determines whether or not a <code>FileItem</code> instance represents
179:             * a simple form field.
180:             *
181:             * @return <code>true</code> if the instance represents a simple form
182:             *         field; <code>false</code> if it represents an uploaded file.
183:             */
184:            boolean isFormField();
185:
186:            /**
187:             * Specifies whether or not a <code>FileItem</code> instance represents
188:             * a simple form field.
189:             *
190:             * @param state <code>true</code> if the instance represents a simple form
191:             *              field; <code>false</code> if it represents an uploaded file.
192:             */
193:            void setFormField(boolean state);
194:
195:            /**
196:             * Returns an {@link java.io.OutputStream OutputStream} that can
197:             * be used for storing the contents of the file.
198:             *
199:             * @return An {@link java.io.OutputStream OutputStream} that can be used
200:             *         for storing the contensts of the file.
201:             *
202:             * @exception IOException if an error occurs.
203:             */
204:            OutputStream getOutputStream() throws IOException;
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.