commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r618055 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/web/ test/java/org/apache/commons/configuration2/web/
Date Sun, 03 Feb 2008 18:57:51 GMT
Author: oheger
Date: Sun Feb  3 10:57:49 2008
New Revision: 618055

URL: http://svn.apache.org/viewvc?rev=618055&view=rev
Log:
Removed dependency to commons-collections from ServletRequestConfiguration and some Java 1.5-related
changes

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/web/ServletRequestConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/web/TestServletRequestConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/web/ServletRequestConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/web/ServletRequestConfiguration.java?rev=618055&r1=618054&r2=618055&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/web/ServletRequestConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/web/ServletRequestConfiguration.java
Sun Feb  3 10:57:49 2008
@@ -24,8 +24,6 @@
 
 import javax.servlet.ServletRequest;
 
-import org.apache.commons.collections.iterators.EnumerationIterator;
-
 /**
  * A configuration wrapper to read the parameters of a servlet request. This
  * configuration is read only, adding or removing a property will throw an
@@ -65,13 +63,13 @@
         else
         {
             // ensure that escape characters in all list elements are removed
-            List result = new ArrayList(values.length);
-            for (int i = 0; i < values.length; i++)
+            List<Object> result = new ArrayList<Object>(values.length);
+            for (String value : values)
             {
-                Object val = handleDelimiters(values[i]);
+                Object val = handleDelimiters(value);
                 if (val instanceof Collection)
                 {
-                    result.addAll((Collection) val);
+                    result.addAll((Collection<?>) val);
                 }
                 else
                 {
@@ -82,8 +80,9 @@
         }
     }
 
-    public Iterator getKeys()
+    @SuppressWarnings("unchecked")
+    public Iterator<String> getKeys()
     {
-        return new EnumerationIterator(request.getParameterNames());
+        return request.getParameterMap().keySet().iterator();
     }
 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/web/TestServletRequestConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/web/TestServletRequestConfiguration.java?rev=618055&r1=618054&r2=618055&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/web/TestServletRequestConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/web/TestServletRequestConfiguration.java
Sun Feb  3 10:57:49 2008
@@ -17,20 +17,20 @@
 
 package org.apache.commons.configuration2.web;
 
-import java.util.Enumeration;
 import java.util.List;
+import java.util.Map;
 
 import javax.servlet.ServletRequest;
 
-import com.mockobjects.servlet.MockHttpServletRequest;
-import org.apache.commons.collections.iterators.IteratorEnumeration;
 import org.apache.commons.configuration2.AbstractConfiguration;
 import org.apache.commons.configuration2.BaseConfiguration;
 import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.ConfigurationConverter;
 import org.apache.commons.configuration2.TestAbstractConfiguration;
-import org.apache.commons.configuration2.web.ServletRequestConfiguration;
 import org.apache.commons.lang.StringUtils;
 
+import com.mockobjects.servlet.MockHttpServletRequest;
+
 /**
  * Test case for the {@link ServletRequestConfiguration} class.
  *
@@ -58,14 +58,16 @@
 
         ServletRequest request = new MockHttpServletRequest()
         {
+            @Override
             public String getParameter(String key)
             {
                 return null;
             }
 
-            public Enumeration getParameterNames()
+            @Override
+            public Map<?, ?> getParameterMap()
             {
-                return new IteratorEnumeration(configuration.getKeys());
+                return ConfigurationConverter.getMap(configuration);
             }
         };
 
@@ -84,14 +86,16 @@
     {
         ServletRequest request = new MockHttpServletRequest()
         {
+            @Override
             public String[] getParameterValues(String key)
             {
                 return base.getStringArray(key);
             }
-
-            public Enumeration getParameterNames()
+            
+            @Override
+            public Map<?, ?> getParameterMap()
             {
-                return new IteratorEnumeration(base.getKeys());
+                return ConfigurationConverter.getMap(base);
             }
         };
 
@@ -138,7 +142,7 @@
         assertEquals("Wrong number of list elements", values.length, config
                 .getList(listKey).size());
         Configuration c = createConfiguration(config);
-        List v = c.getList(listKey);
+        List<?> v = c.getList(listKey);
         assertEquals("Wrong number of elements in list", values.length, v
                 .size());
         for (int i = 0; i < values.length; i++)



Mime
View raw message