Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FormList |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright (C) 1998-2000 Semiotek Inc. All Rights Reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted under the terms of either of the following | |
6 | * Open Source licenses: | |
7 | * | |
8 | * The GNU General Public License, version 2, or any later version, as | |
9 | * published by the Free Software Foundation | |
10 | * (http://www.fsf.org/copyleft/gpl.html); | |
11 | * | |
12 | * or | |
13 | * | |
14 | * The Semiotek Public License (http://webmacro.org/LICENSE.) | |
15 | * | |
16 | * This software is provided "as is", with NO WARRANTY, not even the | |
17 | * implied warranties of fitness to purpose, or merchantability. You | |
18 | * assume all risks and liabilities associated with its use. | |
19 | * | |
20 | * See www.webmacro.org for more information on the WebMacro project. | |
21 | */ | |
22 | ||
23 | ||
24 | package org.webmacro.servlet; | |
25 | ||
26 | import org.webmacro.UnsettableException; | |
27 | import org.webmacro.util.Bag; | |
28 | ||
29 | import javax.servlet.http.HttpServletRequest; | |
30 | ||
31 | ||
32 | /** | |
33 | * Provide access to form variables | |
34 | */ | |
35 | final public class FormList implements Bag | |
36 | { | |
37 | ||
38 | /** | |
39 | * This is the request object from the WebContext | |
40 | */ | |
41 | final HttpServletRequest _request; | |
42 | ||
43 | /** | |
44 | * Read the form data from the supplied Request object | |
45 | */ | |
46 | FormList (final HttpServletRequest r) | |
47 | 14 | { |
48 | 14 | _request = r; |
49 | 14 | } |
50 | ||
51 | /** | |
52 | * Get a form value | |
53 | */ | |
54 | final public Object get (String field) | |
55 | { | |
56 | try | |
57 | { | |
58 | 30 | return _request.getParameterValues(field); |
59 | } | |
60 | 0 | catch (NullPointerException ne) |
61 | { | |
62 | 0 | return null; |
63 | } | |
64 | } | |
65 | ||
66 | /** | |
67 | * Unsupported | |
68 | */ | |
69 | final public void remove (String key) | |
70 | throws UnsettableException | |
71 | { | |
72 | 0 | throw new UnsettableException("Cannot unset a form property"); |
73 | } | |
74 | ||
75 | /** | |
76 | * Unsupported | |
77 | */ | |
78 | final public void put (String key, Object value) | |
79 | throws UnsettableException | |
80 | { | |
81 | 0 | throw new UnsettableException("Cannot set a form property"); |
82 | } | |
83 | } | |
84 |