Suppress deprecation message when compiling. Can't avoid implementing the deprecated method, but we don't need to see the warning.

This commit is contained in:
jeb228 2010-03-21 18:27:36 +00:00
parent c1b15742de
commit d7e274f11b

View file

@ -1,343 +1,343 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package stubs.javax.servlet.http; package stubs.javax.servlet.http;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.Principal; import java.security.Principal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
/** /**
* *
* @author jeb228 * @author jeb228
*/ */
public class HttpServletRequestStub implements HttpServletRequest { @SuppressWarnings("deprecation")
public class HttpServletRequestStub implements HttpServletRequest {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Stub infrastructure // Stub infrastructure
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private final Map<String, List<String>> parameters; private final Map<String, List<String>> parameters;
private final Map<String, Object> attributes; private final Map<String, Object> attributes;
public HttpServletRequestStub(Map<String, List<String>> parameters, public HttpServletRequestStub(Map<String, List<String>> parameters,
Map<String, Object> attributes) { Map<String, Object> attributes) {
this(); this();
this.parameters.putAll(parameters); this.parameters.putAll(parameters);
this.attributes.putAll(attributes); this.attributes.putAll(attributes);
} }
public HttpServletRequestStub() { public HttpServletRequestStub() {
parameters = new HashMap<String, List<String>>(); parameters = new HashMap<String, List<String>>();
attributes = new HashMap<String, Object>(); attributes = new HashMap<String, Object>();
} }
public void addParameter(String name, String value) { public void addParameter(String name, String value) {
if (!parameters.containsKey(name)) { if (!parameters.containsKey(name)) {
parameters.put(name, new ArrayList<String>()); parameters.put(name, new ArrayList<String>());
} }
parameters.get(name).add(value); parameters.get(name).add(value);
} }
/** Clear all values for a given parameter name. */ /** Clear all values for a given parameter name. */
public void removeParameter(String name) { public void removeParameter(String name) {
parameters.remove(name); parameters.remove(name);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Stub methods // Stub methods
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public String getParameter(String name) { public String getParameter(String name) {
if (!parameters.containsKey(name)) { if (!parameters.containsKey(name)) {
return null; return null;
} }
return parameters.get(name).get(0); return parameters.get(name).get(0);
} }
public Map getParameterMap() { public Map getParameterMap() {
Map<String,String[]> map = new HashMap<String,String[]>(); Map<String, String[]> map = new HashMap<String, String[]>();
for( String key : parameters.keySet() ){ for (String key : parameters.keySet()) {
map.put(key, parameters.get(key).toArray(new String[0])); map.put(key, parameters.get(key).toArray(new String[0]));
} }
return map; return map;
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Un-implemented methods // Un-implemented methods
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public String getAuthType() { public String getAuthType() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getAuthType() not implemented."); "HttpServletRequestStub.getAuthType() not implemented.");
} }
public String getContextPath() { public String getContextPath() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getContextPath() not implemented."); "HttpServletRequestStub.getContextPath() not implemented.");
} }
public Cookie[] getCookies() { public Cookie[] getCookies() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getCookies() not implemented."); "HttpServletRequestStub.getCookies() not implemented.");
} }
public long getDateHeader(String arg0) { public long getDateHeader(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getDateHeader() not implemented."); "HttpServletRequestStub.getDateHeader() not implemented.");
} }
public String getHeader(String arg0) { public String getHeader(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getHeader() not implemented."); "HttpServletRequestStub.getHeader() not implemented.");
} }
public Enumeration getHeaderNames() { public Enumeration getHeaderNames() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getHeaderNames() not implemented."); "HttpServletRequestStub.getHeaderNames() not implemented.");
} }
public Enumeration getHeaders(String arg0) { public Enumeration getHeaders(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getHeaders() not implemented."); "HttpServletRequestStub.getHeaders() not implemented.");
} }
public int getIntHeader(String arg0) { public int getIntHeader(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getIntHeader() not implemented."); "HttpServletRequestStub.getIntHeader() not implemented.");
} }
public String getMethod() { public String getMethod() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getMethod() not implemented."); "HttpServletRequestStub.getMethod() not implemented.");
} }
public String getPathInfo() { public String getPathInfo() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getPathInfo() not implemented."); "HttpServletRequestStub.getPathInfo() not implemented.");
} }
public String getPathTranslated() { public String getPathTranslated() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getPathTranslated() not implemented."); "HttpServletRequestStub.getPathTranslated() not implemented.");
} }
public String getQueryString() { public String getQueryString() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getQueryString() not implemented."); "HttpServletRequestStub.getQueryString() not implemented.");
} }
public String getRemoteUser() { public String getRemoteUser() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRemoteUser() not implemented."); "HttpServletRequestStub.getRemoteUser() not implemented.");
} }
public String getRequestURI() { public String getRequestURI() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRequestURI() not implemented."); "HttpServletRequestStub.getRequestURI() not implemented.");
} }
public StringBuffer getRequestURL() { public StringBuffer getRequestURL() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRequestURL() not implemented."); "HttpServletRequestStub.getRequestURL() not implemented.");
} }
public String getRequestedSessionId() { public String getRequestedSessionId() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRequestedSessionId() not implemented."); "HttpServletRequestStub.getRequestedSessionId() not implemented.");
} }
public String getServletPath() { public String getServletPath() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getServletPath() not implemented."); "HttpServletRequestStub.getServletPath() not implemented.");
} }
public HttpSession getSession() { public HttpSession getSession() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getSession() not implemented."); "HttpServletRequestStub.getSession() not implemented.");
} }
public HttpSession getSession(boolean arg0) { public HttpSession getSession(boolean arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getSession() not implemented."); "HttpServletRequestStub.getSession() not implemented.");
} }
public Principal getUserPrincipal() { public Principal getUserPrincipal() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getUserPrincipal() not implemented."); "HttpServletRequestStub.getUserPrincipal() not implemented.");
} }
public boolean isRequestedSessionIdFromCookie() { public boolean isRequestedSessionIdFromCookie() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isRequestedSessionIdFromCookie() not implemented."); "HttpServletRequestStub.isRequestedSessionIdFromCookie() not implemented.");
} }
public boolean isRequestedSessionIdFromURL() { public boolean isRequestedSessionIdFromURL() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isRequestedSessionIdFromURL() not implemented."); "HttpServletRequestStub.isRequestedSessionIdFromURL() not implemented.");
} }
public boolean isRequestedSessionIdFromUrl() { public boolean isRequestedSessionIdFromUrl() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isRequestedSessionIdFromUrl() not implemented."); "HttpServletRequestStub.isRequestedSessionIdFromUrl() not implemented.");
} }
public boolean isRequestedSessionIdValid() { public boolean isRequestedSessionIdValid() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isRequestedSessionIdValid() not implemented."); "HttpServletRequestStub.isRequestedSessionIdValid() not implemented.");
} }
public boolean isUserInRole(String arg0) { public boolean isUserInRole(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isUserInRole() not implemented."); "HttpServletRequestStub.isUserInRole() not implemented.");
} }
public Object getAttribute(String arg0) { public Object getAttribute(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getAttribute() not implemented."); "HttpServletRequestStub.getAttribute() not implemented.");
} }
public Enumeration getAttributeNames() { public Enumeration getAttributeNames() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getAttributeNames() not implemented."); "HttpServletRequestStub.getAttributeNames() not implemented.");
} }
public String getCharacterEncoding() { public String getCharacterEncoding() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getCharacterEncoding() not implemented."); "HttpServletRequestStub.getCharacterEncoding() not implemented.");
} }
public int getContentLength() { public int getContentLength() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getContentLength() not implemented."); "HttpServletRequestStub.getContentLength() not implemented.");
} }
public String getContentType() { public String getContentType() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getContentType() not implemented."); "HttpServletRequestStub.getContentType() not implemented.");
} }
public ServletInputStream getInputStream() throws IOException { public ServletInputStream getInputStream() throws IOException {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getInputStream() not implemented."); "HttpServletRequestStub.getInputStream() not implemented.");
} }
public String getLocalAddr() { public String getLocalAddr() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getLocalAddr() not implemented."); "HttpServletRequestStub.getLocalAddr() not implemented.");
} }
public String getLocalName() { public String getLocalName() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getLocalName() not implemented."); "HttpServletRequestStub.getLocalName() not implemented.");
} }
public int getLocalPort() { public int getLocalPort() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getLocalPort() not implemented."); "HttpServletRequestStub.getLocalPort() not implemented.");
} }
public Locale getLocale() { public Locale getLocale() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getLocale() not implemented."); "HttpServletRequestStub.getLocale() not implemented.");
} }
public Enumeration getLocales() { public Enumeration getLocales() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getLocales() not implemented."); "HttpServletRequestStub.getLocales() not implemented.");
} }
public Enumeration getParameterNames() { public Enumeration getParameterNames() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getParameterNames() not implemented."); "HttpServletRequestStub.getParameterNames() not implemented.");
} }
public String[] getParameterValues(String arg0) { public String[] getParameterValues(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getParameterValues() not implemented."); "HttpServletRequestStub.getParameterValues() not implemented.");
} }
public String getProtocol() { public String getProtocol() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getProtocol() not implemented."); "HttpServletRequestStub.getProtocol() not implemented.");
} }
public BufferedReader getReader() throws IOException { public BufferedReader getReader() throws IOException {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getReader() not implemented."); "HttpServletRequestStub.getReader() not implemented.");
} }
public String getRealPath(String arg0) { public String getRealPath(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRealPath() not implemented."); "HttpServletRequestStub.getRealPath() not implemented.");
} }
public String getRemoteAddr() { public String getRemoteAddr() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRemoteAddr() not implemented."); "HttpServletRequestStub.getRemoteAddr() not implemented.");
} }
public String getRemoteHost() { public String getRemoteHost() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRemoteHost() not implemented."); "HttpServletRequestStub.getRemoteHost() not implemented.");
} }
public int getRemotePort() { public int getRemotePort() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRemotePort() not implemented."); "HttpServletRequestStub.getRemotePort() not implemented.");
} }
public RequestDispatcher getRequestDispatcher(String arg0) { public RequestDispatcher getRequestDispatcher(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getRequestDispatcher() not implemented."); "HttpServletRequestStub.getRequestDispatcher() not implemented.");
} }
public String getScheme() { public String getScheme() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getScheme() not implemented."); "HttpServletRequestStub.getScheme() not implemented.");
} }
public String getServerName() { public String getServerName() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getServerName() not implemented."); "HttpServletRequestStub.getServerName() not implemented.");
} }
public int getServerPort() { public int getServerPort() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.getServerPort() not implemented."); "HttpServletRequestStub.getServerPort() not implemented.");
} }
public boolean isSecure() { public boolean isSecure() {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.isSecure() not implemented."); "HttpServletRequestStub.isSecure() not implemented.");
} }
public void removeAttribute(String arg0) { public void removeAttribute(String arg0) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.removeAttribute() not implemented."); "HttpServletRequestStub.removeAttribute() not implemented.");
} }
public void setAttribute(String arg0, Object arg1) { public void setAttribute(String arg0, Object arg1) {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.setAttribute() not implemented."); "HttpServletRequestStub.setAttribute() not implemented.");
} }
public void setCharacterEncoding(String arg0) public void setCharacterEncoding(String arg0)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
throw new RuntimeException( throw new RuntimeException(
"HttpServletRequestStub.setCharacterEncoding() not implemented."); "HttpServletRequestStub.setCharacterEncoding() not implemented.");
} }
} }