| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.apache.commons.fileupload.util; |
| 18 | |
|
| 19 | |
import java.io.Serializable; |
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.Collections; |
| 22 | |
import java.util.Iterator; |
| 23 | |
import java.util.LinkedHashMap; |
| 24 | |
import java.util.List; |
| 25 | |
import java.util.Locale; |
| 26 | |
import java.util.Map; |
| 27 | |
|
| 28 | |
import org.apache.commons.fileupload.FileItemHeaders; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 3195 | public class FileItemHeadersImpl implements FileItemHeaders, Serializable { |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
private static final long serialVersionUID = -4455695752627032559L; |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | 3195 | private final Map<String, List<String>> headerNameToValueListMap = new LinkedHashMap<String, List<String>>(); |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public String getHeader(String name) { |
| 52 | 15983 | String nameLower = name.toLowerCase(Locale.ENGLISH); |
| 53 | 15983 | List<String> headerValueList = headerNameToValueListMap.get(nameLower); |
| 54 | 15983 | if (null == headerValueList) { |
| 55 | 9536 | return null; |
| 56 | |
} |
| 57 | 6447 | return headerValueList.get(0); |
| 58 | |
} |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public Iterator<String> getHeaderNames() { |
| 64 | 1 | return headerNameToValueListMap.keySet().iterator(); |
| 65 | |
} |
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
public Iterator<String> getHeaders(String name) { |
| 71 | 4 | String nameLower = name.toLowerCase(Locale.ENGLISH); |
| 72 | 4 | List<String> headerValueList = headerNameToValueListMap.get(nameLower); |
| 73 | 4 | if (null == headerValueList) { |
| 74 | 1 | headerValueList = Collections.emptyList(); |
| 75 | |
} |
| 76 | 4 | return headerValueList.iterator(); |
| 77 | |
} |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
public synchronized void addHeader(String name, String value) { |
| 86 | 3246 | String nameLower = name.toLowerCase(Locale.ENGLISH); |
| 87 | 3246 | List<String> headerValueList = headerNameToValueListMap.get(nameLower); |
| 88 | 3246 | if (null == headerValueList) { |
| 89 | 3243 | headerValueList = new ArrayList<String>(); |
| 90 | 3243 | headerNameToValueListMap.put(nameLower, headerValueList); |
| 91 | |
} |
| 92 | 3246 | headerValueList.add(value); |
| 93 | 3246 | } |
| 94 | |
|
| 95 | |
} |