PrimitiveAssertion.java 1.75 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.wspolicy;

import com.adobe.xfa.Document;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.wspolicy.CompoundAssertion;
import com.adobe.xfa.wspolicy.Policy;

public class PrimitiveAssertion
extends Policy {
    PrimitiveAssertion(Document oDestDoc, Element oSrcNode) {
        super(oDestDoc, oSrcNode);
        this.setAssertionType(0);
        for (Node oChild = oSrcNode.getFirstXMLChild(); oChild != null; oChild = oChild.getNextXMLSibling()) {
            Element e;
            if (!(oChild instanceof Element) || !PrimitiveAssertion.isPolicyOrRef(e = (Element)oChild)) continue;
            Policy poChildPolicy = Policy.loadPolicy(oDestDoc, e);
            if (poChildPolicy == null) break;
            this.addPolicy(poChildPolicy);
            break;
        }
    }

    PrimitiveAssertion(Document oDestDoc, String aNameSpaceURI, String aLocalName) {
        super(oDestDoc, aNameSpaceURI, aLocalName);
        this.setAssertionType(0);
    }

    public boolean hasNestedPolicy() {
        return this.getFirstPolicyChild() != null;
    }

    public CompoundAssertion getNestedPolicy() {
        Policy policy = this.getFirstPolicyChild();
        if (policy != null) {
            assert (policy instanceof CompoundAssertion);
            return (CompoundAssertion)policy;
        }
        return null;
    }

    public CompoundAssertion addNestedPolicy() {
        if (!this.hasNestedPolicy()) {
            Document oDoc = this.getDomNode().getOwnerDocument();
            CompoundAssertion poPolicy = new CompoundAssertion(oDoc, "http://schemas.xmlsoap.org/ws/2004/09/policy", "Policy");
            this.addPolicy(poPolicy);
        }
        return this.getNestedPolicy();
    }
}