GuideDropDownElement.java
2.34 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
64
65
66
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.xfa.Element
* org.apache.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.elements.DoRDropDownElement;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElement;
import com.adobe.xfa.Element;
import java.util.Hashtable;
import java.util.Properties;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuideDropDownElement
extends GuideElement {
private Logger logger = LoggerFactory.getLogger(GuideDropDownElement.class);
public GuideDropDownElement(JSONObject jsonObject) {
super(jsonObject);
try {
JSONArray options;
String key = "multiSelect";
String value = jsonObject.optString(key);
if (value != null) {
this.properties.setProperty(key, value);
}
if ((value = jsonObject.optString(key = "displayValue")) != null && !value.isEmpty()) {
this.properties.setProperty(key, value);
}
if ((options = jsonObject.optJSONArray(key = "options")) != null) {
Hashtable<String, String> map = new Hashtable<String, String>();
for (int i = 0; i < options.length(); ++i) {
String option = options.getString(i);
if (option.contains("=")) {
int index = option.indexOf(61);
map.put(option.substring(0, index), option.substring(index + 1));
continue;
}
map.put(option, option);
}
this.properties.put(key, map);
}
}
catch (JSONException e) {
this.logger.error("Failed to construct", (Throwable)e);
}
}
@Override
public DoRElement createDoRElement(Element xfaElement) throws Exception {
return new DoRDropDownElement(xfaElement);
}
}