001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.request;
016
017 import javax.servlet.http.HttpServletRequest;
018
019 /**
020 * Contains properties of an {@link javax.servlet.http.HttpServletRequest}that have been extracted
021 * from the request (or otherwise determined). An instance of this is created by an
022 * {@link org.apache.tapestry.request.IRequestDecoder}. The decoder must set the serverName and
023 * requestURI properties, and should set the scheme and server port properties.
024 *
025 * @see IRequestDecoder
026 * @author Howard Lewis Ship
027 * @since 2.2
028 */
029
030 public class DecodedRequest
031 {
032 private String _scheme = "http";
033
034 private String _serverName;
035
036 private String _requestURI;
037
038 private int _serverPort = 80;
039
040 public DecodedRequest()
041 {
042 }
043
044 /**
045 * Initializes default values for the properties from the request provided.
046 *
047 * @since 4.0
048 */
049
050 public DecodedRequest(HttpServletRequest request)
051 {
052 _scheme = request.getScheme();
053 _serverName = request.getServerName();
054 _requestURI = request.getRequestURI();
055 _serverPort = request.getServerPort();
056 }
057
058 /**
059 * Default value is 80.
060 */
061
062 public int getServerPort()
063 {
064 return _serverPort;
065 }
066
067 /**
068 * Default value is 'http'.
069 */
070
071 public String getScheme()
072 {
073 return _scheme;
074 }
075
076 /**
077 * No default, a value must be set by the decoder.
078 */
079
080 public String getServerName()
081 {
082 return _serverName;
083 }
084
085 /**
086 * No default, a value must be set by the decoder.
087 */
088
089 public String getRequestURI()
090 {
091 return _requestURI;
092 }
093
094 public void setServerPort(int serverPort)
095 {
096 _serverPort = serverPort;
097 }
098
099 public void setScheme(String scheme)
100 {
101 _scheme = scheme;
102 }
103
104 public void setServerName(String serverName)
105 {
106 _serverName = serverName;
107 }
108
109 public void setRequestURI(String URI)
110 {
111 _requestURI = URI;
112 }
113
114 }