📄 channellist.java
字号:
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
/**
*
*
* @author Chen Xin Wu
*/
public class ChannelList
{
static int channelNum=0;
static Channel[] channelList;
ChannelList(){
channelNum=0;
makeChannel();
}
public static Channel[] makeChannel(){
channelList=new Channel[100];
// 初始化频道
DBOperater DB = new DBOperater("Channel");
String queryString;
try
{
queryString = "select * from channel";
ResultSet rs = DB.executeQuery(queryString);
Channel temp;
String name,id,type,module;
if(rs==null){
DB.close();
return null;
}
while(rs.next())
{
name = CommonMethods.getFieldValue (rs,"channelname");
id = CommonMethods.getFieldValue (rs,"channelid");
type = CommonMethods.getFieldValue (rs,"type");
module = CommonMethods.getFieldValue (rs,"modulename");
if( module ==null )
continue;
try{
temp = (Channel)(Class.forName(module).newInstance());
}catch(Exception e)
{
temp=null;
continue;
}
temp.setChannelName(name);
temp.setChannelID(id);
temp.setChannelType(type);
temp.setChannelModule(module);
channelList[channelNum] = temp;
channelNum++;
}
} catch(Exception ex) {
System.err.println("ReplaceEngine SQLException: " + ex.getMessage());
}
DB.close();
return channelList;
}
public static Channel searchChannel(String name)
{
int i;
if(name == null)
return null;
name = name.trim ();
for(i=0;i<channelNum;i++)
{
if(channelList[i].getChannelID().compareTo (name)==0)
return channelList[i];
}
return null;
}
public static int getChannelNum() { return channelNum; }
public static Channel getChannelAt(int i) { return channelList[i]; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -