?? systeminfo.java
字號(hào):
package org.zblog.zenghelper.dbtool;
import java.io.DataInputStream;
import java.io.ByteArrayInputStream;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
/**
* <br><strong>Z英語(yǔ)學(xué)習(xí)助手-生詞卡片顯示屬性類</strong><br>
* <br>該類的包裝了生詞卡片的顯示屬性,包括:第一次顯示內(nèi)容,是否隨機(jī)排序兩個(gè)主要屬性.
* 該類是一個(gè)類似于EnWord的類,它的一個(gè)對(duì)象就對(duì)應(yīng)了RMS中的一條記錄,并且本身封裝了與
* RMS中數(shù)據(jù)保持一致的方法,dbInit()和store().
*
* @author <a href="mailto:zcw@zblog.org">朱傳偉</a><br>
* <a href="http://www.zblog.org">www.zblog.org</a></p>
* @version <strong>ZEnHelper</strong> Ver 1.0
*/
public class SystemInfo {
private DbTool dt=DbTool.getInstance();
/**
* 是否顯示英文單詞
*/
public boolean isEnShow=true;
/**
* 是否顯示中文解釋
*/
public boolean isCnShow=true;
public boolean isYbShow=true;
public boolean isRandom=true;
/**
* 該類在構(gòu)造對(duì)象時(shí),就會(huì)從RMS中取出數(shù)據(jù)來(lái)初始化該對(duì)象
*/
public SystemInfo(){
dbInit();
}
/**
* 從數(shù)據(jù)庫(kù)中獲取數(shù)據(jù)來(lái)初始化SystemInfo對(duì)象
*/
public void dbInit(){
try{
RecordStore rs=dt.openRS(DbTool.SYSTEM_DB);
RecordEnumeration re=rs.enumerateRecords(null,null,false);
if(re.hasNextElement()){
byte[]bs=re.nextRecord();
ByteArrayInputStream bis = new ByteArrayInputStream(bs);
DataInputStream dis = new DataInputStream(bis);
isEnShow=dis.readBoolean();
isCnShow=dis.readBoolean();
isRandom=dis.readBoolean();
dis.close();
bis.close();
}
rs.closeRecordStore();
}
catch(Exception e){
e.printStackTrace();
}
}
/**
* 將當(dāng)前SystemInfo對(duì)象的狀態(tài)持久化到RMS中
*/
public void store(){
try{
ByteArrayOutputStream bos=new ByteArrayOutputStream();
DataOutputStream dos=new DataOutputStream(bos);
dos.writeBoolean(isEnShow);
dos.writeBoolean(isCnShow);
dos.writeBoolean(isRandom);
byte[]bytes=bos.toByteArray();
dos.close();
bos.close();
RecordStore rs=dt.openRS(DbTool.SYSTEM_DB);
RecordEnumeration re=rs.enumerateRecords(null,null,false);
if(re.hasNextElement()){
int id=re.nextRecordId();
rs.setRecord(id,bytes,0,bytes.length);
}
else{
rs.addRecord(bytes,0,bytes.length);
}
rs.closeRecordStore();
}
catch(Exception e){
e.printStackTrace();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -