/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Object
 *  java.lang.String
 *  java.util.ArrayList
 *  java.util.Enumeration
 *  java.util.List
 *  javax.swing.tree.TreeNode
 */
package org.dom4j.swing;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.swing.tree.TreeNode;
import org.dom4j.Branch;
import org.dom4j.CharacterData;
import org.dom4j.Node;
import org.dom4j.swing.BranchTreeNode$1;
import org.dom4j.swing.LeafTreeNode;

public class BranchTreeNode
extends LeafTreeNode {
    protected List children;

    public BranchTreeNode() {
    }

    public BranchTreeNode(TreeNode treeNode, Branch branch) {
        super(treeNode, branch);
    }

    public BranchTreeNode(Branch branch) {
        super(branch);
    }

    @Override
    public Enumeration children() {
        return new BranchTreeNode$1(this);
    }

    /*
     * Enabled aggressive block sorting
     */
    protected List createChildList() {
        Branch branch = this.getXmlBranch();
        int n = branch.nodeCount();
        ArrayList arrayList = new ArrayList(n);
        int n2 = 0;
        while (n2 < n) {
            String string2;
            Node node = branch.node(n2);
            if (!(node instanceof CharacterData) || (string2 = node.getText()) != null && string2.trim().length() > 0) {
                arrayList.add((Object)this.createChildTreeNode(node));
            }
            ++n2;
        }
        return arrayList;
    }

    protected TreeNode createChildTreeNode(Node node) {
        if (node instanceof Branch) {
            return new BranchTreeNode((TreeNode)this, (Branch)node);
        }
        return new LeafTreeNode((TreeNode)this, node);
    }

    @Override
    public boolean getAllowsChildren() {
        return true;
    }

    @Override
    public TreeNode getChildAt(int n) {
        return (TreeNode)this.getChildList().get(n);
    }

    @Override
    public int getChildCount() {
        return this.getChildList().size();
    }

    protected List getChildList() {
        if (this.children == null) {
            this.children = this.createChildList();
        }
        return this.children;
    }

    @Override
    public int getIndex(TreeNode treeNode) {
        return this.getChildList().indexOf((Object)treeNode);
    }

    protected Branch getXmlBranch() {
        return (Branch)this.xmlNode;
    }

    @Override
    public boolean isLeaf() {
        if (this.getXmlBranch().nodeCount() <= 0) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return this.xmlNode.getName();
    }
}

