ParameterMap.java
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.request.RequestParameter
* org.apache.sling.api.request.RequestParameterMap
*/
package com.adobe.forms.common.submitutils;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.request.RequestParameterMap;
public class ParameterMap
extends TreeMap<String, RequestParameter[]>
implements RequestParameterMap {
private Map<String, String[]> stringParameterMap;
public RequestParameter[] getValues(String name) {
return (RequestParameter[])this.get(name);
}
public RequestParameter getValue(String name) {
RequestParameter[] params = (RequestParameter[])this.get(name);
return params != null && params.length > 0 ? params[0] : null;
}
public String getStringValue(String name) {
RequestParameter param = this.getValue(name);
return param != null ? param.getString() : null;
}
public String[] getStringValues(String name) {
return ParameterMap.toStringArray(this.getValues(name));
}
public Map<String, String[]> getStringParameterMap() {
if (this.stringParameterMap == null) {
LinkedHashMap pm = new LinkedHashMap();
for (Map.Entry ppmEntry : this.entrySet()) {
pm.put(ppmEntry.getKey(), ParameterMap.toStringArray((RequestParameter[])ppmEntry.getValue()));
}
this.stringParameterMap = Collections.unmodifiableMap(pm);
}
return this.stringParameterMap;
}
private static String[] toStringArray(RequestParameter[] params) {
if (params == null) {
return null;
}
String[] ps = new String[params.length];
for (int i = 0; i < params.length; ++i) {
ps[i] = params[i].getString();
}
return ps;
}
}