00001 /* 00002 * Copyright 2004 The Apache Software Foundation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef _SERVLET_REQUEST_WRAPPER_H_ 00018 #define _SERVLET_REQUEST_WRAPPER_H_ 00019 00020 #include <servlet/ServletRequest.h> 00021 #include <servlet/IllegalArgumentException.h> 00022 00023 namespace servlet 00024 { 00039 class ServletRequestWrapper: virtual public ServletRequest { 00040 private: 00041 ServletRequest* request; 00042 public: 00047 ServletRequestWrapper(ServletRequest* request) 00048 : request(request) 00049 {} 00053 ServletRequest* getRequest() { 00054 return request; 00055 } 00056 const ServletRequest* getRequest() const { 00057 return request; 00058 } 00059 00065 void setRequest(ServletRequest* request) { 00066 if (request == 0) { 00067 throw IllegalArgumentException("Request cannot be null"); 00068 } 00069 this->request = request; 00070 } 00071 00078 virtual boost::shared_ptr<void> getAttribute(const std::string& name) { 00079 return request->getAttribute(name); 00080 } 00081 00088 virtual bool hasAttribute(const std::string& name) const { 00089 return request->hasAttribute(name); 00090 } 00091 00097 virtual std::auto_ptr< std::vector<std::string> > getAttributeNames() const { 00098 return request->getAttributeNames(); 00099 } 00100 00101 00102 00108 virtual std::string getCharacterEncoding() const { 00109 return request->getCharacterEncoding(); 00110 } 00111 00117 virtual void setCharacterEncoding(const std::string& enc) { 00118 request->setCharacterEncoding(enc); 00119 } 00120 00126 virtual int getContentLength() const { 00127 return request->getContentLength(); 00128 } 00129 00134 virtual std::string getContentType() const { 00135 return request->getContentType(); 00136 } 00137 00143 virtual std::istream& getInputStream() { 00144 return request->getInputStream(); 00145 } 00146 00152 virtual std::string getParameter(const std::string& name) const { 00153 return request->getParameter(name); 00154 } 00155 00160 virtual std::auto_ptr< std::multimap<std::string,std::string> > getParameterMap() const { 00161 return request->getParameterMap(); 00162 } 00163 00168 virtual std::auto_ptr< std::vector<std::string> > getParameterNames() const { 00169 return request->getParameterNames(); 00170 } 00171 00176 virtual std::auto_ptr< std::vector<std::string> > getParameterValues(const std::string& name) const { 00177 return request->getParameterValues(name); 00178 } 00179 00185 virtual std::string getProtocol() const { 00186 return request->getProtocol(); 00187 } 00188 00193 virtual std::string getScheme() const { 00194 return request->getScheme(); 00195 } 00196 00201 virtual std::string getServerName() const { 00202 return request->getServerName(); 00203 } 00204 00210 virtual int getServerPort() const { 00211 return request->getServerPort(); 00212 } 00213 00219 virtual std::string getRemoteAddr() const { 00220 return request->getRemoteAddr(); 00221 } 00222 00228 virtual std::string getRemoteHost() const { 00229 return request->getRemoteHost(); 00230 } 00231 00237 virtual void setAttribute(const std::string& name, boost::shared_ptr<void> t) { 00238 request->setAttribute(name, t); 00239 } 00240 00245 virtual void removeAttribute(const std::string& name) { 00246 request->removeAttribute(name); 00247 } 00248 00254 virtual bool isSecure() const { 00255 return request->isSecure(); 00256 } 00257 00263 virtual RequestDispatcher* getRequestDispatcher(const std::string& path) { 00264 return request->getRequestDispatcher(path); 00265 } 00266 00267 00274 virtual int getRemotePort() const { 00275 return request->getRemotePort(); 00276 } 00277 00278 00285 virtual std::string getLocalName() const { 00286 return request->getLocalName(); 00287 } 00288 00296 virtual std::string getLocalAddr() const { 00297 return request->getLocalAddr(); 00298 } 00299 00306 virtual int getLocalPort() const { 00307 return request->getLocalPort(); 00308 } 00309 }; 00310 00311 } 00312 00313 #endif