##### Coverage Report - org.melati.util.DelegatedHttpServletRequest

Classes in this File | Line Coverage | Branch Coverage | Complexity
DelegatedHttpServletRequest |
20% | 12/60
N/A | N/A
| 1.0;1

1 |  |
     /*
2 |  |
      * $Source: /usr/cvsroot/melati/melati/src/site/resources/withWebmacro/org.melati.util.DelegatedHttpServletRequest.html,v $
3 |  |
      * $Revision: 1.1 $
4 |  |
      *
5 |  |
      * Copyright (C) 2001 William Chesters
6 |  |
      *
7 |  |
      * Part of Melati (http://melati.org), a framework for the rapid
8 |  |
      * development of clean, maintainable web applications.
9 |  |
      *
10 |  |
      * Melati is free software; Permission is granted to copy, distribute
11 |  |
      * and/or modify this software under the terms either:
12 |  |
      *
13 |  |
      * a) the GNU General Public License as published by the Free Software
14 |  |
      *    Foundation; either version 2 of the License, or (at your option)
15 |  |
      *    any later version,
16 |  |
      *
17 |  |
      *    or
18 |  |
      *
19 |  |
      * b) any version of the Melati Software License, as published
20 |  |
      *    at http://melati.org
21 |  |
      *
22 |  |
      * You should have received a copy of the GNU General Public License and
23 |  |
      * the Melati Software License along with this program;
24 |  |
      * if not, write to the Free Software Foundation, Inc.,
25 |  |
      * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
26 |  |
      * GNU General Public License and visit http://melati.org to obtain the
27 |  |
      * Melati Software License.
28 |  |
      *
29 |  |
      * Feel free to contact the Developers of Melati (http://melati.org),
30 |  |
      * if you would like to work out a different arrangement than the options
31 |  |
      * outlined here.  It is our intention to allow Melati to be used by as
32 |  |
      * wide an audience as possible.
33 |  |
      *
34 |  |
      * This program is distributed in the hope that it will be useful,
35 |  |
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 |  |
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 |  |
      * GNU General Public License for more details.
38 |  |
      *
39 |  |
      * Contact details for copyright holder:
40 |  |
      *
41 |  |
      *     William Chesters <williamc At paneris.org>
42 |  |
      *     http://paneris.org/~williamc
43 |  |
      *     Obrechtstraat 114, 2517VX Den Haag, The Netherlands
44 |  |
      */
45 |  |
46 |  |
     package org.melati.util;
47 |  |
48 |  |
     import java.util.Map;
49 |  |
     import java.util.Enumeration;
50 |  |
     import java.util.Locale;
51 |  |
     import javax.servlet.RequestDispatcher;
52 |  |
     import javax.servlet.http.HttpServletRequest;
53 |  |
54 |  |
      /**
55 |  |
       *
56 |  |
       *
57 |  |
       * Enables Melati to compile, without warnings, with the Servlet API
58 |  |
       * versions 2.0 to 2.5.
59 |  |
       *
60 |  |
       * However the database listener and admin tests rely upon 2.4 features.
61 |  |
       *
62 |  |
       */
