commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1453040 - /commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
Date Tue, 05 Mar 2013 22:13:23 GMT
Author: simonetripodi
Date: Tue Mar  5 22:13:23 2013
New Revision: 1453040

URL: http://svn.apache.org/r1453040
Log:
[FILEUPLOAD-221] #comment LinkedHashMap is now available, no more need for a List to keep
the keys order #resolve

Modified:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java?rev=1453040&r1=1453039&r2=1453040&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java
Tue Mar  5 22:13:23 2013
@@ -19,8 +19,8 @@ package org.apache.commons.fileupload.ut
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -39,14 +39,7 @@ public class FileItemHeadersImpl impleme
      * Map of <code>String</code> keys to a <code>List</code> of
      * <code>String</code> instances.
      */
-    private final Map<String, List<String>> headerNameToValueListMap = new HashMap<String,
List<String>>();
-
-    /**
-     * List to preserve order of headers as added.  This would not be
-     * needed if a <code>LinkedHashMap</code> could be used, but don't
-     * want to depend on 1.4.
-     */
-    private final List<String> headerNameList = new ArrayList<String>();
+    private final Map<String, List<String>> headerNameToValueListMap = new LinkedHashMap<String,
List<String>>();
 
     public String getHeader(String name) {
         String nameLower = name.toLowerCase();
@@ -58,7 +51,7 @@ public class FileItemHeadersImpl impleme
     }
 
     public Iterator<String> getHeaderNames() {
-        return headerNameList.iterator();
+        return headerNameToValueListMap.keySet().iterator();
     }
 
     public Iterator<String> getHeaders(String name) {
@@ -82,7 +75,6 @@ public class FileItemHeadersImpl impleme
         if (null == headerValueList) {
             headerValueList = new ArrayList<String>();
             headerNameToValueListMap.put(nameLower, headerValueList);
-            headerNameList.add(nameLower);
         }
         headerValueList.add(value);
     }



Mime
View raw message