GuideRadioButtonElement.java 2.09 KB
/*
 * 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.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.DoRRadioButtonElement;
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 GuideRadioButtonElement
extends GuideElement {
    private Logger logger = LoggerFactory.getLogger(GuideRadioButtonElement.class);

    public GuideRadioButtonElement(JSONObject jsonObject) {
        super(jsonObject);
        try {
            String key = "options";
            JSONArray options = jsonObject.getJSONArray(key);
            if (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);
            }
            this.properties.put("name", jsonObject.getString("name"));
        }
        catch (JSONException e) {
            this.logger.error("Failed to construct", (Throwable)e);
        }
    }

    @Override
    public DoRElement createDoRElement(Element xfaElement) throws Exception {
        return new DoRRadioButtonElement(xfaElement);
    }
}