AnnotationProcessor.java 3.04 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.aemds.guide.xsd;

import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public class AnnotationProcessor {
    private static final String appinfoSourceURL = "http://www.adobe.com/in/marketing-cloud/enterprise-content-management.html";
    private static final String appinfoNamespaceURL = "http://www.adobe.com/in/marketing-cloud/enterprise-content-management.html";
    private static AnnotationProcessor annotationProcessor = new AnnotationProcessor();

    public static AnnotationProcessor getInstance() {
        return annotationProcessor;
    }

    private AnnotationProcessor() {
    }

    public List<Node> getValidAppInfoNodes(Element annotation) {
        LinkedList<Node> validAppInfoNodeList = new LinkedList<Node>();
        if (annotation == null) {
            return validAppInfoNodeList;
        }
        String prefix = annotation.getPrefix();
        NodeList appInfoNodes = annotation.getElementsByTagName(prefix + ":" + "appinfo");
        int length = appInfoNodes.getLength();
        for (int i = 0; i < length; ++i) {
            Node appInfoNode = appInfoNodes.item(i);
            String namespacePrefix = appInfoNode.lookupPrefix("http://www.adobe.com/in/marketing-cloud/enterprise-content-management.html");
            Node source = appInfoNode.getAttributes().getNamedItem("source");
            if (!source.getNodeValue().equals("http://www.adobe.com/in/marketing-cloud/enterprise-content-management.html") || namespacePrefix == null || namespacePrefix.isEmpty()) continue;
            validAppInfoNodeList.add(appInfoNode);
        }
        return validAppInfoNodeList;
    }

    public Map<String, String> getProperties(Node appinfo) {
        Hashtable<String, String> propertiesTable = new Hashtable<String, String>();
        if (appinfo == null) {
            return propertiesTable;
        }
        String prefix = appinfo.lookupPrefix("http://www.adobe.com/in/marketing-cloud/enterprise-content-management.html");
        Node form = ((Element)appinfo).getElementsByTagName(prefix + ":" + "form").item(0);
        if (form == null) {
            return propertiesTable;
        }
        NodeList properties = form.getChildNodes();
        int length = properties.getLength();
        for (int i = 0; i < length; ++i) {
            Node nameNode;
            Node property = properties.item(i);
            if (!property.getNodeName().equals(prefix + ":" + "afProperty") || (nameNode = property.getAttributes().getNamedItem("name")) == null) continue;
            String value = property.getTextContent();
            String name = nameNode.getNodeValue();
            if (name == null || value == null || name.isEmpty() || value.isEmpty()) continue;
            propertiesTable.put(name, value);
        }
        return propertiesTable;
    }
}