treeparent.java

来自「J2EE eclipse 下开发数据库一个插件」· Java 代码 · 共 66 行

JAVA
66
字号
/*
 * Created on 2003-4-10
 *
 */
package com.tanghan.plugin.dbviews.elements;

import java.util.ArrayList;

/** 树的父节点类型
 * @author Jerry Tang
 * @version v0.1.0
 * @copyright  (C) 2003 Tanghan工作组
 *  */
public class TreeParent extends TreeObject{
	private ArrayList children;

	/**构造函数
	 * @param name 节点名称
	 * @param obj 节点对应的对象实例
	 */
	public TreeParent(String name, Object obj, int type) {
		super(name, obj,type);
		children = new ArrayList();
	}
	
	/** 构造函数
	 * @param name 节点名称
	 */
	public TreeParent(String name, int type) {
		super(name,type);
		children = new ArrayList();
	}
	/**初始化*/
	private void init(){
		children = new ArrayList();
	}
	
	/**	添加字节点
	 * @param child 字节点
	 */
	public void addChild(TreeObject child) {
		children.add(child);
		child.setParent(this);
	}
	
	/**删除字节点
	 * @param child 字节点
	 */
	public void removeChild(TreeObject child) {
		children.remove(child);
		child.setParent(null);
	}
	/** 得到所有的节点列表
	 * @return 所有字节点的数组列表
	 */
	public TreeObject [] getChildren() {
		return (TreeObject [])children.toArray(new TreeObject[children.size()]);
	}
	/** 查询是否有字节点
	 * @return 是否有字节点
	 */
	public boolean hasChildren() {
		return children.size()>0;
	}
}

⌨️ 快捷键说明

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