DEADSOFTWARE

Update readme
[mp3cc.git] / mps / src / RS.java
1 // this is the class to implement record store functionality
2 // for MIDletPascal
3 import javax.microedition.rms.*;
5 public class RS
6 {
7 // open record store
8 public static RecordStore j(String name)
9 {
10 try
11 {
12 return RecordStore.openRecordStore(name, true);
13 }
14 catch(Exception e)
15 {
16 return null;
17 }
18 }
21 // closes record store
22 public static void L(RecordStore rs)
23 {
24 try
25 {
26 rs.closeRecordStore();
27 }
28 catch(Exception e)
29 {
30 }
31 }
33 // deletes a record store
34 public static void L(String name)
35 {
36 try
37 {
38 RecordStore.deleteRecordStore(name);
39 }
40 catch(Exception e)
41 {
42 }
43 }
45 // deletes a record from a record store
46 public static void L(RecordStore rs, int id)
47 {
48 try
49 {
50 rs.deleteRecord(id);
51 }
52 catch(Exception e)
53 {
54 }
55 }
57 // adds a record
58 public static int L(RecordStore rs, String data)
59 {
60 try
61 {
62 return rs.addRecord(data.getBytes(), 0, data.length());
63 }
64 catch(Exception e)
65 {
66 return -1;
67 }
68 }
70 // sets a data in the entry
71 public static void L(RecordStore rs, String data, int id)
72 {
73 try
74 {
75 rs.setRecord(id, data.getBytes(), 0, data.getBytes().length);
76 }
77 catch (Exception e)
78 {}
79 }
81 // returns the next record ID
82 public static int Lja(RecordStore rs)
83 {
84 try
85 {
86 return rs.getNextRecordID();
87 }
88 catch (Exception e)
89 {
90 return -1;
91 }
92 }
94 // read the data from the record store
95 public static String j(RecordStore rs, int id)
96 {
97 try
98 {
99 byte[] res;
100 res = rs.getRecord(id);
102 if (res == null)
103 return "";
105 return new String(res);
107 catch(Exception e)
109 return "";
113 // return the number of records in the record store
114 public static int j(RecordStore rs)
116 try
118 return rs.getNumRecords();
120 catch(Exception e)
122 return 0;
125 };