Ignore rules for git users
[stereo.git] / MemphisDJ / src / music / CollectionTrack.java
blobc2083af97972c13a97bf67149500578013b05579
1 package music;
3 import interfaces.Album;
4 import interfaces.Constants;
5 import interfaces.Track;
7 import java.io.IOException;
8 import java.util.ArrayList;
10 public class CollectionTrack implements Track {
12 private final Track track;
13 private final int container;
14 private final int containerItemId;
16 public CollectionTrack(Track track, int container, int containerItemId) {
17 this.track = track;
18 this.container = container;
19 this.containerItemId = containerItemId;
22 public int hashCode() {
23 return track.id();
26 public boolean equals(Object o) {
27 if (o == this) return true;
28 else if (o instanceof Track) {
29 return ((Track)o).id() == track.id();
31 return false;
34 public Object get(Constants tag) {
35 switch (tag) {
36 case dmap_containeritemid:
37 return containerItemId;
38 case dmap_parentcontainerid:
39 return container;
40 default:
41 return track.get(tag);
45 public Object get(Constants tag, Object defaultValue) {
46 Object ret = get(tag);
47 if (ret == null) {
48 return defaultValue;
50 else {
51 return ret;
55 public Album getAlbum() {
56 return track.getAlbum();
59 public Iterable<Constants> getAllTags() {
60 ArrayList<Constants> tags = new ArrayList<Constants>();
61 for (Constants c: track.getAllTags()) {
62 tags.add(c);
64 tags.add(Constants.dmap_containeritemid);
65 tags.add(Constants.dmap_parentcontainerid);
66 return tags;
69 public void getStream(StreamReader reader) throws IOException {
70 track.getStream(reader);
73 public int id() {
74 return track.id();
77 public long persistentId() {
78 return track.persistentId();
81 public void put(Constants tag, Object value) {
82 track.put(tag, value);
85 public void setAlbum(Album album) {
86 track.setAlbum(album);
89 public String toString() {
90 return track.toString();