diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/CDDiskInfo.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/CDDiskInfo.java')
| -rw-r--r-- | NET/worlds/scape/CDDiskInfo.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/NET/worlds/scape/CDDiskInfo.java b/NET/worlds/scape/CDDiskInfo.java new file mode 100644 index 0000000..ebfb220 --- /dev/null +++ b/NET/worlds/scape/CDDiskInfo.java @@ -0,0 +1,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) { + } +} |