Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
DecodedRequest |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.request; |
|
16 | ||
17 | import javax.servlet.http.HttpServletRequest; |
|
18 | ||
19 | /** |
|
20 | * Contains properties of an {@link javax.servlet.http.HttpServletRequest}that have been extracted |
|
21 | * from the request (or otherwise determined). An instance of this is created by an |
|
22 | * {@link org.apache.tapestry.request.IRequestDecoder}. The decoder must set the serverName and |
|
23 | * requestURI properties, and should set the scheme and server port properties. |
|
24 | * |
|
25 | * @see IRequestDecoder |
|
26 | * @author Howard Lewis Ship |
|
27 | * @since 2.2 |
|
28 | */ |
|
29 | ||
30 | public class DecodedRequest |
|
31 | { |
|
32 | 3 | private String _scheme = "http"; |
33 | ||
34 | private String _serverName; |
|
35 | ||
36 | private String _requestURI; |
|
37 | ||
38 | 3 | private int _serverPort = 80; |
39 | ||
40 | public DecodedRequest() |
|
41 | 2 | { |
42 | 2 | } |
43 | ||
44 | /** |
|
45 | * Initializes default values for the properties from the request provided. |
|
46 | * |
|
47 | * @since 4.0 |
|
48 | */ |
|
49 | ||
50 | public DecodedRequest(HttpServletRequest request) |
|
51 | 1 | { |
52 | 1 | _scheme = request.getScheme(); |
53 | 1 | _serverName = request.getServerName(); |
54 | 1 | _requestURI = request.getRequestURI(); |
55 | 1 | _serverPort = request.getServerPort(); |
56 | 1 | } |
57 | ||
58 | /** |
|
59 | * Default value is 80. |
|
60 | */ |
|
61 | ||
62 | public int getServerPort() |
|
63 | { |
|
64 | 2 | return _serverPort; |
65 | } |
|
66 | ||
67 | /** |
|
68 | * Default value is 'http'. |
|
69 | */ |
|
70 | ||
71 | public String getScheme() |
|
72 | { |
|
73 | 2 | return _scheme; |
74 | } |
|
75 | ||
76 | /** |
|
77 | * No default, a value must be set by the decoder. |
|
78 | */ |
|
79 | ||
80 | public String getServerName() |
|
81 | { |
|
82 | 2 | return _serverName; |
83 | } |
|
84 | ||
85 | /** |
|
86 | * No default, a value must be set by the decoder. |
|
87 | */ |
|
88 | ||
89 | public String getRequestURI() |
|
90 | { |
|
91 | 3 | return _requestURI; |
92 | } |
|
93 | ||
94 | public void setServerPort(int serverPort) |
|
95 | { |
|
96 | 1 | _serverPort = serverPort; |
97 | 1 | } |
98 | ||
99 | public void setScheme(String scheme) |
|
100 | { |
|
101 | 1 | _scheme = scheme; |
102 | 1 | } |
103 | ||
104 | public void setServerName(String serverName) |
|
105 | { |
|
106 | 1 | _serverName = serverName; |
107 | 1 | } |
108 | ||
109 | public void setRequestURI(String URI) |
|
110 | { |
|
111 | 2 | _requestURI = URI; |
112 | 2 | } |
113 | ||
114 | } |