package
DataBasePackage;
import javax.microedition.rms.RecordComparator;
import PublicPackage. * ;
public class BallComparator implements RecordComparator ... {
private boolean SetB = false;
public BallComparator(boolean B)
...{
SetB = B;
}
public int compare(byte[] arg0, byte[] arg1) ...{
try ...{
DrawBallType D = DrawBallType.ByteToClass(arg0);
DrawBallType S = DrawBallType.ByteToClass(arg1);
Integer DD = Integer.valueOf(D.Str);
Integer SS = Integer.valueOf(S.Str);
if (SetB)...{
if (DD.intValue() > SS.intValue())
return RecordComparator.FOLLOWS;
if (DD.intValue() < SS.intValue())
return RecordComparator.PRECEDES;
}else
...{
if (DD.intValue() > SS.intValue())
return RecordComparator.PRECEDES;
if (DD.intValue() < SS.intValue())
return RecordComparator.FOLLOWS;
}
return RecordComparator.EQUIVALENT;
} catch (Exception e) ...{
e.printStackTrace();
}
return 0;
}
}
import javax.microedition.rms.RecordComparator;
import PublicPackage. * ;
public class BallComparator implements RecordComparator ... {
private boolean SetB = false;
public BallComparator(boolean B)
...{
SetB = B;
}
public int compare(byte[] arg0, byte[] arg1) ...{
try ...{
DrawBallType D = DrawBallType.ByteToClass(arg0);
DrawBallType S = DrawBallType.ByteToClass(arg1);
Integer DD = Integer.valueOf(D.Str);
Integer SS = Integer.valueOf(S.Str);
if (SetB)...{
if (DD.intValue() > SS.intValue())
return RecordComparator.FOLLOWS;
if (DD.intValue() < SS.intValue())
return RecordComparator.PRECEDES;
}else
...{
if (DD.intValue() > SS.intValue())
return RecordComparator.PRECEDES;
if (DD.intValue() < SS.intValue())
return RecordComparator.FOLLOWS;
}
return RecordComparator.EQUIVALENT;
} catch (Exception e) ...{
e.printStackTrace();
}
return 0;
}
}
package
DataBasePackage;
import javax.microedition.rms.RecordFilter;
import PublicPackage. * ;
public class BallFilter implements RecordFilter ... {
private String PStr;
public BallFilter(String FilterStr)
...{
PStr = FilterStr;
}
public boolean matches(byte[] arg0) ...{
try ...{
DrawBallType TempBallType = DrawBallType.ByteToClass(arg0);
if (TempBallType.Str.equals(PStr)) return false;
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
}
import javax.microedition.rms.RecordFilter;
import PublicPackage. * ;
public class BallFilter implements RecordFilter ... {
private String PStr;
public BallFilter(String FilterStr)
...{
PStr = FilterStr;
}
public boolean matches(byte[] arg0) ...{
try ...{
DrawBallType TempBallType = DrawBallType.ByteToClass(arg0);
if (TempBallType.Str.equals(PStr)) return false;
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
}
package
DataBasePackage;
import java.io. * ;
import PublicPackage.BusType;
public class BusDataRecord ... {
private InputStreamReader reader;
private String fileName = "/res/respath.txt";
private int LineID = 0;
private int MaxBusC = 146, MaxL = 12;
public BusDataRecord() ...{
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
}
public String ReadLine(int LineID) ...{
String Str = "";
int TempLineID = 0;
try ...{
char[] buffer = new char[2048];
int len = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13) && ((byte) (reader.read()) == 10)) ...{
if (TempLineID >= LineID) ...{
break;
} else ...{
len = 0;
buffer = new char[2048];
TempLineID++;
}
}
}
Str = String.valueOf(buffer);
} catch (Exception e) ...{
e.printStackTrace();
}
return Str;
}
public BusType Getrecord(int ID) ...{
String Str = "";
BusType BT = new BusType();
if ((ID > 145) || (ID < 0))
return BT;
Str = ReadLine(ID * MaxL);
char[] Tempc = new char[3];
Str.getChars(0, 3, Tempc, 0);
Integer TempI = Integer.valueOf(String.valueOf(Tempc).trim());
if ((TempI.intValue() >= ID) && (Str.trim() != "")) ...{
BT.ID = ID;
System.out.println(Str.trim().length());
char[] Tempcc = new char[Str.length() - 4];
Str.getChars(4, Str.length() - 1, Tempcc, 0);
BT.BusCode = String.valueOf(Tempcc).trim();
System.out.println(BT.BusCode);
BT.BusCompany = ReadLine(ID * MaxL + 1);// 所属公司
BT.BusTJRoad = ReadLine(ID * MaxL + 2);// 途径
BT.BusSite = ReadLine(ID * MaxL + 3);// 停靠站点
BT.BusBeginT = ReadLine(ID * MaxL + 4);// 起点站首末班时间
BT.BusEndT = ReadLine(ID * MaxL + 5);// 终点站首末班时间
BT.BusHightT = ReadLine(ID * MaxL + 6);// 高峰行车间隔
BT.BusLowT = ReadLine(ID * MaxL + 7);// 平峰行车间隔
BT.BusRoadLength = ReadLine(ID * MaxL + 8);// 线路里程
BT.BusMonth = ReadLine(ID * MaxL + 9);// 月票情况
BT.BusPrice = ReadLine(ID * MaxL + 10);// 票价
}
return BT;
}
public String[][] SearchBusPathArrary(String SiteName,boolean Site) ...{
int TempLineID = 0, BID = 999 ,LastBID = 999;
String[][] TempBid = new String[2][MaxBusC];
String LastBIDD = "";
if (SiteName.trim().equals("")) return TempBid;
try ...{
char[] buffer = new char[2048];
int len = 0,iid = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13) && ((byte) (reader.read()) == 10)) ...{
String TempID = String.valueOf(buffer).trim();
if (TempLineID % MaxL == 0) ...{//记录ID
char[] TempcharID = new char[3];
TempID.getChars(0, 3, TempcharID, 0);
char[] Tempccode = new char[TempID.length() - 4];
TempID.getChars(4, TempID.length(), Tempccode,
0);
LastBIDD = String.valueOf(Tempccode).trim();
//System.out.println(LastBIDD);
try ...{
BID = Integer.valueOf(
String.valueOf(TempcharID).trim())
.intValue();
} catch (Exception e) ...{
}
}else...{//搜索 SiteName
String TempStr = String.valueOf(buffer).trim();
if (Site)...{
if ((TempStr.indexOf("停靠站点:") != -1)&&
(TempStr.indexOf(SiteName.trim()) != -1))...{
if (LastBID != BID) ...{
TempBid[0][iid] =String.valueOf(BID);
TempBid[1][iid] = LastBIDD;
LastBID = BID;
iid ++;
}
}
}else...{//
if ((TempStr.indexOf("途径:") != -1)&&
(TempStr.indexOf(SiteName.trim()) != -1))...{
if (LastBID != BID) ...{
TempBid[0][iid] =String.valueOf(BID);
TempBid[1][iid] =LastBIDD;
LastBID = BID;
iid ++;
}
}
}
}
len = 0;
buffer = new char[2048];
TempLineID++;
}
}
} catch (Exception e) ...{
e.printStackTrace();
}
return TempBid;
}
public BusType Getrecord(String BusCode, boolean Serch) ...{
BusType TempB = new BusType();
if (Serch) ...{//文件搜索
String Str = BusCode.trim();
//int TempLineID = 0;
try ...{
char[] buffer = new char[2048];
int len = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass()
.getResourceAsStream(fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13)
&& ((byte) (reader.read()) == 10)) ...{
String TempID = String.valueOf(buffer).trim();
//System.out.println( "Length "+TempID.length() + " " + TempID);
if ((TempID.length() > 3)&& (TempID.length() < 10)) ...{
char[] TempcharID = new char[3];
TempID.getChars(0, 3, TempcharID, 0);
char[] Tempccode = new char[TempID.length() - 4];
TempID.getChars(4, TempID.length(), Tempccode,
0);
//System.out.println(String.valueOf(Tempccode).trim());
try ...{
int ID = Integer.valueOf(
String.valueOf(TempcharID).trim()).intValue();
if (! String.valueOf(Tempccode).trim().equals(BusCode
.trim()))...{
len = 0;
buffer = new char[2048];
continue;
}
//
TempB.ID = ID;
TempB.BusCode = String.valueOf(Tempccode).trim();
for (int k = 0; k < 10 ; k ++)...{
len = 0;
buffer = new char[2048];
while ((Tempc = reader.read()) != -1)...{
if (((byte) (Tempc) == 13)
&& ((byte) (reader.read()) == 10)) ...{
break;
} else buffer[len++] = (char) (Tempc);
}
String TempBusCut = String.valueOf(buffer).trim();
switch (k) ...{
case 0:
TempB.BusCompany = TempBusCut;
break;// 所属公司
case 1:
TempB.BusTJRoad = TempBusCut;
break;// 途径
case 2:
TempB.BusSite = TempBusCut;
break;// 停靠站点
case 3:
TempB.BusBeginT = TempBusCut;
break;// 起点站首末班时间
case 4:
TempB.BusEndT = TempBusCut;
break;// 终点站首末班时间
case 5:
TempB.BusHightT = TempBusCut;
break;// 高峰行车间隔
case 6:
TempB.BusLowT = TempBusCut;
break;// 平峰行车间隔
case 7:
TempB.BusRoadLength = TempBusCut;
break;//线路里程
case 8:
TempB.BusMonth = TempBusCut;
break;//月票情况
case 9:
TempB.BusPrice = TempBusCut;
break;//票价
default:
break;
}
}
//TempB = Getrecord(ID-1);
//
//System.out.println("ID"+ID);
return TempB;
} catch (Exception e) ...{
len = 0;
buffer = new char[2048];
continue;
}
} else ...{
len = 0;
buffer = new char[2048];
//TempLineID++;
}
}
}
Str = String.valueOf(buffer);
} catch (Exception e) ...{
e.printStackTrace();
}
} else ...{// 折半查找
int BeginID = 0, EndID = MaxBusC - 1;
int midID = (BeginID + EndID) / 2;
while (BeginID <= EndID) ...{
System.out.println(TempB.ID + " " + midID + " "
+ TempB.BusCode);
midID = (BeginID + EndID) / 2;
TempB = Getrecord(midID + 1);
if (BusCode.compareTo(TempB.BusCode.trim()) > 0) ...{
BeginID = midID - 1;
} else if (BusCode.compareTo(TempB.BusCode.trim()) < 0) ...{
EndID = midID + 1;
} else ...{
return TempB;
}
}
}
return TempB;
}
}
import java.io. * ;
import PublicPackage.BusType;
public class BusDataRecord ... {
private InputStreamReader reader;
private String fileName = "/res/respath.txt";
private int LineID = 0;
private int MaxBusC = 146, MaxL = 12;
public BusDataRecord() ...{
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
}
public String ReadLine(int LineID) ...{
String Str = "";
int TempLineID = 0;
try ...{
char[] buffer = new char[2048];
int len = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13) && ((byte) (reader.read()) == 10)) ...{
if (TempLineID >= LineID) ...{
break;
} else ...{
len = 0;
buffer = new char[2048];
TempLineID++;
}
}
}
Str = String.valueOf(buffer);
} catch (Exception e) ...{
e.printStackTrace();
}
return Str;
}
public BusType Getrecord(int ID) ...{
String Str = "";
BusType BT = new BusType();
if ((ID > 145) || (ID < 0))
return BT;
Str = ReadLine(ID * MaxL);
char[] Tempc = new char[3];
Str.getChars(0, 3, Tempc, 0);
Integer TempI = Integer.valueOf(String.valueOf(Tempc).trim());
if ((TempI.intValue() >= ID) && (Str.trim() != "")) ...{
BT.ID = ID;
System.out.println(Str.trim().length());
char[] Tempcc = new char[Str.length() - 4];
Str.getChars(4, Str.length() - 1, Tempcc, 0);
BT.BusCode = String.valueOf(Tempcc).trim();
System.out.println(BT.BusCode);
BT.BusCompany = ReadLine(ID * MaxL + 1);// 所属公司
BT.BusTJRoad = ReadLine(ID * MaxL + 2);// 途径
BT.BusSite = ReadLine(ID * MaxL + 3);// 停靠站点
BT.BusBeginT = ReadLine(ID * MaxL + 4);// 起点站首末班时间
BT.BusEndT = ReadLine(ID * MaxL + 5);// 终点站首末班时间
BT.BusHightT = ReadLine(ID * MaxL + 6);// 高峰行车间隔
BT.BusLowT = ReadLine(ID * MaxL + 7);// 平峰行车间隔
BT.BusRoadLength = ReadLine(ID * MaxL + 8);// 线路里程
BT.BusMonth = ReadLine(ID * MaxL + 9);// 月票情况
BT.BusPrice = ReadLine(ID * MaxL + 10);// 票价
}
return BT;
}
public String[][] SearchBusPathArrary(String SiteName,boolean Site) ...{
int TempLineID = 0, BID = 999 ,LastBID = 999;
String[][] TempBid = new String[2][MaxBusC];
String LastBIDD = "";
if (SiteName.trim().equals("")) return TempBid;
try ...{
char[] buffer = new char[2048];
int len = 0,iid = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass().getResourceAsStream(
fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13) && ((byte) (reader.read()) == 10)) ...{
String TempID = String.valueOf(buffer).trim();
if (TempLineID % MaxL == 0) ...{//记录ID
char[] TempcharID = new char[3];
TempID.getChars(0, 3, TempcharID, 0);
char[] Tempccode = new char[TempID.length() - 4];
TempID.getChars(4, TempID.length(), Tempccode,
0);
LastBIDD = String.valueOf(Tempccode).trim();
//System.out.println(LastBIDD);
try ...{
BID = Integer.valueOf(
String.valueOf(TempcharID).trim())
.intValue();
} catch (Exception e) ...{
}
}else...{//搜索 SiteName
String TempStr = String.valueOf(buffer).trim();
if (Site)...{
if ((TempStr.indexOf("停靠站点:") != -1)&&
(TempStr.indexOf(SiteName.trim()) != -1))...{
if (LastBID != BID) ...{
TempBid[0][iid] =String.valueOf(BID);
TempBid[1][iid] = LastBIDD;
LastBID = BID;
iid ++;
}
}
}else...{//
if ((TempStr.indexOf("途径:") != -1)&&
(TempStr.indexOf(SiteName.trim()) != -1))...{
if (LastBID != BID) ...{
TempBid[0][iid] =String.valueOf(BID);
TempBid[1][iid] =LastBIDD;
LastBID = BID;
iid ++;
}
}
}
}
len = 0;
buffer = new char[2048];
TempLineID++;
}
}
} catch (Exception e) ...{
e.printStackTrace();
}
return TempBid;
}
public BusType Getrecord(String BusCode, boolean Serch) ...{
BusType TempB = new BusType();
if (Serch) ...{//文件搜索
String Str = BusCode.trim();
//int TempLineID = 0;
try ...{
char[] buffer = new char[2048];
int len = 0;
int Tempc;
try ...{
reader = new InputStreamReader(getClass()
.getResourceAsStream(fileName), "UTF-8");
} catch (Exception e) ...{
}
reader.ready();
while ((Tempc = reader.read()) != -1) ...{
buffer[len++] = (char) (Tempc);
if (((byte) (Tempc) == 13)
&& ((byte) (reader.read()) == 10)) ...{
String TempID = String.valueOf(buffer).trim();
//System.out.println( "Length "+TempID.length() + " " + TempID);
if ((TempID.length() > 3)&& (TempID.length() < 10)) ...{
char[] TempcharID = new char[3];
TempID.getChars(0, 3, TempcharID, 0);
char[] Tempccode = new char[TempID.length() - 4];
TempID.getChars(4, TempID.length(), Tempccode,
0);
//System.out.println(String.valueOf(Tempccode).trim());
try ...{
int ID = Integer.valueOf(
String.valueOf(TempcharID).trim()).intValue();
if (! String.valueOf(Tempccode).trim().equals(BusCode
.trim()))...{
len = 0;
buffer = new char[2048];
continue;
}
//
TempB.ID = ID;
TempB.BusCode = String.valueOf(Tempccode).trim();
for (int k = 0; k < 10 ; k ++)...{
len = 0;
buffer = new char[2048];
while ((Tempc = reader.read()) != -1)...{
if (((byte) (Tempc) == 13)
&& ((byte) (reader.read()) == 10)) ...{
break;
} else buffer[len++] = (char) (Tempc);
}
String TempBusCut = String.valueOf(buffer).trim();
switch (k) ...{
case 0:
TempB.BusCompany = TempBusCut;
break;// 所属公司
case 1:
TempB.BusTJRoad = TempBusCut;
break;// 途径
case 2:
TempB.BusSite = TempBusCut;
break;// 停靠站点
case 3:
TempB.BusBeginT = TempBusCut;
break;// 起点站首末班时间
case 4:
TempB.BusEndT = TempBusCut;
break;// 终点站首末班时间
case 5:
TempB.BusHightT = TempBusCut;
break;// 高峰行车间隔
case 6:
TempB.BusLowT = TempBusCut;
break;// 平峰行车间隔
case 7:
TempB.BusRoadLength = TempBusCut;
break;//线路里程
case 8:
TempB.BusMonth = TempBusCut;
break;//月票情况
case 9:
TempB.BusPrice = TempBusCut;
break;//票价
default:
break;
}
}
//TempB = Getrecord(ID-1);
//
//System.out.println("ID"+ID);
return TempB;
} catch (Exception e) ...{
len = 0;
buffer = new char[2048];
continue;
}
} else ...{
len = 0;
buffer = new char[2048];
//TempLineID++;
}
}
}
Str = String.valueOf(buffer);
} catch (Exception e) ...{
e.printStackTrace();
}
} else ...{// 折半查找
int BeginID = 0, EndID = MaxBusC - 1;
int midID = (BeginID + EndID) / 2;
while (BeginID <= EndID) ...{
System.out.println(TempB.ID + " " + midID + " "
+ TempB.BusCode);
midID = (BeginID + EndID) / 2;
TempB = Getrecord(midID + 1);
if (BusCode.compareTo(TempB.BusCode.trim()) > 0) ...{
BeginID = midID - 1;
} else if (BusCode.compareTo(TempB.BusCode.trim()) < 0) ...{
EndID = midID + 1;
} else ...{
return TempB;
}
}
}
return TempB;
}
}
package
DataBasePackage;
import javax.microedition.rms. * ;
import PublicPackage. * ;
public class RecordStoreE ... {
private String DataBaseName = "DoubleBallDB";
private RecordStore RS;
public boolean OpenDatabase() ...{
try ...{
RS = RecordStore.openRecordStore(DataBaseName, true);
//
String TempN = "99999";
boolean haveN = false;
DrawBallType[] T = GetAllRecord(true);
for (int i = 0; i < T.length; i++) ...{
if (T[T.length - 1 - i].Str.equals(TempN)) ...{
haveN = true;
break;
}
}
if (haveN == false) ...{
DrawBallType TempD = new DrawBallType();
TempD.Str = TempN;
AddRecordN(TempD);
}
//
} catch (Exception e) ...{
System.out.println(e.toString());
return false;
}
return true;
}
public boolean CloseDatabase() ...{
if (RS != null) ...{
try ...{
RS.closeRecordStore();
} catch (Exception e) ...{
System.out.println(e.toString());
}
}
return false;
}
public boolean DeleteDatabase()
...{
try ...{
CloseDatabase();
RecordStore.deleteRecordStore(DataBaseName);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public boolean AddRecord(DrawBallType record) ...{
try ...{
String TempN = "99999";
boolean TempB = record.Str.equals(TempN);
if (TempB)
return false;
DrawBallType[] T = GetAllRecord(true);
for (int i = 0; i < T.length; i++)
if (T[i].Str.equals(record.Str))
return false;
byte[] TempByte = DrawBallType.ClassToByte(record);
RS.addRecord(TempByte, 0, TempByte.length);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
private boolean AddRecordN(DrawBallType record) ...{
try ...{
byte[] TempByte = DrawBallType.ClassToByte(record);
RS.addRecord(TempByte, 0, TempByte.length);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public boolean DeleteRecord(DrawBallType record) ...{
try ...{
DrawBallType DrawBalls = new DrawBallType();
RecordEnumeration re = null;
try ...{
if (RS == null)
return false;
re = RS.enumerateRecords(null,new BallComparator(true), false);
int Drecords = 0;
while (re.hasNextElement()) ...{
byte[] temp = re.nextRecord();
DrawBalls = new DrawBallType();
DrawBalls = DrawBallType.ByteToClass(temp);
Drecords++;
re.nextRecordId();
int ID = re.previousRecordId();
if (DrawBalls.Str.equals(record.Str)) ...{
RS.deleteRecord(ID);
System.out.println("ID:"+ID);
}
}
} catch (Exception e) ...{
e.printStackTrace();
} finally ...{
if (re != null)
re.destroy();
}
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public DrawBallType[] GetAllRecord(boolean RecordE) ...{
DrawBallType[] DrawBalls = new DrawBallType[0];
RecordEnumeration re = null;
try ...{
if (RS == null)
return DrawBalls;
if (RecordE)
re = RS.enumerateRecords(null, new BallComparator(false), true);
else
re = RS.enumerateRecords(new BallFilter("99999"),
new BallComparator(false), false);
DrawBalls = new DrawBallType[re.numRecords()];
int Drecords = 0;
while (re.hasNextElement()) ...{
byte[] temp = re.nextRecord();
DrawBalls[Drecords] = new DrawBallType();
DrawBalls[Drecords] = DrawBallType.ByteToClass(temp);
Drecords++;
}
} catch (Exception e) ...{
e.printStackTrace();
return null;
} finally ...{
if (re != null)
re.destroy();
}
return DrawBalls;
}
}
import javax.microedition.rms. * ;
import PublicPackage. * ;
public class RecordStoreE ... {
private String DataBaseName = "DoubleBallDB";
private RecordStore RS;
public boolean OpenDatabase() ...{
try ...{
RS = RecordStore.openRecordStore(DataBaseName, true);
//
String TempN = "99999";
boolean haveN = false;
DrawBallType[] T = GetAllRecord(true);
for (int i = 0; i < T.length; i++) ...{
if (T[T.length - 1 - i].Str.equals(TempN)) ...{
haveN = true;
break;
}
}
if (haveN == false) ...{
DrawBallType TempD = new DrawBallType();
TempD.Str = TempN;
AddRecordN(TempD);
}
//
} catch (Exception e) ...{
System.out.println(e.toString());
return false;
}
return true;
}
public boolean CloseDatabase() ...{
if (RS != null) ...{
try ...{
RS.closeRecordStore();
} catch (Exception e) ...{
System.out.println(e.toString());
}
}
return false;
}
public boolean DeleteDatabase()
...{
try ...{
CloseDatabase();
RecordStore.deleteRecordStore(DataBaseName);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public boolean AddRecord(DrawBallType record) ...{
try ...{
String TempN = "99999";
boolean TempB = record.Str.equals(TempN);
if (TempB)
return false;
DrawBallType[] T = GetAllRecord(true);
for (int i = 0; i < T.length; i++)
if (T[i].Str.equals(record.Str))
return false;
byte[] TempByte = DrawBallType.ClassToByte(record);
RS.addRecord(TempByte, 0, TempByte.length);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
private boolean AddRecordN(DrawBallType record) ...{
try ...{
byte[] TempByte = DrawBallType.ClassToByte(record);
RS.addRecord(TempByte, 0, TempByte.length);
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public boolean DeleteRecord(DrawBallType record) ...{
try ...{
DrawBallType DrawBalls = new DrawBallType();
RecordEnumeration re = null;
try ...{
if (RS == null)
return false;
re = RS.enumerateRecords(null,new BallComparator(true), false);
int Drecords = 0;
while (re.hasNextElement()) ...{
byte[] temp = re.nextRecord();
DrawBalls = new DrawBallType();
DrawBalls = DrawBallType.ByteToClass(temp);
Drecords++;
re.nextRecordId();
int ID = re.previousRecordId();
if (DrawBalls.Str.equals(record.Str)) ...{
RS.deleteRecord(ID);
System.out.println("ID:"+ID);
}
}
} catch (Exception e) ...{
e.printStackTrace();
} finally ...{
if (re != null)
re.destroy();
}
} catch (Exception e) ...{
e.printStackTrace();
return false;
}
return true;
}
public DrawBallType[] GetAllRecord(boolean RecordE) ...{
DrawBallType[] DrawBalls = new DrawBallType[0];
RecordEnumeration re = null;
try ...{
if (RS == null)
return DrawBalls;
if (RecordE)
re = RS.enumerateRecords(null, new BallComparator(false), true);
else
re = RS.enumerateRecords(new BallFilter("99999"),
new BallComparator(false), false);
DrawBalls = new DrawBallType[re.numRecords()];
int Drecords = 0;
while (re.hasNextElement()) ...{
byte[] temp = re.nextRecord();
DrawBalls[Drecords] = new DrawBallType();
DrawBalls[Drecords] = DrawBallType.ByteToClass(temp);
Drecords++;
}
} catch (Exception e) ...{
e.printStackTrace();
return null;
} finally ...{
if (re != null)
re.destroy();
}
return DrawBalls;
}
}