001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.util.bridges.wai;
022:
023: import com.liferay.portal.kernel.util.StringMaker;
024: import com.liferay.portal.kernel.util.StringPool;
025:
026: import java.util.Collections;
027: import java.util.Enumeration;
028: import java.util.Map;
029:
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletRequestWrapper;
032:
033: /**
034: * <a href="WAIHttpServletRequest.java.html"><b><i>View Source</i></b></a>
035: *
036: * @author Jorge Ferrer
037: *
038: */
039: public class WAIHttpServletRequest extends HttpServletRequestWrapper {
040:
041: public WAIHttpServletRequest(HttpServletRequest req,
042: String contextPath, String pathInfo, String queryString,
043: Map params) {
044:
045: super (req);
046:
047: _contextPath = contextPath;
048: _pathInfo = pathInfo;
049: _queryString = queryString;
050: _params = params;
051: }
052:
053: public String getContextPath() {
054: return _contextPath;
055: }
056:
057: public String getPathInfo() {
058: return super .getPathInfo();
059: }
060:
061: public String getQueryString() {
062: return _queryString;
063: }
064:
065: public String getRequestURI() {
066: StringMaker sm = new StringMaker();
067:
068: sm.append(getContextPath());
069: sm.append(_pathInfo);
070:
071: if (getQueryString().trim().length() > 0) {
072: sm.append(StringPool.QUESTION);
073: sm.append(getQueryString());
074: }
075:
076: return sm.toString();
077: }
078:
079: public StringBuffer getRequestURL() {
080: return new StringBuffer(getRequestURI());
081: }
082:
083: public Map getParameterMap() {
084: return _params;
085: }
086:
087: public Enumeration getParameterNames() {
088: return Collections.enumeration(_params.keySet());
089: }
090:
091: public String getParameter(String key) {
092: String[] values = (String[]) _params.get(key);
093:
094: if (values == null) {
095: return null;
096: }
097:
098: return values[0];
099: }
100:
101: public String[] getParameterValues(String key) {
102: return (String[]) _params.get(key);
103: }
104:
105: private String _contextPath;
106: private String _pathInfo;
107: private String _queryString;
108: private Map _params;
109:
110: }
|