KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > fileupload > MyHttpServletRequest


1 package org.apache.commons.fileupload;
2
3 import java.io.BufferedReader JavaDoc;
4 import java.io.ByteArrayInputStream JavaDoc;
5 import java.io.IOException JavaDoc;
6 import java.io.UnsupportedEncodingException JavaDoc;
7 import java.security.Principal JavaDoc;
8 import java.util.Enumeration JavaDoc;
9 import java.util.Locale JavaDoc;
10 import java.util.Map JavaDoc;
11
12 import javax.servlet.RequestDispatcher JavaDoc;
13 import javax.servlet.ServletInputStream JavaDoc;
14 import javax.servlet.http.Cookie JavaDoc;
15 import javax.servlet.http.HttpServletRequest JavaDoc;
16 import javax.servlet.http.HttpSession JavaDoc;
17
18 /**
19  *
20  *
21  *
22  *
23  *
24  *
25  */

26 class MyHttpServletRequest implements HttpServletRequest JavaDoc
27 {
28
29     private byte[] m_requestData;
30     private String JavaDoc m_strContentType;
31     private Map JavaDoc m_headers = new java.util.HashMap JavaDoc();
32
33     public MyHttpServletRequest(
34             final byte[] requestData,
35             final String JavaDoc strContentType)
36     {
37         m_requestData = requestData;
38         m_strContentType = strContentType;
39         m_headers.put(FileUploadBase.CONTENT_TYPE, strContentType);
40     }
41
42     /**
43      * @see javax.servlet.http.HttpServletRequest#getAuthType()
44      */

45     public String JavaDoc getAuthType()
46     {
47         return null;
48     }
49
50     /**
51      * @see javax.servlet.http.HttpServletRequest#getCookies()
52      */

53     public Cookie JavaDoc[] getCookies()
54     {
55         return null;
56     }
57
58     /**
59      * @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
60      */

61     public long getDateHeader(String JavaDoc arg0)
62     {
63         return 0;
64     }
65
66     /**
67      * @see javax.servlet.http.HttpServletRequest#getHeader(String)
68      */

69     public String JavaDoc getHeader(String JavaDoc headerName)
70     {
71         return (String JavaDoc) m_headers.get(headerName);
72     }
73
74     /**
75      * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
76      */

77     public Enumeration JavaDoc getHeaders(String JavaDoc arg0)
78     {
79         // todo - implement
80
return null;
81     }
82
83     /**
84      * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
85      */

86     public Enumeration JavaDoc getHeaderNames()
87     {
88         // todo - implement
89
return null;
90     }
91
92     /**
93      * @see javax.servlet.http.HttpServletRequest#getIntHeader(String)
94      */

95     public int getIntHeader(String JavaDoc arg0)
96     {
97         return 0;
98     }
99
100     /**
101      * @see javax.servlet.http.HttpServletRequest#getMethod()
102      */

103     public String JavaDoc getMethod()
104     {
105         return null;
106     }
107
108     /**
109      * @see javax.servlet.http.HttpServletRequest#getPathInfo()
110      */

111     public String JavaDoc getPathInfo()
112     {
113         return null;
114     }
115
116     /**
117      * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
118      */

119     public String JavaDoc getPathTranslated()
120     {
121         return null;
122     }
123
124     /**
125      * @see javax.servlet.http.HttpServletRequest#getContextPath()
126      */

127     public String JavaDoc getContextPath()
128     {
129         return null;
130     }
131
132     /**
133      * @see javax.servlet.http.HttpServletRequest#getQueryString()
134      */

135     public String JavaDoc getQueryString()
136     {
137         return null;
138     }
139
140     /**
141      * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
142      */

143     public String JavaDoc getRemoteUser()
144     {
145         return null;
146     }
147
148     /**
149      * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
150      */

151     public boolean isUserInRole(String JavaDoc arg0)
152     {
153         return false;
154     }
155
156     /**
157      * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
158      */

159     public Principal JavaDoc getUserPrincipal()
160     {
161         return null;
162     }
163
164     /**
165      * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
166      */

167     public String JavaDoc getRequestedSessionId()
168     {
169         return null;
170     }
171
172     /**
173      * @see javax.servlet.http.HttpServletRequest#getRequestURI()
174      */

175     public String JavaDoc getRequestURI()
176     {
177         return null;
178     }
179
180     /**
181      * @see javax.servlet.http.HttpServletRequest#getRequestURL()
182      */

183     public StringBuffer JavaDoc getRequestURL()
184     {
185         return null;
186     }
187
188     /**
189      * @see javax.servlet.http.HttpServletRequest#getServletPath()
190      */

191     public String JavaDoc getServletPath()
192     {
193         return null;
194     }
195
196     /**
197      * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
198      */

199     public HttpSession JavaDoc getSession(boolean arg0)
200     {
201         return null;
202     }
203
204     /**
205      * @see javax.servlet.http.HttpServletRequest#getSession()
206      */

207     public HttpSession JavaDoc getSession()
208     {
209         return null;
210     }
211
212     /**
213      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
214      */

215     public boolean isRequestedSessionIdValid()
216     {
217         return false;
218     }
219
220     /**
221      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
222      */

223     public boolean isRequestedSessionIdFromCookie()
224     {
225         return false;
226     }
227
228     /**
229      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
230      */

231     public boolean isRequestedSessionIdFromURL()
232     {
233         return false;
234     }
235
236     /**
237      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
238      * @deprecated
239      */

240     public boolean isRequestedSessionIdFromUrl()
241     {
242         return false;
243     }
244
245     /**
246      * @see javax.servlet.ServletRequest#getAttribute(String)
247      */

248     public Object JavaDoc getAttribute(String JavaDoc arg0)
249     {
250         return null;
251     }
252
253     /**
254      * @see javax.servlet.ServletRequest#getAttributeNames()
255      */

256     public Enumeration JavaDoc getAttributeNames()
257     {
258         return null;
259     }
260
261     /**
262      * @see javax.servlet.ServletRequest#getCharacterEncoding()
263      */

264     public String JavaDoc getCharacterEncoding()
265     {
266         return null;
267     }
268
269     /**
270      * @see javax.servlet.ServletRequest#setCharacterEncoding(String)
271      */

272     public void setCharacterEncoding(String JavaDoc arg0)
273         throws UnsupportedEncodingException JavaDoc
274     {
275     }
276
277     /**
278      * @see javax.servlet.ServletRequest#getContentLength()
279      */

280     public int getContentLength()
281     {
282         int iLength = 0;
283
284         if (null == m_requestData)
285         {
286             iLength = -1;
287         }
288         else
289         {
290             iLength = m_requestData.length;
291         }
292         return iLength;
293     }
294
295     /**
296      * @see javax.servlet.ServletRequest#getContentType()
297      */

298     public String JavaDoc getContentType()
299     {
300         return m_strContentType;
301     }
302
303     /**
304      * @see javax.servlet.ServletRequest#getInputStream()
305      */

306     public ServletInputStream JavaDoc getInputStream() throws IOException JavaDoc
307     {
308         ServletInputStream JavaDoc sis = new MyServletInputStream(m_requestData);
309         return sis;
310     }
311
312     /**
313      * @see javax.servlet.ServletRequest#getParameter(String)
314      */

315     public String JavaDoc getParameter(String JavaDoc arg0)
316     {
317         return null;
318     }
319
320     /**
321      * @see javax.servlet.ServletRequest#getParameterNames()
322      */

323     public Enumeration JavaDoc getParameterNames()
324     {
325         return null;
326     }
327
328     /**
329      * @see javax.servlet.ServletRequest#getParameterValues(String)
330      */

331     public String JavaDoc[] getParameterValues(String JavaDoc arg0)
332     {
333         return null;
334     }
335
336     /**
337      * @see javax.servlet.ServletRequest#getParameterMap()
338      */

339     public Map JavaDoc getParameterMap()
340     {
341         return null;
342     }
343
344     /**
345      * @see javax.servlet.ServletRequest#getProtocol()
346      */

347     public String JavaDoc getProtocol()
348     {
349         return null;
350     }
351
352     /**
353      * @see javax.servlet.ServletRequest#getScheme()
354      */

355     public String JavaDoc getScheme()
356     {
357         return null;
358     }
359
360     /**
361      * @see javax.servlet.ServletRequest#getServerName()
362      */

363     public String JavaDoc getServerName()
364     {
365         return null;
366     }
367
368     /**
369      * @see javax.servlet.ServletRequest#getServerPort()
370      */

371     public int getServerPort()
372     {
373         return 0;
374     }
375
376     /**
377      * @see javax.servlet.ServletRequest#getReader()
378      */

379     public BufferedReader JavaDoc getReader() throws IOException JavaDoc
380     {
381         return null;
382     }
383
384     /**
385      * @see javax.servlet.ServletRequest#getRemoteAddr()
386      */

387     public String JavaDoc getRemoteAddr()
388     {
389         return null;
390     }
391
392     /**
393      * @see javax.servlet.ServletRequest#getRemoteHost()
394      */

395     public String JavaDoc getRemoteHost()
396     {
397         return null;
398     }
399
400     /**
401      * @see javax.servlet.ServletRequest#setAttribute(String, Object)
402      */

403     public void setAttribute(String JavaDoc arg0, Object JavaDoc arg1)
404     {
405     }
406
407     /**
408      * @see javax.servlet.ServletRequest#removeAttribute(String)
409      */

410     public void removeAttribute(String JavaDoc arg0)
411     {
412     }
413
414     /**
415      * @see javax.servlet.ServletRequest#getLocale()
416      */

417     public Locale JavaDoc getLocale()
418     {
419         return null;
420     }
421
422     /**
423      * @see javax.servlet.ServletRequest#getLocales()
424      */

425     public Enumeration JavaDoc getLocales()
426     {
427         return null;
428     }
429
430     /**
431      * @see javax.servlet.ServletRequest#isSecure()
432      */

433     public boolean isSecure()
434     {
435         return false;
436     }
437
438     /**
439      * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
440      */

441     public RequestDispatcher JavaDoc getRequestDispatcher(String JavaDoc arg0)
442     {
443         return null;
444     }
445
446     /**
447      * @see javax.servlet.ServletRequest#getRealPath(String)
448      * @deprecated
449      */

450     public String JavaDoc getRealPath(String JavaDoc arg0)
451     {
452         return null;
453     }
454
455     /**
456      *
457      *
458      *
459      *
460      */

461     private static class MyServletInputStream
462         extends javax.servlet.ServletInputStream JavaDoc
463     {
464         private ByteArrayInputStream JavaDoc m_bais;
465
466         public MyServletInputStream(byte[] data)
467         {
468             m_bais = new ByteArrayInputStream JavaDoc(data);
469         }
470
471         public int read()
472         {
473             return m_bais.read();
474         }
475     }
476 }
477
Popular Tags