|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DecodedRequest.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 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 | private String _scheme = "http"; | |
| 33 | ||
| 34 | private String _serverName; | |
| 35 | ||
| 36 | private String _requestURI; | |
| 37 | ||
| 38 | private int _serverPort = 80; | |
| 39 | ||
| 40 | 6 | public DecodedRequest() |
| 41 | { | |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * Initializes default values for the properties from the request provided. | |
| 46 | * | |
| 47 | * @since 4.0 | |
| 48 | */ | |
| 49 | ||
| 50 | 3 | public DecodedRequest(HttpServletRequest request) |
| 51 | { | |
| 52 | 3 | _scheme = request.getScheme(); |
| 53 | 3 | _serverName = request.getServerName(); |
| 54 | 3 | _requestURI = request.getRequestURI(); |
| 55 | 3 | _serverPort = request.getServerPort(); |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Default value is 80. | |
| 60 | */ | |
| 61 | ||
| 62 | 6 | public int getServerPort() |
| 63 | { | |
| 64 | 6 | return _serverPort; |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * Default value is 'http'. | |
| 69 | */ | |
| 70 | ||
| 71 | 6 | public String getScheme() |
| 72 | { | |
| 73 | 6 | return _scheme; |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * No default, a value must be set by the decoder. | |
| 78 | */ | |
| 79 | ||
| 80 | 6 | public String getServerName() |
| 81 | { | |
| 82 | 6 | return _serverName; |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * No default, a value must be set by the decoder. | |
| 87 | */ | |
| 88 | ||
| 89 | 9 | public String getRequestURI() |
| 90 | { | |
| 91 | 9 | return _requestURI; |
| 92 | } | |
| 93 | ||
| 94 | 3 | public void setServerPort(int serverPort) |
| 95 | { | |
| 96 | 3 | _serverPort = serverPort; |
| 97 | } | |
| 98 | ||
| 99 | 3 | public void setScheme(String scheme) |
| 100 | { | |
| 101 | 3 | _scheme = scheme; |
| 102 | } | |
| 103 | ||
| 104 | 3 | public void setServerName(String serverName) |
| 105 | { | |
| 106 | 3 | _serverName = serverName; |
| 107 | } | |
| 108 | ||
| 109 | 6 | public void setRequestURI(String URI) |
| 110 | { | |
| 111 | 6 | _requestURI = URI; |
| 112 | } | |
| 113 | ||
| 114 | } |
|
||||||||||