KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > request > DecodedRequest


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 JavaDoc;
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 JavaDoc _scheme = "http";
33
34     private String JavaDoc _serverName;
35
36     private String JavaDoc _requestURI;
37
38     private int _serverPort = 80;
39
40     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     public DecodedRequest(HttpServletRequest JavaDoc request)
51     {
52         _scheme = request.getScheme();
53         _serverName = request.getServerName();
54         _requestURI = request.getRequestURI();
55         _serverPort = request.getServerPort();
56     }
57
58     /**
59      * Default value is 80.
60      */

61
62     public int getServerPort()
63     {
64         return _serverPort;
65     }
66
67     /**
68      * Default value is 'http'.
69      */

70
71     public String JavaDoc getScheme()
72     {
73         return _scheme;
74     }
75
76     /**
77      * No default, a value must be set by the decoder.
78      */

79
80     public String JavaDoc getServerName()
81     {
82         return _serverName;
83     }
84
85     /**
86      * No default, a value must be set by the decoder.
87      */

88
89     public String JavaDoc getRequestURI()
90     {
91         return _requestURI;
92     }
93
94     public void setServerPort(int serverPort)
95     {
96         _serverPort = serverPort;
97     }
98
99     public void setScheme(String JavaDoc scheme)
100     {
101         _scheme = scheme;
102     }
103
104     public void setServerName(String JavaDoc serverName)
105     {
106         _serverName = serverName;
107     }
108
109     public void setRequestURI(String JavaDoc URI)
110     {
111         _requestURI = URI;
112     }
113
114 }
Popular Tags