packageorg.ccnt.med.body;importjava.util.ArrayList;importjava.util.List;public classNode {//叶子节点
public final static String TYPE_LEAF = "leaf";//有子节点的节点
public final static String TYPE_NODE = "node";//节点键值
privateString org_code;//节点名称
privateString org_name;//节点状态
privateString status;//节点类型
privateString org_type;//父节点值
privateString parent_code;//子节点数组
privateNode[] childNodes;/*** 转换列表为数组
*
*@paramNodeList
*@return
*/
public static Node[] listToArray(ListNodeList) {
Node[] nodes= null;if (NodeList != null) {
nodes= newNode[NodeList.size()];for (int i = 0; i < NodeList.size(); i++) {
nodes[i]=(Node) NodeList.get(i);
}
}returnnodes;
}/*** 判断是否是有子节点的节点
*
*@return
*/
public booleanisNode() {if (this.getChildNodes() != null && this.getChildNodes().length > 0) {return true;
}else{return false;
}
}/*** 判断是否是叶子节点
*
*@return
*/
public booleanisLeaf() {return !isNode();
}/*** 根据列表设置当前节点的子节点*/
public voidfilterChildNodes(Node[] nodes) {
List list = new ArrayList();
Node tempNode= newNode();for (int i = 0; i < nodes.length; i++) {
tempNode=nodes[i];if ("root".equals(tempNode.getParent_code())&& this.getOrg_code() == null) {
list.add(tempNode);
}else{if (!"root".equals(tempNode.getParent_code())&& this.getOrg_code() != null) {if (tempNode.getParent_code().equals(this.getOrg_code())) {
list.add(tempNode);
}
}
}
}this.setChildNodes(listToArray(list));
}publicString getOrg_code() {returnorg_code;
}public voidsetOrg_code(String org_code) {this.org_code =org_code;
}publicString getOrg_name() {returnorg_name;
}public voidsetOrg_name(String org_name) {this.org_name =org_name;
}publicString getStatus() {returnstatus;
}public voidsetStatus(String status) {this.status =status;
}publicString getOrg_type() {returnorg_type;
}public voidsetOrg_type(String org_type) {this.org_type =org_type;
}publicString getParent_code() {returnparent_code;
}public voidsetParent_code(String parent_code) {this.parent_code =parent_code;
}publicNode[] getChildNodes() {returnchildNodes;
}public voidsetChildNodes(Node[] childNodes) {this.childNodes =childNodes;
}public staticString getTYPE_LEAF() {returnTYPE_LEAF;
}public staticString getTYPE_NODE() {returnTYPE_NODE;
}
}