blob: ebfb2203129e35a85ed2578ef211c1c93b6be211 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
package NET.worlds.scape;
import java.io.IOException;
public class CDDiskInfo implements Persister {
private String artist;
private String title;
private String category;
private String[] trackNames;
private static Object classCookie = new Object();
public CDDiskInfo(String artist, String title, String category, String[] trackNames) {
this.artist = artist;
this.title = title;
this.category = category;
this.trackNames = new String[trackNames.length];
System.arraycopy(trackNames, 0, this.trackNames, 0, trackNames.length);
}
public CDDiskInfo() {
}
public String getArtist() {
return this.artist;
}
public String getTitle() {
return this.title;
}
public String getCategory() {
return this.category;
}
public int getNumTracks() {
return this.trackNames.length;
}
public String getTrackName(int track) {
return this.trackNames[track];
}
@Override
public String toString() {
String ret = "Artist: " + this.artist + "\n" + "Title: " + this.title + "\n" + "Category: " + this.category + "\n";
for (int i = 0; i < this.trackNames.length; i++) {
ret = ret + "Track " + (i + 1) + ":";
if (this.trackNames[i] != null) {
ret = ret + this.trackNames[i];
}
ret = ret + "\n";
}
return ret;
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(1, classCookie);
s.saveString(this.artist);
s.saveString(this.title);
s.saveString(this.category);
s.saveInt(this.trackNames.length);
for (int i = 0; i < this.trackNames.length; i++) {
s.saveString(this.trackNames[i]);
}
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
switch (r.restoreVersion(classCookie)) {
case 1:
this.artist = r.restoreString();
this.title = r.restoreString();
this.category = r.restoreString();
this.trackNames = new String[r.restoreInt()];
for (int i = 0; i < this.trackNames.length; i++) {
this.trackNames[i] = r.restoreString();
}
return;
default:
throw new TooNewException();
}
}
@Override
public void postRestore(int version) {
}
}
|