01: package net.sf.borg.model;
02:
03: import java.util.StringTokenizer;
04:
05: import net.sf.borg.common.PrefName;
06: import net.sf.borg.common.Prefs;
07:
08: public class ReminderTimes {
09:
10: static private int times_[] = null;
11: static private int NUM = 20;
12:
13: static public int getNum() {
14: return NUM;
15: }
16:
17: static public int getTimes(int i) {
18: if (times_ == null) {
19: // get times array from prefs
20: times_ = new int[NUM];
21: String s = Prefs.getPref(PrefName.REMMINS);
22: arrayFromString(s);
23: }
24: return times_[i];
25: }
26:
27: static public void setTimes(int times[]) {
28: times_ = times;
29: String s = arrayToString(times_);
30: Prefs.putPref(PrefName.REMMINS, s);
31: }
32:
33: static private String arrayToString(int a[]) {
34: StringBuffer sb = new StringBuffer();
35: for (int i = 0; i < a.length; i++) {
36: sb.append(Integer.toString(a[i]));
37: if (sb.length() != 0)
38: sb.append(',');
39: }
40:
41: return sb.toString();
42: }
43:
44: static private void arrayFromString(String s) {
45: StringTokenizer t = new StringTokenizer(s, ",");
46: for (int i = 0; i < NUM; i++) {
47: if (t.hasMoreTokens()) {
48: String tok = t.nextToken();
49: times_[i] = Integer.parseInt(tok);
50: } else {
51: times_[i] = 0;
52: }
53: }
54: }
55: }
|