63 |  |
64 |  |
     public class DelegatedHttpServletRequest implements HttpServletRequest {
65 |  |
66 |  |
       protected HttpServletRequest peer;
67 |  |
68 |  |
       /**
69 |  |
        * @param peer
70 |  |
        */
71 | 6 |
       public DelegatedHttpServletRequest(HttpServletRequest peer) {
72 | 6 |
         this.peer = peer;
73 | 6 |
       }
74 |  |
75 |  |
      /*
76 |  |
       * Core methods common to all APIs; call these directly.
77 |  |
       */
78 |  |
79 |  |
       /**
80 |  |
        * {@inheritDoc}
81 |  |
        * @see javax.servlet.http.HttpServletRequest#getAuthType()
82 |  |
        */
83 |  |
       public java.lang.String getAuthType() {
84 | 0 |
         return peer.getAuthType();
85 |  |
       }
86 |  |
       /**
87 |  |
        * {@inheritDoc}
88 |  |
        * @see javax.servlet.http.HttpServletRequest#getCookies()
89 |  |
        */
90 |  |
       public javax.servlet.http.Cookie[] getCookies() {
91 | 0 |
         return peer.getCookies();
92 |  |
       }
93 |  |
       /**
94 |  |
        * {@inheritDoc}
95 |  |
        * @see javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
96 |  |
        */
97 |  |
       public long getDateHeader(java.lang.String a) {
98 | 0 |
         return peer.getDateHeader(a);
99 |  |
       }
100 |  |
       /**
101 |  |
        * {@inheritDoc}
102 |  |
        * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
103 |  |
        */
104 |  |
       public java.lang.String getHeader(java.lang.String a) {
105 | 4 |
         return peer.getHeader(a);
106 |  |
       }
107 |  |
       /**
108 |  |
        * {@inheritDoc}
109 |  |
        * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
110 |  |
        */
111 |  |
       @SuppressWarnings("unchecked")
112 |  |
       public java.util.Enumeration<String> getHeaderNames() {
113 | 0 |
         return peer.getHeaderNames();
114 |  |
       }
115 |  |
       /**
116 |  |
        * {@inheritDoc}
117 |  |
        * @see javax.servlet.http.HttpServletRequest#getIntHeader(java.lang.String)
118 |  |
        */
119 |  |
       public int getIntHeader(java.lang.String a) {
120 | 0 |
         return peer.getIntHeader(a);
121 |  |
       }
122 |  |
       /**
123 |  |
        * {@inheritDoc}
124 |  |
        * @see javax.servlet.http.HttpServletRequest#getMethod()
125 |  |
        */
126 |  |
       public java.lang.String getMethod() {
127 | 0 |
         return peer.getMethod();
128 |  |
       }
129 |  |
       /**
130 |  |
        * {@inheritDoc}
131 |  |
        * @see javax.servlet.http.HttpServletRequest#getPathInfo()
132 |  |
        */
133 |  |
       public java.lang.String getPathInfo() {
134 | 0 |
         return peer.getPathInfo();
135 |  |
       }
136 |  |
       /**
137 |  |
        * {@inheritDoc}
138 |  |
        * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
139 |  |
        */
140 |  |
       public java.lang.String getPathTranslated() {
141 | 0 |
         return peer.getPathTranslated();
142 |  |
       }
143 |  |
       /**
144 |  |
        * {@inheritDoc}
145 |  |
        * @see javax.servlet.http.HttpServletRequest#getQueryString()
146 |  |
        */
147 |  |
       public java.lang.String getQueryString() {
148 | 6 |
         return peer.getQueryString();
149 |  |
       }
150 |  |
       /**
151 |  |
        * {@inheritDoc}
152 |  |
        * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
153 |  |
        */
154 |  |
       public java.lang.String getRemoteUser() {
155 | 0 |
         return peer.getRemoteUser();
156 |  |
       }
157 |  |
       /**
158 |  |
        * {@inheritDoc}
159 |  |
        * @see javax.servlet.http.HttpServletRequest#getRequestURI()
160 |  |
        */
161 |  |
       public java.lang.String getRequestURI() {
162 | 6 |
         return peer.getRequestURI();
163 |  |
       }
164 |  |
       /**
165 |  |
        * {@inheritDoc}
166 |  |
        * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
167 |  |
        */
168 |  |
       public java.lang.String getRequestedSessionId() {
169 | 0 |
         return peer.getRequestedSessionId();
170 |  |
       }
171 |  |
       /**
172 |  |
        * {@inheritDoc}
173 |  |
        * @see javax.servlet.http.HttpServletRequest#getServletPath()
174 |  |
        */
175 |  |
       public java.lang.String getServletPath() {
176 | 16 |
         return peer.getServletPath();
177 |  |
       }
178 |  |
       /**
179 |  |
        * {@inheritDoc}
180 |  |
        * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
181 |  |
        */
182 |  |
       public javax.servlet.http.HttpSession getSession(boolean a) {
183 | 6 |
         return peer.getSession(a);
184 |  |
       }
185 |  |
186 |  |
       /**
187 |  |
        * {@inheritDoc}
188 |  |
        * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
189 |  |
        */
190 |  |
       public boolean isRequestedSessionIdValid() {
191 | 0 |
         return peer.isRequestedSessionIdValid();
192 |  |
       }
193 |  |
       /**
194 |  |
        * {@inheritDoc}
195 |  |
        * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
196 |  |
        */
197 |  |
       public java.lang.Object getAttribute(java.lang.String a) {
198 | 0 |
         return peer.getAttribute(a);
199 |  |
       }
200 |  |
       /**
201 |  |
        * {@inheritDoc}
202 |  |
        * @see javax.servlet.ServletRequest#getCharacterEncoding()
203 |  |
        */
204 |  |
       public java.lang.String getCharacterEncoding() {
205 | 0 |
         return peer.getCharacterEncoding();
206 |  |
       }
207 |  |
       /**
208 |  |
        * {@inheritDoc}
209 |  |
        * @see javax.servlet.ServletRequest#getContentLength()
210 |  |
        */
211 |  |
       public int getContentLength() {
212 | 0 |
         return peer.getContentLength();
213 |  |
       }
214 |  |
       /**
215 |  |
        * {@inheritDoc}
216 |  |
        * @see javax.servlet.ServletRequest#getContentType()
217 |  |
        */
218 |  |
       public java.lang.String getContentType() {
219 | 0 |
         return peer.getContentType();
220 |  |
       }
221 |  |
       /**
222 |  |
        * {@inheritDoc}
223 |  |
        * @see javax.servlet.ServletRequest#getInputStream()
224 |  |
        */
225 |  |
       public javax.servlet.ServletInputStream getInputStream()
226 |  |
             throws java.io.IOException {
227 | 0 |
         return peer.getInputStream();
228 |  |
       }
229 |  |
       /**
230 |  |
        * {@inheritDoc}
231 |  |
        * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
232 |  |
        */
233 |  |
       public java.lang.String getParameter(java.lang.String a) {
234 | 0 |
         return peer.getParameter(a);
235 |  |
       }
236 |  |
       /**
237 |  |
        * {@inheritDoc}
238 |  |
        * @see javax.servlet.ServletRequest#getParameterNames()
239 |  |
        */
240 |  |
       @SuppressWarnings("unchecked")
241 |  |
       public java.util.Enumeration<String> getParameterNames() {
242 | 0 |
         return peer.getParameterNames();
243 |  |
       }
244 |  |
       /**
245 |  |
        * {@inheritDoc}
246 |  |
        * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
247 |  |
        */
248 |  |
       public java.lang.String[] getParameterValues(java.lang.String a) {
249 | 0 |
         return peer.getParameterValues(a);
250 |  |
       }
251 |  |
       /**
252 |  |
        * {@inheritDoc}
253 |  |
        * @see javax.servlet.ServletRequest#getProtocol()
254 |  |
        */
255 |  |
       public java.lang.String getProtocol() {
256 | 0 |
         return peer.getProtocol();
257 |  |
       }
258 |  |
       /**
259 |  |
        * {@inheritDoc}
260 |  |
        * @see javax.servlet.ServletRequest#getReader()
261 |  |
        */
262 |  |
       public java.io.BufferedReader getReader() throws java.io.IOException {
263 | 0 |
         return peer.getReader();
264 |  |
       }
265 |  |
266 |  |
       /**
267 |  |
        * {@inheritDoc}
268 |  |
        * @see javax.servlet.ServletRequest#getRemoteAddr()
269 |  |
        */
270 |  |
       public java.lang.String getRemoteAddr() {
271 | 0 |
         return peer.getRemoteAddr();
272 |  |
       }
273 |  |
       /**
274 |  |
        * {@inheritDoc}
275 |  |
        * @see javax.servlet.ServletRequest#getRemoteHost()
276 |  |
        */
277 |  |
       public java.lang.String getRemoteHost() {
278 | 0 |
         return peer.getRemoteHost();
279 |  |
       }
280 |  |
       /**
281 |  |
        * {@inheritDoc}
282 |  |
        * @see javax.servlet.ServletRequest#getScheme()
283 |  |
        */
284 |  |
       public java.lang.String getScheme() {
285 | 14 |
         return peer.getScheme();
286 |  |
       }
287 |  |
       /**
288 |  |
        * {@inheritDoc}
289 |  |
        * @see javax.servlet.ServletRequest#getServerName()
290 |  |
        */
291 |  |
       public java.lang.String getServerName() {
292 | 14 |
         return peer.getServerName();
293 |  |
       }
294 |  |
       /**
295 |  |
        * {@inheritDoc}
296 |  |
        * @see javax.servlet.ServletRequest#getServerPort()
297 |  |
        */
298 |  |
       public int getServerPort() {
299 | 28 |
         return peer.getServerPort();
300 |  |
       }
301 |  |
302 |  |
       /**
303 |  |
        * {@inheritDoc}
304 |  |
        * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
305 |  |
        */
306 |  |
       public boolean isRequestedSessionIdFromCookie() {
307 | 0 |
         return peer.isRequestedSessionIdFromCookie();
308 |  |
       }
309 |  |
310 |  |
       //
311 |  |
       //  Deprecated methods, may disappear.
312 |  |
       //
313 |  |
314 |  |
       /**
315 |  |
        * @deprecated Servlet API 2.1
316 |  |
        *
317 |  |
        * {@inheritDoc}
318 |  |
        * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
319 |  |
        */
320 |  |
       public boolean isRequestedSessionIdFromUrl() {
321 | 0 |
         return peer.isRequestedSessionIdFromUrl();
322 |  |
       }
323 |  |
       /**
324 |  |
        * @deprecated Servlet API 2.1
325 |  |
        *
326 |  |
        * {@inheritDoc}
327 |  |
        * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
328 |  |
        */
329 |  |
       public java.lang.String getRealPath(java.lang.String a) {
330 | 0 |
         return peer.getRealPath(a);
331 |  |
       }
332 |  |
333 |  |
       //
334 |  |
       // Servlet API 2.1 extensions
335 |  |
       //
336 |  |
337 |  |
       /**
338 |  |
        * {@inheritDoc}
339 |  |
        * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
340 |  |
        */
341 |  |
       public java.security.Principal getUserPrincipal() {
342 | 0 |
         return peer.getUserPrincipal();
343 |  |
       }
344 |  |
       /**
345 |  |
        * {@inheritDoc}
346 |  |
        * @see javax.servlet.http.HttpServletRequest#getContextPath()
347 |  |
        */
348 |  |
       public java.lang.String getContextPath() {
349 | 16 |
         return peer.getContextPath();
350 |  |
       }
351 |  |
       /**
352 |  |
        * {@inheritDoc}
353 |  |
        * @see javax.servlet.http.HttpServletRequest#getHeaders(java.lang.String)
354 |  |
        */
355 |  |
       @SuppressWarnings("unchecked")
356 |  |
       public java.util.Enumeration<String> getHeaders(java.lang.String name) {
357 | 0 |
         return peer.getHeaders(name);
358 |  |
       }
359 |  |
       /**
360 |  |
        * {@inheritDoc}
361 |  |
        * @see javax.servlet.http.HttpServletRequest#getSession()
362 |  |
        */
363 |  |
       public javax.servlet.http.HttpSession getSession() {
364 | 0 |
         return peer.getSession();
365 |  |
       }
366 |  |
       /**
367 |  |
        * {@inheritDoc}
368 |  |
        * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
369 |  |
        */
370 |  |
       public boolean isRequestedSessionIdFromURL() {
371 | 0 |
         return peer.isRequestedSessionIdFromURL();
372 |  |
       }
373 |  |
374 |  |
       //
375 |  |
       // Servlet API 2.2 extensions
376 |  |
       //
377 |  |
378 |  |
       /**
379 |  |
        * {@inheritDoc}
380 |  |
        * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
381 |  |
        */
382 |  |
       public boolean isUserInRole(java.lang.String a) {
383 | 0 |
         return peer.isUserInRole(a);
384 |  |
       }
385 |  |
       /**
386 |  |
        * {@inheritDoc}
387 |  |
        * @see javax.servlet.ServletRequest#getAttributeNames()
388 |  |
        */
389 |  |
       @SuppressWarnings("unchecked")
390 |  |
       public Enumeration<String> getAttributeNames() {
391 | 0 |
         return peer.getAttributeNames();
392 |  |
       }
393 |  |
       /**
394 |  |
        * {@inheritDoc}
395 |  |
        * @see javax.servlet.ServletRequest#getLocale()
396 |  |
        */
397 |  |
       public Locale getLocale()  {
398 | 0 |
         return peer.getLocale();
399 |  |
       }
400 |  |
       /**
401 |  |
        * {@inheritDoc}
402 |  |
        * @see javax.servlet.ServletRequest#getLocales()
403 |  |
        */
404 |  |
       @SuppressWarnings("unchecked")
405 |  |
       public Enumeration<Locale> getLocales() {
406 | 0 |
         return peer.getLocales();
407 |  |
       }
408 |  |
409 |  |
       /**
410 |  |
        * {@inheritDoc}
411 |  |
        * @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
412 |  |
        */
413 |  |
       public RequestDispatcher getRequestDispatcher(String arg) {
414 | 0 |
         return peer.getRequestDispatcher(arg);
415 |  |
       }
416 |  |
       /**
417 |  |
        * {@inheritDoc}
418 |  |
        * @see javax.servlet.ServletRequest#isSecure()
419 |  |
        */
420 |  |
       public boolean isSecure() {
421 | 0 |
         return peer.isSecure();
422 |  |
       }
423 |  |
       /**
424 |  |
        * {@inheritDoc}
425 |  |
        * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
426 |  |
        */
427 |  |
       public void removeAttribute(String arg) {
428 | 0 |
         peer.removeAttribute(arg);
429 | 0 |
       }
430 |  |
       /**
431 |  |
        * {@inheritDoc}
432 |  |
        * @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object)
433 |  |
        */
434 |  |
       public void setAttribute(String arg1, Object arg2) {
435 | 0 |
         peer.setAttribute(arg1, arg2);
436 | 0 |
       }
437 |  |
438 |  |
       //
439 |  |
       //  Servlet 2.3 extensions
440 |  |
       //
441 |  |
442 |  |
       /**
443 |  |
        * {@inheritDoc}
444 |  |
        * @see javax.servlet.http.HttpServletRequest#getRequestURL()
445 |  |
        */
446 |  |
       public StringBuffer getRequestURL() {
447 | 0 |
         return peer.getRequestURL();
448 |  |
       }
449 |  |
450 |  |
       /**
451 |  |
        * {@inheritDoc}
452 |  |
        * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
453 |  |
        */
454 |  |
       public void setCharacterEncoding (String s) throws java.io.UnsupportedEncodingException {
455 | 0 |
         peer.setCharacterEncoding(s);
456 | 0 |
       }
457 |  |
458 |  |
       /**
459 |  |
        * {@inheritDoc}
460 |  |
        * @see javax.servlet.ServletRequest#getParameterMap()
461 |  |
        */
462 |  |
       @SuppressWarnings("unchecked")
463 |  |
       public Map<String, String[]> getParameterMap () {
464 | 0 |
         return peer.getParameterMap();
465 |  |
       }
466 |  |
467 |  |
       //
468 |  |
       //  Servlet 2.4 extensions
469 |  |
       //
470 |  |
471 |  |
       /**
472 |  |
        * {@inheritDoc}
473 |  |
        * @see javax.servlet.ServletRequest#getLocalAddr()
474 |  |
        */
475 |  |
       public String getLocalAddr() {
476 | 0 |
         return peer.getLocalAddr();
477 |  |
       }
478 |  |
479 |  |
       /**
480 |  |
        * {@inheritDoc}
481 |  |
        * @see javax.servlet.ServletRequest#getLocalName()
482 |  |
        */
483 |  |
       public String getLocalName() {
484 | 0 |
         return peer.getLocalName();
485 |  |
       }
486 |  |
487 |  |
       /**
488 |  |
        * {@inheritDoc}
489 |  |
        * @see javax.servlet.ServletRequest#getLocalPort()
490 |  |
        */
491 |  |
       public int getLocalPort() {
492 | 0 |
         return peer.getLocalPort();
493 |  |
       }
494 |  |
495 |  |
       /**
496 |  |
        * {@inheritDoc}
497 |  |
        * @see javax.servlet.ServletRequest#getRemotePort()
498 |  |
        */
499 |  |
       public int getRemotePort() {
500 | 0 |
         return peer.getRemotePort();
501 |  |
       }
502 |  |
503 |  |
       //
504 |  |
       //  There are no Servlet 2.5 extensions
505 |  |
       //
506 |  |
     }
507 |  |
508 |  |
509 |  |
510 |  |
511 |  |
512 |  |
513 |  |
514 |  |
515 |  |
516 |  |
517 |  |
518 |  |
519 |  |
520 |  |
521 |  |