From decc23ec4d1583108ba102f6a7e71af922a6f279 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 12 Jan 2009 14:16:19 +0000 Subject: [PATCH] Apply generics to javax.servlet.* on the basis that the EG is in the process of accepting a patch to do this. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@733768 13f79535-47bb-0310-9956-ffa450edef68 --- java/javax/servlet/FilterConfig.java | 2 +- java/javax/servlet/GenericServlet.java | 2 +- java/javax/servlet/ServletConfig.java | 2 +- java/javax/servlet/ServletContext.java | 10 +- java/javax/servlet/ServletRequest.java | 8 +- java/javax/servlet/ServletRequestWrapper.java | 8 +- java/javax/servlet/http/HttpServletRequest.java | 4 +- .../servlet/http/HttpServletRequestWrapper.java | 4 +- java/javax/servlet/http/HttpSession.java | 2 +- java/javax/servlet/http/HttpSessionContext.java | 2 +- java/javax/servlet/http/HttpUtils.java | 14 ++- java/javax/servlet/jsp/el/ExpressionEvaluator.java | 4 +- .../servlet/jsp/el/ImplicitObjectELResolver.java | 139 +++++++++++---------- .../servlet/jsp/el/ScopedAttributeELResolver.java | 10 +- java/javax/servlet/jsp/tagext/TagSupport.java | 2 +- 15 files changed, 108 insertions(+), 105 deletions(-) diff --git a/java/javax/servlet/FilterConfig.java b/java/javax/servlet/FilterConfig.java index e1ef616c7..8eeb87936 100644 --- a/java/javax/servlet/FilterConfig.java +++ b/java/javax/servlet/FilterConfig.java @@ -84,7 +84,7 @@ public interface FilterConfig { * */ - public Enumeration getInitParameterNames(); + public Enumeration getInitParameterNames(); diff --git a/java/javax/servlet/GenericServlet.java b/java/javax/servlet/GenericServlet.java index feec0c461..88410795d 100644 --- a/java/javax/servlet/GenericServlet.java +++ b/java/javax/servlet/GenericServlet.java @@ -119,7 +119,7 @@ public abstract class GenericServlet * */ - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { return getServletConfig().getInitParameterNames(); } diff --git a/java/javax/servlet/ServletConfig.java b/java/javax/servlet/ServletConfig.java index dea6bbd5e..b0c385c4a 100644 --- a/java/javax/servlet/ServletConfig.java +++ b/java/javax/servlet/ServletConfig.java @@ -89,7 +89,7 @@ public interface ServletConfig { * */ - public Enumeration getInitParameterNames(); + public Enumeration getInitParameterNames(); } diff --git a/java/javax/servlet/ServletContext.java b/java/javax/servlet/ServletContext.java index cbaab95be..d4490528d 100644 --- a/java/javax/servlet/ServletContext.java +++ b/java/javax/servlet/ServletContext.java @@ -162,7 +162,7 @@ public interface ServletContext { * @since Servlet 2.3 */ - public Set getResourcePaths(String path); + public Set getResourcePaths(String path); @@ -352,7 +352,7 @@ public interface ServletContext { * */ - public Enumeration getServlets(); + public Enumeration getServlets(); @@ -371,7 +371,7 @@ public interface ServletContext { * */ - public Enumeration getServletNames(); + public Enumeration getServletNames(); @@ -524,7 +524,7 @@ public interface ServletContext { * @see ServletConfig#getInitParameter */ - public Enumeration getInitParameterNames(); + public Enumeration getInitParameterNames(); @@ -577,7 +577,7 @@ public interface ServletContext { * */ - public Enumeration getAttributeNames(); + public Enumeration getAttributeNames(); diff --git a/java/javax/servlet/ServletRequest.java b/java/javax/servlet/ServletRequest.java index c090ae293..21c486d1d 100644 --- a/java/javax/servlet/ServletRequest.java +++ b/java/javax/servlet/ServletRequest.java @@ -91,7 +91,7 @@ public interface ServletRequest { * */ - public Enumeration getAttributeNames(); + public Enumeration getAttributeNames(); @@ -229,7 +229,7 @@ public interface ServletRequest { * */ - public Enumeration getParameterNames(); + public Enumeration getParameterNames(); @@ -266,7 +266,7 @@ public interface ServletRequest { * */ - public Map getParameterMap(); + public Map getParameterMap(); @@ -480,7 +480,7 @@ public interface ServletRequest { * */ - public Enumeration getLocales(); + public Enumeration getLocales(); diff --git a/java/javax/servlet/ServletRequestWrapper.java b/java/javax/servlet/ServletRequestWrapper.java index a863ee845..2e42ab151 100644 --- a/java/javax/servlet/ServletRequestWrapper.java +++ b/java/javax/servlet/ServletRequestWrapper.java @@ -89,7 +89,7 @@ public class ServletRequestWrapper implements ServletRequest { * on the wrapped request object. */ - public Enumeration getAttributeNames() { + public Enumeration getAttributeNames() { return this.request.getAttributeNames(); } @@ -162,7 +162,7 @@ public class ServletRequestWrapper implements ServletRequest { * The default behavior of this method is to return getParameterMap() * on the wrapped request object. */ - public Map getParameterMap() { + public Map getParameterMap() { return this.request.getParameterMap(); } @@ -174,7 +174,7 @@ public class ServletRequestWrapper implements ServletRequest { * on the wrapped request object. */ - public Enumeration getParameterNames() { + public Enumeration getParameterNames() { return this.request.getParameterNames(); } @@ -315,7 +315,7 @@ public class ServletRequestWrapper implements ServletRequest { * on the wrapped request object. */ - public Enumeration getLocales() { + public Enumeration getLocales() { return this.request.getLocales(); } diff --git a/java/javax/servlet/http/HttpServletRequest.java b/java/javax/servlet/http/HttpServletRequest.java index 50b5d4f92..c247a1504 100644 --- a/java/javax/servlet/http/HttpServletRequest.java +++ b/java/javax/servlet/http/HttpServletRequest.java @@ -192,7 +192,7 @@ public interface HttpServletRequest extends ServletRequest { * */ - public Enumeration getHeaders(String name); + public Enumeration getHeaders(String name); @@ -219,7 +219,7 @@ public interface HttpServletRequest extends ServletRequest { * */ - public Enumeration getHeaderNames(); + public Enumeration getHeaderNames(); diff --git a/java/javax/servlet/http/HttpServletRequestWrapper.java b/java/javax/servlet/http/HttpServletRequestWrapper.java index 28cc3a98c..f9d87d54a 100644 --- a/java/javax/servlet/http/HttpServletRequestWrapper.java +++ b/java/javax/servlet/http/HttpServletRequestWrapper.java @@ -84,7 +84,7 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements * The default behavior of this method is to return getHeaders(String name) * on the wrapped request object. */ - public Enumeration getHeaders(String name) { + public Enumeration getHeaders(String name) { return this._getHttpServletRequest().getHeaders(name); } @@ -93,7 +93,7 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements * on the wrapped request object. */ - public Enumeration getHeaderNames() { + public Enumeration getHeaderNames() { return this._getHttpServletRequest().getHeaderNames(); } diff --git a/java/javax/servlet/http/HttpSession.java b/java/javax/servlet/http/HttpSession.java index 0aa4e5ffa..08a5bc0df 100644 --- a/java/javax/servlet/http/HttpSession.java +++ b/java/javax/servlet/http/HttpSession.java @@ -257,7 +257,7 @@ public interface HttpSession { * */ - public Enumeration getAttributeNames(); + public Enumeration getAttributeNames(); diff --git a/java/javax/servlet/http/HttpSessionContext.java b/java/javax/servlet/http/HttpSessionContext.java index 3810aba53..674f169f2 100644 --- a/java/javax/servlet/http/HttpSessionContext.java +++ b/java/javax/servlet/http/HttpSessionContext.java @@ -62,7 +62,7 @@ public interface HttpSessionContext { * */ - public Enumeration getIds(); + public Enumeration getIds(); } diff --git a/java/javax/servlet/http/HttpUtils.java b/java/javax/servlet/http/HttpUtils.java index dc612f6d3..90d546824 100644 --- a/java/javax/servlet/http/HttpUtils.java +++ b/java/javax/servlet/http/HttpUtils.java @@ -84,14 +84,14 @@ public class HttpUtils { * */ - static public Hashtable parseQueryString(String s) { + static public Hashtable parseQueryString(String s) { String valArray[] = null; if (s == null) { throw new IllegalArgumentException(); } - Hashtable ht = new Hashtable(); + Hashtable ht = new Hashtable(); StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(s, "&"); while (st.hasMoreTokens()) { @@ -105,7 +105,7 @@ public class HttpUtils { String key = parseName(pair.substring(0, pos), sb); String val = parseName(pair.substring(pos+1, pair.length()), sb); if (ht.containsKey(key)) { - String oldVals[] = (String []) ht.get(key); + String oldVals[] = ht.get(key); valArray = new String[oldVals.length + 1]; for (int i = 0; i < oldVals.length; i++) valArray[i] = oldVals[i]; @@ -163,14 +163,16 @@ public class HttpUtils { */ - static public Hashtable parsePostData(int len, + static public Hashtable parsePostData(int len, ServletInputStream in) { // XXX // should a length of 0 be an IllegalArgumentException - if (len <=0) - return new Hashtable(); // cheap hack to return an empty hash + // cheap hack to return an empty hash + if (len <=0) + return new Hashtable(); + if (in == null) { throw new IllegalArgumentException(); diff --git a/java/javax/servlet/jsp/el/ExpressionEvaluator.java b/java/javax/servlet/jsp/el/ExpressionEvaluator.java index 72c26a0e2..44fec8e61 100644 --- a/java/javax/servlet/jsp/el/ExpressionEvaluator.java +++ b/java/javax/servlet/jsp/el/ExpressionEvaluator.java @@ -77,7 +77,7 @@ public abstract class ExpressionEvaluator { * @exception ELException Thrown if parsing errors were found. */ public abstract Expression parseExpression( String expression, - Class expectedType, + Class expectedType, FunctionMapper fMapper ) throws ELException; @@ -100,7 +100,7 @@ public abstract class ExpressionEvaluator { * @exception ELException Thrown if the expression evaluation failed. */ public abstract Object evaluate( String expression, - Class expectedType, + Class expectedType, VariableResolver vResolver, FunctionMapper fMapper ) throws ELException; diff --git a/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java b/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java index 7191932f7..0418561a0 100644 --- a/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java +++ b/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java @@ -119,7 +119,7 @@ public class ImplicitObjectELResolver extends ELResolver { return null; } - public Class getType(ELContext context, Object base, Object property) + public Class getType(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); @@ -197,25 +197,25 @@ public class ImplicitObjectELResolver extends ELResolver { private final PageContext page; - private Map applicationScope; + private Map applicationScope; - private Map cookie; + private Map cookie; - private Map header; + private Map header; - private Map headerValues; + private Map headerValues; - private Map initParam; + private Map initParam; - private Map pageScope; + private Map pageScope; - private Map param; + private Map param; - private Map paramValues; + private Map paramValues; - private Map requestScope; + private Map requestScope; - private Map sessionScope; + private Map sessionScope; public ScopeManager(PageContext page) { this.page = page; @@ -230,9 +230,9 @@ public class ImplicitObjectELResolver extends ELResolver { return mngr; } - public Map getApplicationScope() { + public Map getApplicationScope() { if (this.applicationScope == null) { - this.applicationScope = new ScopeMap() { + this.applicationScope = new ScopeMap() { protected void setAttribute(String name, Object value) { page.getServletContext().setAttribute(name, value); } @@ -241,7 +241,7 @@ public class ImplicitObjectELResolver extends ELResolver { page.getServletContext().removeAttribute(name); } - protected Enumeration getAttributeNames() { + protected Enumeration getAttributeNames() { return page.getServletContext().getAttributeNames(); } @@ -253,14 +253,14 @@ public class ImplicitObjectELResolver extends ELResolver { return this.applicationScope; } - public Map getCookie() { + public Map getCookie() { if (this.cookie == null) { - this.cookie = new ScopeMap() { - protected Enumeration getAttributeNames() { + this.cookie = new ScopeMap() { + protected Enumeration getAttributeNames() { Cookie[] c = ((HttpServletRequest) page.getRequest()) .getCookies(); if (c != null) { - Vector v = new Vector(); + Vector v = new Vector(); for (int i = 0; i < c.length; i++) { v.add(c[i].getName()); } @@ -269,7 +269,7 @@ public class ImplicitObjectELResolver extends ELResolver { return null; } - protected Object getAttribute(String name) { + protected Cookie getAttribute(String name) { Cookie[] c = ((HttpServletRequest) page.getRequest()) .getCookies(); if (c != null) { @@ -287,15 +287,15 @@ public class ImplicitObjectELResolver extends ELResolver { return this.cookie; } - public Map getHeader() { + public Map getHeader() { if (this.header == null) { - this.header = new ScopeMap() { - protected Enumeration getAttributeNames() { + this.header = new ScopeMap() { + protected Enumeration getAttributeNames() { return ((HttpServletRequest) page.getRequest()) .getHeaderNames(); } - protected Object getAttribute(String name) { + protected String getAttribute(String name) { return ((HttpServletRequest) page.getRequest()) .getHeader(name); } @@ -304,21 +304,22 @@ public class ImplicitObjectELResolver extends ELResolver { return this.header; } - public Map getHeaderValues() { + public Map getHeaderValues() { if (this.headerValues == null) { - this.headerValues = new ScopeMap() { - protected Enumeration getAttributeNames() { + this.headerValues = new ScopeMap() { + protected Enumeration getAttributeNames() { return ((HttpServletRequest) page.getRequest()) .getHeaderNames(); } - protected Object getAttribute(String name) { - Enumeration e = ((HttpServletRequest) page.getRequest()) - .getHeaders(name); + protected String[] getAttribute(String name) { + Enumeration e = + ((HttpServletRequest) page.getRequest()) + .getHeaders(name); if (e != null) { - List list = new ArrayList(); + List list = new ArrayList(); while (e.hasMoreElements()) { - list.add(e.nextElement().toString()); + list.add(e.nextElement()); } return list.toArray(new String[list.size()]); } @@ -330,14 +331,14 @@ public class ImplicitObjectELResolver extends ELResolver { return this.headerValues; } - public Map getInitParam() { + public Map getInitParam() { if (this.initParam == null) { - this.initParam = new ScopeMap() { - protected Enumeration getAttributeNames() { + this.initParam = new ScopeMap() { + protected Enumeration getAttributeNames() { return page.getServletContext().getInitParameterNames(); } - protected Object getAttribute(String name) { + protected String getAttribute(String name) { return page.getServletContext().getInitParameter(name); } }; @@ -349,9 +350,9 @@ public class ImplicitObjectELResolver extends ELResolver { return this.page; } - public Map getPageScope() { + public Map getPageScope() { if (this.pageScope == null) { - this.pageScope = new ScopeMap() { + this.pageScope = new ScopeMap() { protected void setAttribute(String name, Object value) { page.setAttribute(name, value); } @@ -360,9 +361,9 @@ public class ImplicitObjectELResolver extends ELResolver { page.removeAttribute(name); } - protected Enumeration getAttributeNames() { - return page - .getAttributeNamesInScope(PageContext.PAGE_SCOPE); + protected Enumeration getAttributeNames() { + return page.getAttributeNamesInScope( + PageContext.PAGE_SCOPE); } protected Object getAttribute(String name) { @@ -373,14 +374,14 @@ public class ImplicitObjectELResolver extends ELResolver { return this.pageScope; } - public Map getParam() { + public Map getParam() { if (this.param == null) { - this.param = new ScopeMap() { - protected Enumeration getAttributeNames() { + this.param = new ScopeMap() { + protected Enumeration getAttributeNames() { return page.getRequest().getParameterNames(); } - protected Object getAttribute(String name) { + protected String getAttribute(String name) { return page.getRequest().getParameter(name); } }; @@ -388,14 +389,14 @@ public class ImplicitObjectELResolver extends ELResolver { return this.param; } - public Map getParamValues() { + public Map getParamValues() { if (this.paramValues == null) { - this.paramValues = new ScopeMap() { - protected Object getAttribute(String name) { + this.paramValues = new ScopeMap() { + protected String[] getAttribute(String name) { return page.getRequest().getParameterValues(name); } - protected Enumeration getAttributeNames() { + protected Enumeration getAttributeNames() { return page.getRequest().getParameterNames(); } }; @@ -403,9 +404,9 @@ public class ImplicitObjectELResolver extends ELResolver { return this.paramValues; } - public Map getRequestScope() { + public Map getRequestScope() { if (this.requestScope == null) { - this.requestScope = new ScopeMap() { + this.requestScope = new ScopeMap() { protected void setAttribute(String name, Object value) { page.getRequest().setAttribute(name, value); } @@ -414,7 +415,7 @@ public class ImplicitObjectELResolver extends ELResolver { page.getRequest().removeAttribute(name); } - protected Enumeration getAttributeNames() { + protected Enumeration getAttributeNames() { return page.getRequest().getAttributeNames(); } @@ -426,9 +427,9 @@ public class ImplicitObjectELResolver extends ELResolver { return this.requestScope; } - public Map getSessionScope() { + public Map getSessionScope() { if (this.sessionScope == null) { - this.sessionScope = new ScopeMap() { + this.sessionScope = new ScopeMap() { protected void setAttribute(String name, Object value) { ((HttpServletRequest) page.getRequest()).getSession() .setAttribute(name, value); @@ -441,7 +442,7 @@ public class ImplicitObjectELResolver extends ELResolver { } } - protected Enumeration getAttributeNames() { + protected Enumeration getAttributeNames() { HttpSession session = page.getSession(); if (session != null) { return session.getAttributeNames(); @@ -462,11 +463,11 @@ public class ImplicitObjectELResolver extends ELResolver { } } - private abstract static class ScopeMap extends AbstractMap { + private abstract static class ScopeMap extends AbstractMap { - protected abstract Enumeration getAttributeNames(); + protected abstract Enumeration getAttributeNames(); - protected abstract Object getAttribute(String name); + protected abstract V getAttribute(String name); protected void removeAttribute(String name) { throw new UnsupportedOperationException(); @@ -476,18 +477,18 @@ public class ImplicitObjectELResolver extends ELResolver { throw new UnsupportedOperationException(); } - public final Set entrySet() { - Enumeration e = getAttributeNames(); - Set set = new HashSet(); + public final Set> entrySet() { + Enumeration e = getAttributeNames(); + Set> set = new HashSet>(); if (e != null) { while (e.hasMoreElements()) { - set.add(new ScopeEntry((String) e.nextElement())); + set.add(new ScopeEntry(e.nextElement())); } } return set; } - private class ScopeEntry implements Map.Entry { + private class ScopeEntry implements Map.Entry { private final String key; @@ -495,15 +496,15 @@ public class ImplicitObjectELResolver extends ELResolver { this.key = key; } - public Object getKey() { + public String getKey() { return this.key; } - public Object getValue() { + public V getValue() { return getAttribute(this.key); } - public Object setValue(Object value) { + public V setValue(Object value) { if (value == null) { removeAttribute(this.key); } else { @@ -522,14 +523,14 @@ public class ImplicitObjectELResolver extends ELResolver { } - public final Object get(Object key) { + public final V get(String key) { if (key != null) { - return getAttribute(key.toString()); + return getAttribute(key); } return null; } - public final Object put(Object key, Object value) { + public final V put(String key, V value) { if (key == null) { throw new NullPointerException(); } @@ -541,7 +542,7 @@ public class ImplicitObjectELResolver extends ELResolver { return null; } - public final Object remove(Object key) { + public final V remove(String key) { if (key == null) { throw new NullPointerException(); } diff --git a/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java b/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java index 694553515..a802f33b4 100644 --- a/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java +++ b/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java @@ -111,13 +111,13 @@ public class ScopedAttributeELResolver extends ELResolver { PageContext ctxt = (PageContext) context.getContext(JspContext.class); List list = new ArrayList(); - Enumeration e; + Enumeration e; Object value; String name; e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE); while (e.hasMoreElements()) { - name = (String) e.nextElement(); + name = e.nextElement(); value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE); FeatureDescriptor descriptor = new FeatureDescriptor(); descriptor.setName(name); @@ -133,7 +133,7 @@ public class ScopedAttributeELResolver extends ELResolver { e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE); while (e.hasMoreElements()) { - name = (String) e.nextElement(); + name = e.nextElement(); value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE); FeatureDescriptor descriptor = new FeatureDescriptor(); descriptor.setName(name); @@ -150,7 +150,7 @@ public class ScopedAttributeELResolver extends ELResolver { if (ctxt.getSession() != null) { e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE); while (e.hasMoreElements()) { - name = (String) e.nextElement(); + name = e.nextElement(); value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE); FeatureDescriptor descriptor = new FeatureDescriptor(); descriptor.setName(name); @@ -167,7 +167,7 @@ public class ScopedAttributeELResolver extends ELResolver { e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE); while (e.hasMoreElements()) { - name = (String) e.nextElement(); + name = e.nextElement(); value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE); FeatureDescriptor descriptor = new FeatureDescriptor(); descriptor.setName(name); diff --git a/java/javax/servlet/jsp/tagext/TagSupport.java b/java/javax/servlet/jsp/tagext/TagSupport.java index 20e0cfdbf..cd570c5b0 100644 --- a/java/javax/servlet/jsp/tagext/TagSupport.java +++ b/java/javax/servlet/jsp/tagext/TagSupport.java @@ -73,7 +73,7 @@ public class TagSupport implements IterationTag, Serializable { * or is an instance of the class specified */ - public static final Tag findAncestorWithClass(Tag from, Class klass) { + public static final Tag findAncestorWithClass(Tag from, Class klass) { boolean isInterface = false; if (from == null || -- 2.11.0