1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.util.httpaccess;
35
36 import org.apache.commons.fileupload.FileItem;
37 import org.apache.commons.fileupload.FileItemHeaders;
38
39 import java.io.File;
40 import java.io.IOException;
41 import java.io.InputStream;
42 import java.io.OutputStream;
43 import java.io.UnsupportedEncodingException;
44
45
46
47
48
49
50 public class MemoryFileItem implements FileItem
51 {
52 private static final long serialVersionUID = 922231338093963479L;
53 private byte [ ] _data;
54 private String _strName;
55 private long _lSize;
56 private String _strContentType;
57
58
59
60
61
62
63
64
65
66
67
68
69
70 public MemoryFileItem( byte [ ] data, String strName, long lSize, String strContentType )
71 {
72 _data = data;
73 _strName = strName;
74 _lSize = lSize;
75 _strContentType = strContentType;
76 }
77
78
79
80
81 public void delete( )
82 {
83
84 }
85
86
87
88
89 public byte [ ] get( )
90 {
91 return _data;
92 }
93
94
95
96
97 public String getContentType( )
98 {
99 return _strContentType;
100 }
101
102
103
104
105
106
107 public String getFieldName( )
108 {
109 return null;
110 }
111
112
113
114
115 public InputStream getInputStream( ) throws IOException
116 {
117 throw new UnsupportedOperationException( );
118 }
119
120
121
122
123 public String getName( )
124 {
125 return _strName;
126 }
127
128
129
130
131 public OutputStream getOutputStream( ) throws IOException
132 {
133 throw new UnsupportedOperationException( );
134 }
135
136
137
138
139 public long getSize( )
140 {
141 return _lSize;
142 }
143
144
145
146
147 public String getString( )
148 {
149 return new String( get( ) );
150 }
151
152
153
154
155 public String getString( String strEncoding ) throws UnsupportedEncodingException
156 {
157 return new String( get( ), strEncoding );
158 }
159
160
161
162
163 public boolean isFormField( )
164 {
165 return false;
166 }
167
168
169
170
171 public boolean isInMemory( )
172 {
173 return true;
174 }
175
176
177
178
179 public void setFieldName( String strFieldName )
180 {
181
182 }
183
184
185
186
187 public void setFormField( boolean state )
188 {
189
190 }
191
192
193
194
195 public void write( File file ) throws Exception
196 {
197 throw new UnsupportedOperationException( );
198 }
199
200 public FileItemHeaders getHeaders( )
201 {
202 throw new UnsupportedOperationException( );
203 }
204
205 public void setHeaders( FileItemHeaders headers )
206 {
207 throw new UnsupportedOperationException( );
208 }
209 }