Apply generics to javax.servlet.* on the basis that the EG is in the process of accep...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 12 Jan 2009 14:16:19 +0000 (14:16 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 12 Jan 2009 14:16:19 +0000 (14:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@733768 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
java/javax/servlet/FilterConfig.java
java/javax/servlet/GenericServlet.java
java/javax/servlet/ServletConfig.java
java/javax/servlet/ServletContext.java
java/javax/servlet/ServletRequest.java
java/javax/servlet/ServletRequestWrapper.java
java/javax/servlet/http/HttpServletRequest.java
java/javax/servlet/http/HttpServletRequestWrapper.java
java/javax/servlet/http/HttpSession.java
java/javax/servlet/http/HttpSessionContext.java
java/javax/servlet/http/HttpUtils.java
java/javax/servlet/jsp/el/ExpressionEvaluator.java
java/javax/servlet/jsp/el/ImplicitObjectELResolver.java
java/javax/servlet/jsp/el/ScopedAttributeELResolver.java
java/javax/servlet/jsp/tagext/TagSupport.java

index e1ef616..8eeb879 100644 (file)
@@ -84,7 +84,7 @@ public interface FilterConfig {
      *
      */
 
-    public Enumeration getInitParameterNames();
+    public Enumeration<String> getInitParameterNames();
 
 
 
index feec0c4..8841079 100644 (file)
@@ -119,7 +119,7 @@ public abstract class GenericServlet
     *
     */
 
-    public Enumeration getInitParameterNames() {
+    public Enumeration<String> getInitParameterNames() {
        return getServletConfig().getInitParameterNames();
     }   
     
index dea6bbd..b0c385c 100644 (file)
@@ -89,7 +89,7 @@ public interface ServletConfig {
      *
      */
 
-    public Enumeration getInitParameterNames();
+    public Enumeration<String> getInitParameterNames();
 
 
 }
index cbaab95..d449052 100644 (file)
@@ -162,7 +162,7 @@ public interface ServletContext {
     * @since Servlet 2.3
     */
     
-    public Set getResourcePaths(String path);
+    public Set<String> getResourcePaths(String path);
     
     
 
@@ -352,7 +352,7 @@ public interface ServletContext {
      *
      */
     
-    public Enumeration getServlets();
+    public Enumeration<Servlet> getServlets();
     
     
     
@@ -371,7 +371,7 @@ public interface ServletContext {
      *
      */
  
-    public Enumeration getServletNames();
+    public Enumeration<String> getServletNames();
     
   
   
@@ -524,7 +524,7 @@ public interface ServletContext {
      * @see ServletConfig#getInitParameter
      */
 
-    public Enumeration getInitParameterNames();
+    public Enumeration<String> getInitParameterNames();
     
     
 
@@ -577,7 +577,7 @@ public interface ServletContext {
      *
      */
 
-    public Enumeration getAttributeNames();
+    public Enumeration<String> getAttributeNames();
     
     
     
index c090ae2..21c486d 100644 (file)
@@ -91,7 +91,7 @@ public interface ServletRequest {
      *
      */
 
-    public Enumeration getAttributeNames();
+    public Enumeration<String> getAttributeNames();
     
     
     
@@ -229,7 +229,7 @@ public interface ServletRequest {
      *
      */
      
-    public Enumeration getParameterNames();
+    public Enumeration<String> getParameterNames();
     
     
     
@@ -266,7 +266,7 @@ public interface ServletRequest {
      *
      */
 
-    public Map getParameterMap();
+    public Map<String,String[]> getParameterMap();
     
     
 
@@ -480,7 +480,7 @@ public interface ServletRequest {
      *
      */
 
-    public Enumeration getLocales();
+    public Enumeration<Locale> getLocales();
     
     
     
index a863ee8..2e42ab1 100644 (file)
@@ -89,7 +89,7 @@ public class ServletRequestWrapper implements ServletRequest {
      * on the wrapped request object.
      */
 
-    public Enumeration getAttributeNames() {
+    public Enumeration<String> 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<String,String[]> getParameterMap() {
        return this.request.getParameterMap();
     }
     
@@ -174,7 +174,7 @@ public class ServletRequestWrapper implements ServletRequest {
      * on the wrapped request object.
      */
      
-    public Enumeration getParameterNames() {
+    public Enumeration<String> getParameterNames() {
        return this.request.getParameterNames();
     }
     
@@ -315,7 +315,7 @@ public class ServletRequestWrapper implements ServletRequest {
      * on the wrapped request object.
      */
 
-    public Enumeration getLocales() {
+    public Enumeration<Locale> getLocales() {
        return this.request.getLocales();
     }
     
index 50b5d4f..c247a15 100644 (file)
@@ -192,7 +192,7 @@ public interface HttpServletRequest extends ServletRequest {
      *
      */                        
 
-    public Enumeration getHeaders(String name); 
+    public Enumeration<String> getHeaders(String name); 
     
     
     
@@ -219,7 +219,7 @@ public interface HttpServletRequest extends ServletRequest {
      *
      */
 
-    public Enumeration getHeaderNames();
+    public Enumeration<String> getHeaderNames();
     
     
     
index 28cc3a9..f9d87d5 100644 (file)
@@ -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<String> 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<String> getHeaderNames() {
        return this._getHttpServletRequest().getHeaderNames();
     }
     
index 0aa4e5f..08a5bc0 100644 (file)
@@ -257,7 +257,7 @@ public interface HttpSession {
      *
      */
     
-    public Enumeration getAttributeNames();
+    public Enumeration<String> getAttributeNames();
     
     
     
index 3810aba..674f169 100644 (file)
@@ -62,7 +62,7 @@ public interface HttpSessionContext {
      *
      */
 
-    public Enumeration getIds();
+    public Enumeration<String> getIds();
 }
 
 
index dc612f6..90d5468 100644 (file)
@@ -84,14 +84,14 @@ public class HttpUtils {
      *
      */
 
-    static public Hashtable parseQueryString(String s) {
+    static public Hashtable<String,String[]> parseQueryString(String s) {
 
        String valArray[] = null;
        
        if (s == null) {
            throw new IllegalArgumentException();
        }
-       Hashtable ht = new Hashtable();
+       Hashtable<String,String[]> ht = new Hashtable<String,String[]>();
        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<String,String[]> 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<String,String[]>();
+
 
        if (in == null) {
            throw new IllegalArgumentException();
index 72c26a0..44fec8e 100644 (file)
@@ -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; 
index 7191932..0418561 100644 (file)
@@ -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<String,Object> applicationScope;
 
-        private Map cookie;
+        private Map<String,Cookie> cookie;
 
-        private Map header;
+        private Map<String,String> header;
 
-        private Map headerValues;
+        private Map<String,String[]> headerValues;
 
-        private Map initParam;
+        private Map<String,String> initParam;
 
-        private Map pageScope;
+        private Map<String,Object> pageScope;
 
-        private Map param;
+        private Map<String,String> param;
 
-        private Map paramValues;
+        private Map<String,String[]> paramValues;
 
-        private Map requestScope;
+        private Map<String,Object> requestScope;
 
-        private Map sessionScope;
+        private Map<String,Object> sessionScope;
 
         public ScopeManager(PageContext page) {
             this.page = page;
@@ -230,9 +230,9 @@ public class ImplicitObjectELResolver extends ELResolver {
             return mngr;
         }
 
-        public Map getApplicationScope() {
+        public Map<String,Object> getApplicationScope() {
             if (this.applicationScope == null) {
-                this.applicationScope = new ScopeMap() {
+                this.applicationScope = new ScopeMap<Object>() {
                     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<String> getAttributeNames() {
                         return page.getServletContext().getAttributeNames();
                     }
 
@@ -253,14 +253,14 @@ public class ImplicitObjectELResolver extends ELResolver {
             return this.applicationScope;
         }
 
-        public Map getCookie() {
+        public Map<String,Cookie> getCookie() {
             if (this.cookie == null) {
-                this.cookie = new ScopeMap() {
-                    protected Enumeration getAttributeNames() {
+                this.cookie = new ScopeMap<Cookie>() {
+                    protected Enumeration<String> getAttributeNames() {
                         Cookie[] c = ((HttpServletRequest) page.getRequest())
                                 .getCookies();
                         if (c != null) {
-                            Vector v = new Vector();
+                            Vector<String> v = new Vector<String>();
                             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<String,String> getHeader() {
             if (this.header == null) {
-                this.header = new ScopeMap() {
-                    protected Enumeration getAttributeNames() {
+                this.header = new ScopeMap<String>() {
+                    protected Enumeration<String> 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<String,String[]> getHeaderValues() {
             if (this.headerValues == null) {
-                this.headerValues = new ScopeMap() {
-                    protected Enumeration getAttributeNames() {
+                this.headerValues = new ScopeMap<String[]>() {
+                    protected Enumeration<String> getAttributeNames() {
                         return ((HttpServletRequest) page.getRequest())
                                 .getHeaderNames();
                     }
 
-                    protected Object getAttribute(String name) {
-                        Enumeration e = ((HttpServletRequest) page.getRequest())
-                                .getHeaders(name);
+                    protected String[] getAttribute(String name) {
+                        Enumeration<String> e =
+                            ((HttpServletRequest) page.getRequest())
+                                    .getHeaders(name);
                         if (e != null) {
-                            List list = new ArrayList();
+                            List<String> list = new ArrayList<String>();
                             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<String,String> getInitParam() {
             if (this.initParam == null) {
-                this.initParam = new ScopeMap() {
-                    protected Enumeration getAttributeNames() {
+                this.initParam = new ScopeMap<String>() {
+                    protected Enumeration<String> 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<String,Object> getPageScope() {
             if (this.pageScope == null) {
-                this.pageScope = new ScopeMap() {
+                this.pageScope = new ScopeMap<Object>() {
                     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<String> 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<String,String> getParam() {
             if (this.param == null) {
-                this.param = new ScopeMap() {
-                    protected Enumeration getAttributeNames() {
+                this.param = new ScopeMap<String>() {
+                    protected Enumeration<String> 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<String,String[]> getParamValues() {
             if (this.paramValues == null) {
-                this.paramValues = new ScopeMap() {
-                    protected Object getAttribute(String name) {
+                this.paramValues = new ScopeMap<String[]>() {
+                    protected String[] getAttribute(String name) {
                         return page.getRequest().getParameterValues(name);
                     }
 
-                    protected Enumeration getAttributeNames() {
+                    protected Enumeration<String> getAttributeNames() {
                         return page.getRequest().getParameterNames();
                     }
                 };
@@ -403,9 +404,9 @@ public class ImplicitObjectELResolver extends ELResolver {
             return this.paramValues;
         }
 
-        public Map getRequestScope() {
+        public Map<String,Object> getRequestScope() {
             if (this.requestScope == null) {
-                this.requestScope = new ScopeMap() {
+                this.requestScope = new ScopeMap<Object>() {
                     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<String> getAttributeNames() {
                         return page.getRequest().getAttributeNames();
                     }
 
@@ -426,9 +427,9 @@ public class ImplicitObjectELResolver extends ELResolver {
             return this.requestScope;
         }
 
-        public Map getSessionScope() {
+        public Map<String,Object> getSessionScope() {
             if (this.sessionScope == null) {
-                this.sessionScope = new ScopeMap() {
+                this.sessionScope = new ScopeMap<Object>() {
                     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<String> 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<V> extends AbstractMap<String,V> {
 
-        protected abstract Enumeration getAttributeNames();
+        protected abstract Enumeration<String> 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<Map.Entry<String,V>> entrySet() {
+            Enumeration<String> e = getAttributeNames();
+            Set<Map.Entry<String, V>> set = new HashSet<Map.Entry<String, V>>();
             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<String,V> {
 
             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();
             }
index 6945535..a802f33 100644 (file)
@@ -111,13 +111,13 @@ public class ScopedAttributeELResolver extends ELResolver {
 
                PageContext ctxt = (PageContext) context.getContext(JspContext.class);
                List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
-               Enumeration e;
+               Enumeration<String> 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);
index 20e0cfd..cd570c5 100644 (file)
@@ -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 ||