Items.java 1.85 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.template;

import com.adobe.xfa.Delta;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.XFA;
import com.adobe.xfa.XFAList;
import com.adobe.xfa.content.TextValue;
import org.xml.sax.Attributes;

public final class Items
extends ProtoableNode {
    public Items(Element parent, Node prevSibling) {
        super(parent, prevSibling, null, "items", "items", null, XFA.ITEMSTAG, "items");
    }

    public void addItem(String sItemValue, boolean bDefault) {
        TextValue bound = new TextValue(this, null);
        bound.setValue(sItemValue);
        if (!bDefault) {
            this.makeNonDefault(true);
        }
    }

    public void clearItems(boolean bDefault) {
        Node child = this.getFirstXFAChild();
        while (child != null) {
            Node next = child.getNextXFASibling();
            this.removeChild(child);
            child = next;
        }
        if (!bDefault) {
            this.makeNonDefault(true);
        }
    }

    public void removeItem(int nIndex, boolean bDefault) {
        Node child = this.getXFAChild(nIndex);
        if (child != null) {
            child.remove();
            if (!bDefault) {
                this.makeNonDefault(true);
            }
        }
    }

    @Override
    public void getDeltas(Element delta, XFAList list) {
        if (this.isSameClass(delta) && list != null) {
            Element parent = this.getXFAParent();
            Element deltaParent = delta.getXFAParent();
            Delta newDelta = new Delta(parent, deltaParent, this, delta, "");
            list.append(newDelta);
        }
    }

    @Override
    public void makeNonDefault(boolean bRecursive) {
        if (this.isDefault(false)) {
            this.fullyResolve(true);
        }
    }
}