Minor changes supporting new client architecture
[stereo.git] / MemphisDJ / src / music / Track.java
blob3b8179edcb1b903067b608174e77479b009b5db2
1 package music;
4 import interfaces.Album;
5 import interfaces.HasMetadata;
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.util.HashMap;
10 import java.util.Map;
12 public abstract class Track implements HasMetadata {
14 private final int id;
15 private final long persistentId;
16 private Album album;
17 private final Map<Integer, Object> tags = new HashMap<Integer, Object>();
19 public Track(int id, long persistentId) {
20 this.id = id;
21 this.persistentId = persistentId;
22 this.tags.put(1835624804, id);
23 this.tags.put(1836082546, persistentId);
26 public int id() {
27 return id;
30 public long persistentId() {
31 return persistentId;
34 public boolean equals(Object o) {
35 if (o instanceof Track) {
36 return ((Track)o).persistentId == this.persistentId;
38 return false;
41 public int hashCode() {
42 return ((Long)persistentId).hashCode();
45 public Album getAlbum() {
46 return album;
49 public void setAlbum(Album album) {
50 this.album = album;
53 public Object get(int tag) {
54 return tags.get(tag);
57 public void put(int tag, Object value) {
58 tags.put(tag, value);
61 public Iterable<Integer> getAllTags() {
62 return tags.keySet();
65 /**
66 * Returns the track as a playable stream of data.
68 * @return A stream, possibly null
69 * @throws IOException
71 public abstract InputStream getStream() throws IOException;
73 public interface TrackFactory {
74 public Track create(int id, long persistentId);