GuideElement.java 3.77 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemds.guide.addon.dor.DoRThreadLocal
 *  com.adobe.aemds.guide.addon.dor.GuideType
 *  com.adobe.xfa.Element
 *  org.apache.sling.commons.json.JSONObject
 */
package com.adobe.aemds.guide.addon.dor.elements;

import com.adobe.aemds.guide.addon.dor.DoRThreadLocal;
import com.adobe.aemds.guide.addon.dor.GuideType;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElementProperties;
import com.adobe.aemds.guide.addon.dor.elements.GuideElementUtils;
import com.adobe.xfa.Element;
import java.util.Properties;
import org.apache.sling.commons.json.JSONObject;

public abstract class GuideElement {
    protected Properties properties = new Properties();
    protected String bindRef;

    public GuideElement(JSONObject jsonObject) {
        String property;
        for (String key2 : GuideElementProperties.COMMON_PROPERTIES) {
            if (!jsonObject.has(key2)) continue;
            this.properties.setProperty(key2, jsonObject.optString(key2));
        }
        for (String key2 : GuideElementProperties.PATTERN_PROPERTIES) {
            String value = jsonObject.optString(key2);
            if (value == null || value.isEmpty()) continue;
            this.properties.setProperty(key2, value);
        }
        if (this.properties.containsKey("displayIsSameAsValidate")) {
            this.properties.put("validatePictureClause", jsonObject.optString("displayPictureClause"));
        }
        if (this.properties.containsKey("isEditSameAsDisplayPattern")) {
            this.properties.put("editPictureClause", jsonObject.optString("displayPictureClause"));
        }
        if (this.properties.containsKey(property = "assistPriority") && this.properties.getProperty(property).equals("label")) {
            this.properties.setProperty(property, "caption");
        }
        if (this.properties.containsKey(property = "hideTitle") && this.properties.getProperty(property).equals("true")) {
            this.properties.remove("jcr:title");
        }
        if (this.properties.containsKey(property = "bindRef")) {
            String binding = this.properties.getProperty(property);
            this.bindRef = GuideElementUtils.adjustIndexes(binding);
            if (this.bindRef.startsWith("/")) {
                int index = DoRThreadLocal.getGuideType().equals((Object)GuideType.JSON_BASED) ? this.bindRef.indexOf(47, 0) : this.bindRef.indexOf(47, 1);
                if (index == -1) {
                    this.properties.setProperty("bindMatch", "none");
                    this.properties.remove("bindRef");
                    this.bindRef = null;
                } else {
                    String bind = "$record";
                    bind = DoRThreadLocal.getGuideType().equals((Object)GuideType.NON_XSD_NON_XDP_BASED) ? bind + this.bindRef : bind + this.bindRef.substring(index);
                    bind = bind.replace("/text()", "");
                    bind = bind.replaceAll("/", ".");
                    bind = bind.replaceAll("@", "");
                    this.properties.put(property, bind);
                    this.properties.setProperty("bindMatch", "dataRef");
                }
            }
        }
        if (this.properties.containsKey(property = "shortDescription")) {
            String shortDescription = this.properties.getProperty(property);
            String replacedString = shortDescription.replaceAll("<[^>]+>", "").replaceAll("&nbsp;", " ");
            this.properties.put(property, replacedString);
        }
    }

    public abstract DoRElement createDoRElement(Element var1) throws Exception;

    public Properties getProperties() {
        return this.properties;
    }

    public String getBindRef() {
        return this.bindRef;
    }
}