⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treenode.java

📁 办公自动化项目
💻 JAVA
字号:

package hong.javanet.util.tree;
import java.io.*;
import java.util.*;

public class TreeNode implements Serializable {
    private Object key;
    private Object value;
    private Object parentKey;
    private Object other;

    private Collection dataInheritParent;
    private Collection dataIncludeChildren;
    private boolean stopToParent;
    private boolean stopToChildred;
    private Tree tree;

    TreeNode parent;

    List children = new ArrayList();

    boolean initInheritParentData;
    boolean initIncludeChildrenData;

    protected void init() {
        if(this.dataInheritParent==null) {
            this.dataInheritParent = new ArrayList();
        }
        if(this.dataIncludeChildren==null) {
            this.dataIncludeChildren = new ArrayList();
        }
    }
    protected void copyParentData() {
        ((ArrayList)this.dataInheritParent).addAll(0,this.parent.dataInheritParent);
    }

    void initInheritParentData() {
        if (this.parent != null) {
            if (!this.parent.initInheritParentData) {
                this.parent.initInheritParentData();
            }
            this.parent.initInheritParentData = true;
            if (!this.stopToParent) {
                this.copyParentData();
            }
        }
    }

    void initIncludeChildrenData() {
        Iterator iter = this.children.iterator();
        while (iter.hasNext()) {
            TreeNode child = (TreeNode) iter.next();
            if(!child.initIncludeChildrenData) {
                child.initIncludeChildrenData();
            }
            if(!this.stopToChildred) {
                this.dataIncludeChildren.addAll(child.dataIncludeChildren);
            }
        }
    }


    public Object getKey() {
        return key;
    }

    public boolean isStopToChildred() {
        return stopToChildred;
    }

    public boolean isStopToParent() {
        return stopToParent;
    }

    public Object getValue() {
        return value;
    }

    public Object getParentKey() {
        return parentKey;
    }

    public Tree getTree() {
        return tree;
    }

    public List getChildren() {
        return children;
    }

    public void setKey(Object key) {
        this.key = key;
    }

    public void setStopToChildred(boolean stopToChildred) {
        this.stopToChildred = stopToChildred;
    }

    public void setStopToParent(boolean stopToParent) {
        this.stopToParent = stopToParent;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public void setParentKey(Object parentKey) {
        this.parentKey = parentKey;
    }
    public TreeNode getParent() {
        return parent;
    }

    public Object getOther() {
        return other;
    }

    public Collection getDataInheritParent() {
        return dataInheritParent;
    }

    public Collection getDataIncludeChildren() {
        return dataIncludeChildren;
    }

    public void setTree(Tree tree) {
        this.tree = tree;
    }

    public void setOther(Object other) {
        this.other = other;
    }

    public void setDataInheritParent(Collection dataInheritParent) {
        this.dataInheritParent = dataInheritParent;
    }

    public void setDataIncludeChildren(Collection dataIncludeChildren) {
        this.dataIncludeChildren = dataIncludeChildren;
    }

    protected TreeNode cloneNode(Object newkey){
        TreeNode node = new TreeNode();
        node.key = newkey;
        node.parentKey = this.parentKey;
        node.tree = this.tree;
//        node.dataInheritParent = this.dataInheritParent;
//        node.dataIncludeChildren = this.dataIncludeChildren;
        node.setOther(this.getOther());
        node.stopToParent = this.stopToParent;
        node.stopToChildred = this.stopToChildred;
        node.value = this.value;
        return node;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -