|
25 | 25 |
|
26 | 26 | import java.io.IOException; |
27 | 27 | import java.util.HashMap; |
28 | | -import java.util.LinkedList; |
29 | | -import java.util.List; |
30 | 28 | import java.util.Locale; |
31 | 29 | import java.util.Map; |
32 | 30 | import java.util.regex.Matcher; |
@@ -91,20 +89,22 @@ public String subtype() throws IOException { |
91 | 89 |
|
92 | 90 | @Override |
93 | 91 | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") |
94 | | - public Map<String, List<String>> params() throws IOException { |
| 92 | + public Map<String, String> params() throws IOException { |
95 | 93 | final Matcher match = this.matcher(); |
96 | 94 | final Matcher param = MimeTypeOf.PTN_PARAM.matcher(this.src); |
97 | | - final Map<String, List<String>> map = new HashMap<>(1); |
| 95 | + final Map<String, String> map = new HashMap<>(1); |
98 | 96 | for (int id = match.end(); id < this.src.length(); id = param.end()) { |
99 | 97 | param.region(id, this.src.length()); |
100 | 98 | if (!param.lookingAt()) { |
101 | 99 | throw new IOException("Invalid mime-type params format"); |
102 | 100 | } |
103 | 101 | final String name = param.group(1); |
104 | | - if (!map.containsKey(name)) { |
105 | | - map.put(name, new LinkedList<String>()); |
| 102 | + if (map.containsKey(name)) { |
| 103 | + throw new IOException( |
| 104 | + String.format("Parameter %s may only exist once.", name) |
| 105 | + ); |
106 | 106 | } |
107 | | - map.get(name).add(MimeTypeOf.paramValue(param)); |
| 107 | + map.put(name, MimeTypeOf.paramValue(param)); |
108 | 108 | } |
109 | 109 | return map; |
110 | 110 | } |
|
0 commit comments