You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by cz...@apache.org on 2009/02/25 17:10:07 UTC

svn commit: r747842 - /portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java

Author: cziegeler
Date: Wed Feb 25 16:10:06 2009
New Revision: 747842

URL: http://svn.apache.org/viewvc?rev=747842&view=rev
Log:
Use generics in string utils.

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java?rev=747842&r1=747841&r2=747842&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java Wed Feb 25 16:10:06 2009
@@ -17,7 +17,6 @@
 package org.apache.pluto.util;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -40,7 +39,7 @@
     /**
      * TODO: can't we just use String[].clone()?
      * @param source
-     * @return
+     * @return The copied array
      */
     public static String[] copy(String[] source) {
         if (source == null) {
@@ -58,20 +57,10 @@
      * @param parameters  the parameter map to deep-clone.
      * @return the deep-cloned parameter map.
      */
-    public static Map copyParameters(Map parameters) {
-        Map result = new HashMap(parameters);
-        for (Iterator it = result.entrySet().iterator(); it.hasNext();) {
-            Map.Entry entry = (Map.Entry) it.next();
-            if (!(entry.getKey() instanceof String)) {
-                throw new IllegalArgumentException("Parameter map keys "
-                		+ "must not be null and of type java.lang.String.");
-            }
-            try {
-                entry.setValue(copy((String[]) entry.getValue()));
-            } catch (ClassCastException ex) {
-                throw new IllegalArgumentException("Parameter map values "
-                		+ "must not be null and of type java.lang.String[].");
-            }
+    public static Map<String, String[]> copyParameters(Map<String, String[]> parameters) {
+        final Map<String, String[]> result = new HashMap<String, String[]>(parameters);
+        for( final Map.Entry<String, String[]> entry : result.entrySet()) {
+            entry.setValue(copy(entry.getValue()));
         }
         return result;
     }