tree.java

来自「一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs」· Java 代码 · 共 70 行

JAVA
70
字号

/**
 *  Tree.java
 */

package com.gs.db.util.tree;

import java.util.Vector;

public class Tree implements TreeInterface {

    private Vector children;
    private int selected;
    private String name;

    public static int NODE = 0;
    public static int LEAF = 1;

    public Tree() {
        children = new Vector();
    }
    
    public Tree( String name ) {
        this.name = name;
        children = new Vector();
    }

    public String getName() {
        return this.name;
    }
    public void setName( String name ) {
        this.name = name;
    }

    public int getSelected() {
        return this.selected;
    }

    public void setSelected( int selected ) {
        this.selected = selected;
    }

    public void addChild (TreeObject child) {
        children.addElement(child);
    }

    public TreeObject getChild(int index) {
        return (TreeObject)children.elementAt(index);
    }

    public int size() {
        return children.size();
    }
    
    public TreeNode getNodeByData(int nodeData) {
        TreeObject to=null;
        for ( int i=0; i<children.size(); i++)
        {
            to =  (TreeObject)children.elementAt(i);
            if ( to.getType () == NODE)
            {
                if ( nodeData == to.getIntData()) return (TreeNode) to;
                TreeNode node1 = ((TreeNode)to).getSubNodeByData(nodeData);
                if ( node1 != null ) return node1;
            }
        }
        return null;
    }
}

⌨️ 快捷键说明

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