View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.custom.requestParameterProvider;
21  
22  
23  import javax.servlet.ServletOutputStream;
24  import javax.servlet.http.Cookie;
25  import javax.servlet.http.HttpServletResponse;
26  import java.io.IOException;
27  import java.io.PrintWriter;
28  import java.util.Locale;
29  
30  /**
31   * @author Thomas Obereder
32   * @version 30.04.2006 14:40:05
33   */
34  public class RequestParameterResponseWrapper implements HttpServletResponse
35  {
36      protected HttpServletResponse original;
37      private String contentType;
38  
39      public RequestParameterResponseWrapper(HttpServletResponse httpServletResponse)
40      {
41          //super();
42          this.original = httpServletResponse;
43      }
44  
45      /**
46       * @param url the url to encode
47       * @return wrappedResponse.encodeUrl(url);
48       */
49      public String encodeURL(String url)
50      {
51          if(url == null)
52              return null;
53  
54          url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
55  
56          return this.original.encodeURL(url);
57      }
58  
59  
60      /**
61       * @param url the url to encode
62       * @return wrappedResponse.encodeUrl(url);
63       */
64  
65      public String encodeRedirectURL(String url)
66      {
67          return this.original.encodeRedirectURL(url);
68      }
69  
70  
71      /**
72       * @deprecated uses deprecated Method.
73       * @param url the url to encode
74       * @return wrappedResponse.encodeUrl(url);
75       */
76      public String encodeUrl(String url)
77      {
78          return this.original.encodeUrl(url);
79      }
80  
81  
82      /**
83       * @deprecated uses deprecated Method.
84       * @param url the url to encode
85       * @return wrappedResponse.encodeUrl(url);
86       */
87      public String encodeRedirectUrl(String url)
88      {
89          return this.original.encodeRedirectUrl(url);
90      }
91  
92  
93      //simple delegation
94  
95      public void addCookie(Cookie cookie)
96      {
97          this.original.addCookie(cookie);
98      }
99  
100 
101     public boolean containsHeader(String header)
102     {
103         return this.original.containsHeader(header);
104     }
105 
106     public void sendError(int i, String string) throws IOException
107     {
108         this.original.sendError(i, string);
109     }
110 
111     public void sendError(int i) throws IOException
112     {
113         this.original.sendError(i);
114     }
115 
116     public void sendRedirect(String string) throws IOException
117     {
118         this.original.sendRedirect(string);
119     }
120 
121     public void setDateHeader(String string, long l)
122     {
123         this.original.setDateHeader(string, l);
124     }
125 
126     public void addDateHeader(String string, long l)
127     {
128         this.original.addDateHeader(string, l);
129     }
130 
131     public void setHeader(String string, String string1)
132     {
133         this.original.setHeader(string, string1);
134     }
135 
136     public void addHeader(String string, String string1)
137     {
138         this.original.addHeader(string, string1);
139     }
140 
141     public void setIntHeader(String string, int i)
142     {
143         this.original.setIntHeader(string, i);
144     }
145 
146     public void addIntHeader(String string, int i)
147     {
148         this.original.addIntHeader(string, i);
149     }
150 
151     public void setStatus(int i)
152     {
153         this.original.setStatus(i);
154     }
155 
156 
157     /**
158      * @deprecated uses deprecated Method
159      */
160 
161     public void setStatus(int i, String string)
162     {
163         this.original.setStatus(i, string);
164     }
165 
166     public String getCharacterEncoding()
167     {
168         return this.original.getCharacterEncoding();
169     }
170 
171     public ServletOutputStream getOutputStream() throws IOException
172     {
173         return this.original.getOutputStream();
174     }
175 
176     public PrintWriter getWriter() throws IOException
177     {
178         return this.original.getWriter();
179     }
180 
181     public void setContentLength(int i)
182     {
183         this.original.setContentLength(i);
184     }
185 
186     public void setContentType(String string)
187     {
188         this.contentType = string;
189         this.original.setContentType(string);
190     }
191 
192     public void setBufferSize(int i)
193     {
194         this.original.setBufferSize(i);
195     }
196 
197     public int getBufferSize()
198     {
199         return this.original.getBufferSize();
200     }
201 
202     public void flushBuffer() throws IOException
203     {
204         this.original.flushBuffer();
205     }
206 
207     public void resetBuffer()
208     {
209         this.original.resetBuffer();
210     }
211 
212     public boolean isCommitted()
213     {
214         return this.original.isCommitted();
215     }
216 
217     public void reset()
218     {
219         this.original.reset();
220     }
221 
222     public void setLocale(Locale locale)
223     {
224         this.original.setLocale(locale);
225     }
226 
227     public Locale getLocale()
228     {
229         return this.original.getLocale();
230     }
231 
232     public String getContentType()
233     {
234         return contentType;
235     }
236 }