001: /*
002: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: */
007: package javax.servlet;
008:
009: import java.util.Enumeration;
010: import java.util.Locale;
011: import java.util.Map;
012: import java.io.BufferedReader;
013: import java.io.IOException;
014: import java.io.UnsupportedEncodingException;
015:
016: /**
017: * Wraps a servlet request object using the decorator pattern.
018: *
019: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
020: */
021: public class ServletRequestWrapper implements ServletRequest {
022: private ServletRequest request;
023:
024: public ServletRequestWrapper(ServletRequest request) {
025: setRequest(request);
026: }
027:
028: public ServletRequest getRequest() {
029: return this .request;
030: }
031:
032: public void setRequest(ServletRequest request) {
033: if (request == null) {
034: throw new IllegalArgumentException("Request was null");
035: } else {
036: this .request = request;
037: }
038: }
039:
040: public Object getAttribute(String name) {
041: return this .request.getAttribute(name);
042: }
043:
044: public Enumeration getAttributeNames() {
045: return this .request.getAttributeNames();
046: }
047:
048: public void removeAttribute(String name) {
049: this .request.removeAttribute(name);
050: }
051:
052: public void setAttribute(String name, Object o) {
053: this .request.setAttribute(name, o);
054: }
055:
056: public String getCharacterEncoding() {
057: return this .request.getCharacterEncoding();
058: }
059:
060: public void setCharacterEncoding(String enc)
061: throws UnsupportedEncodingException {
062: this .request.setCharacterEncoding(enc);
063: }
064:
065: public int getContentLength() {
066: return this .request.getContentLength();
067: }
068:
069: public String getContentType() {
070: return this .request.getContentType();
071: }
072:
073: public Locale getLocale() {
074: return this .request.getLocale();
075: }
076:
077: public Enumeration getLocales() {
078: return this .request.getLocales();
079: }
080:
081: public ServletInputStream getInputStream() throws IOException {
082: return this .request.getInputStream();
083: }
084:
085: public BufferedReader getReader() throws IOException {
086: return this .request.getReader();
087: }
088:
089: public String getParameter(String name) {
090: return this .request.getParameter(name);
091: }
092:
093: public Map getParameterMap() {
094: return this .request.getParameterMap();
095: }
096:
097: public Enumeration getParameterNames() {
098: return this .request.getParameterNames();
099: }
100:
101: public String[] getParameterValues(String name) {
102: return this .request.getParameterValues(name);
103: }
104:
105: public RequestDispatcher getRequestDispatcher(String path) {
106: return this .request.getRequestDispatcher(path);
107: }
108:
109: public String getProtocol() {
110: return this .request.getProtocol();
111: }
112:
113: public String getRemoteAddr() {
114: return this .request.getRemoteAddr();
115: }
116:
117: public String getRemoteHost() {
118: return this .request.getRemoteHost();
119: }
120:
121: public String getScheme() {
122: return this .request.getScheme();
123: }
124:
125: public String getServerName() {
126: return this .request.getServerName();
127: }
128:
129: public int getServerPort() {
130: return this .request.getServerPort();
131: }
132:
133: public String getLocalAddr() {
134: return this .request.getLocalAddr();
135: }
136:
137: public String getLocalName() {
138: return this .request.getLocalName();
139: }
140:
141: public int getLocalPort() {
142: return this .request.getLocalPort();
143: }
144:
145: public int getRemotePort() {
146: return this .request.getRemotePort();
147: }
148:
149: public boolean isSecure() {
150: return this .request.isSecure();
151: }
152:
153: /**
154: * @deprecated
155: */
156: public String getRealPath(String path) {
157: return this.request.getRealPath(path);
158: }
159: }
|