NodeListImpl.java 878 Bytes
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.dom;

import com.adobe.xfa.dom.NodeImpl;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

class NodeListImpl
implements NodeList {
    private final List<NodeImpl> mNodes;

    NodeListImpl(int initialCapacity) {
        this.mNodes = new ArrayList<NodeImpl>(initialCapacity);
    }

    @Override
    public int getLength() {
        return this.mNodes.size();
    }

    @Override
    public Node item(int index) {
        return 0 <= index && index < this.mNodes.size() ? this.mNodes.get(index) : null;
    }

    void addNode(NodeImpl node) {
        this.mNodes.add(node);
    }

    void addNodes(NodeImpl startNode) {
        while (startNode != null) {
            this.addNode(startNode);
            startNode = startNode.getNext();
        }
    }
}