Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/struts/upload/FormFile.java


1   /*
2    * $Id: FormFile.java 54929 2004-10-16 16:38:42Z germuska $ 
3    *
4    * Copyright 1999-2004 The Apache Software Foundation.
5    * 
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * 
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  
20  package org.apache.struts.upload;
21  
22  
23  import java.io.InputStream;
24  import java.io.IOException;
25  import java.io.FileNotFoundException;
26  
27  
28  /**
29   * This interface represents a file that has been uploaded by a client. It is
30   * the only interface or class in upload package which is typically referenced
31   * directly by a Struts application.
32   */
33  public interface FormFile
34  {
35      /**
36       * Returns the content type for this file.
37       *
38       * @return A String representing content type.
39       */
40      public String getContentType();
41      
42      /**
43       * Sets the content type for this file.
44       *
45       * @param contentType The content type for the file.
46       */
47      public void setContentType(String contentType);
48      
49      /**
50       * Returns the size of this file.
51       *
52       * @return The size of the file, in bytes.
53       */
54      public int getFileSize();
55      
56      /**
57       * Sets the file size.
58       *
59       * @param fileSize The size of the file, in bytes,
60       */
61      public void setFileSize(int fileSize);    
62      
63      /**
64       * Returns the file name of this file. This is the base name of the file,
65       * as supplied by the user when the file was uploaded.
66       *
67       * @return The base file name.
68       */
69      public String getFileName();
70      
71      /**
72       * Sets the file name of this file.
73       *
74       * @param fileName The base file name.
75       */
76      public void setFileName(String fileName);
77      
78      /**
79       * Returns the data for the entire file as byte array. Care is needed when
80       * using this method, since a large upload could easily exhaust available
81       * memory. The preferred method for accessing the file data is
82       * {@link #getInputStream() getInputStream}.
83       *
84       * @return The file data as a byte array.
85       *
86       * @exception FileNotFoundException if the uploaded file is not found.
87       * @exception IOException           if an error occurred while reading the
88       *                                  file.
89       */
90      public byte[] getFileData()
91              throws FileNotFoundException, IOException;
92      
93      /**
94       * Returns an input stream for this file. The caller must close the
95       * stream when it is no longer needed.
96       *
97       * @exception FileNotFoundException if the uploaded file is not found.
98       * @exception IOException           if an error occurred while reading the
99       *                                  file.
100      */
101     public InputStream getInputStream()
102             throws FileNotFoundException, IOException;
103     
104     /**
105      * Destroys all content for the uploaded file, including any underlying
106      * data files.
107      */
108     public void destroy();    
109 }