1:
9: package ;
10:
11: import ;
12:
13:
17: public class MediaListImpl implements SACMediaList {
18:
19: String[] array = new String[10];
20: int current;
21:
22: public int getLength() {
23: return current;
24: }
25:
26: public String item(int index) {
27: if ((index < 0) || (index >= current)) {
28: return null;
29: }
30: return array[index];
31: }
32:
33: void addItem(String medium) {
34: if (medium.equals("all")) {
35: array[0] = "all";
36: current = 1;
37: return;
38: }
39: for (int i = 0; i < current; i++) {
40: if (medium.equals(array[i])) {
41: return;
42: }
43: }
44: if (current == array.length) {
45: String[] old = array;
46: array = new String[current + current];
47: System.arraycopy(old, 0, array, 0, current);
48: }
49: array[current++] = medium;
50: }
51:
52:
55: public String toString() {
56: int _i;
57:
58: switch (current) {
59: case 0:
60: return "";
61: case 1:
62: return array[0];
63: default:
64: boolean not_done = true;
65: int i = 0;
66: StringBuffer buf = new StringBuffer(50);
67: do {
68: buf.append(array[i++]);
69: if (i == current) {
70: not_done = false;
71: } else {
72: buf.append(", ");
73: }
74: } while (not_done);
75: return buf.toString();
76: }
77: }
78: }