?? mjtreetablenode.java
字號:
/*
* MJTreeTableNode.java
*
* Created on 2007年6月15日, 上午4:26
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.joy.mjtreetable;
import java.util.Vector;
/**
* MJTreeTableNode
* @author molinus
* @version 1.0.0
*/
public class MJTreeTableNode {
/**
* 節點名稱
*/
private String name="";
/**
* 節點屬性
*/
private Vector propers=new Vector();
/**
* 子節點的集合
*/
private Vector<MJTreeTableNode> childrens=new Vector<MJTreeTableNode>() ;
/**
* 默認構造器
*/
public MJTreeTableNode(){
}
/**
* 用節點名稱構造一個節點
*/
public MJTreeTableNode(String inttName){
this.name=inttName;
propers.add(name);
}
/**
* 用節點名稱和節點屬性的集合構造一個節點
*/
public MJTreeTableNode(String initName,Vector initPropers) {
this.name=initName;
propers.add(name);
this.propers.addAll(initPropers);;
}
/**
* 取得節點名稱
*/
public String getName(){
return this.name;
}
/**
* 設置節點名稱
*/
public void setName(String newName){
this.name=newName;
}
/**
* 取得節點的子節點集合
*/
public Vector getChildrens(){
return this.childrens;
}
/**
* 取得某個索引值的子節點
*/
public MJTreeTableNode getChildrenAt(int i){
if(i<childrens.size()){
return childrens.get(i);
}
return null;
}
/**
* 子節點集合的末尾增加一個子節點
*/
public void addChildren(MJTreeTableNode child){
this.childrens.add(child);
}
/**
* 在某個特定的位置加入一個子節點
*/
public void addChildrenAt(int i,MJTreeTableNode child){
this.childrens.add(i,child);
}
/**
* 刪除某個位置的子節點
*/
public void removeChildAt(int i){
this.childrens.remove(i);
}
/**
* 刪除某個子節點
*/
public void removeChild(MJTreeTableNode child){
if(childrens.contains(child)){
this.childrens.remove(child);
}
}
/**
* 刪除所有子節點
*/
public void removeAllChild(){
this.childrens.clear();
}
/**
* 設置節點的屬性
*/
public void setValues(Vector newPro){
this.propers=null;
this.propers.add(name);
this.propers.addAll(newPro);
}
/**
* 增加一個屬性
*/
public void addValue(Object value){
this.propers.add(value);
}
/**
* 在特定位置加入一個屬性,請注意集合中的第一個屬性為節點名稱
*/
public void addValueAt(int i,Object value){
this.propers.add(i,value);
}
/**
* 取得節點的屬性集合
*/
public Vector getValues(){
return this.propers;
}
/**
* 取得節點屬性集合中某個索引值的屬性,注意集合中的第一個屬性為節點名稱
*/
public Object getValueAt(int i){
if(propers!=null&&i<propers.size()){
return propers.get(i);
}
return null;
}
/**
* 判斷節點是否存在子節點
*/
public boolean hasChild(){
if(childrens.size()>0){
return true;
}
return false;
}
/**
* 輸出節點名稱
*/
public String toString(){
return this.name;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -