1 package org.musicontroller.importer;
2
3 import java.io.Serializable;
4 import java.util.Date;
5 import java.util.HashSet;
6 import java.util.Set;
7
8 import org.varienaja.util.StringUtil;
9
10
11
12
13
14
15
16
17
18
19 public class MusicArchiveEntryBean implements Serializable, Comparable<MusicArchiveEntryBean> {
20
21 private static final long serialVersionUID = 20071205181556L;;
22
23
24
25
26
27 public MusicArchiveEntryBean() {
28 setKeywords(new HashSet<String>());
29 setInclude(true);
30 }
31
32
33
34
35
36 private String _playlistName;
37
38
39
40
41
42 private String _bandName;
43
44
45
46
47 private String _songName;
48
49
50
51
52 private int _songLength;
53
54
55
56
57 private Set<String> _keywords;
58
59
60
61
62 private int _songIndex;
63
64
65
66
67 private boolean _include;
68
69
70
71
72 private String _entryName;
73
74
75
76
77 private Date _releaseDate;
78
79
80
81
82
83 public String getBandName() {
84 return _bandName;
85 }
86
87
88
89
90
91 public void setBandName(String name) {
92 _bandName = name;
93 }
94
95
96
97
98
99 public String getPlaylistName() {
100 return _playlistName;
101 }
102
103
104
105
106
107 public void setPlaylistName(String name) {
108 _playlistName = name;
109 }
110
111
112
113
114
115 public Set<String> getKeywords() {
116 return _keywords;
117 }
118
119
120
121
122
123 public void setKeywords(Set<String> keywords) {
124 this._keywords = keywords;
125 }
126
127
128
129
130
131 public int getSongLength() {
132 return _songLength;
133 }
134
135
136
137
138
139 public void setSongLength(int seconds) {
140 _songLength = seconds;
141 }
142
143
144
145
146
147 public String getSongName() {
148 return _songName;
149 }
150
151
152
153
154
155 public void setSongName(String name) {
156 _songName = name;
157 }
158
159
160
161
162
163 public int getSongIndex() {
164 return _songIndex;
165 }
166
167
168
169
170
171 public void setSongIndex(int index) {
172 _songIndex = index;
173 }
174
175
176
177
178
179 public void setInclude(boolean include) {
180 this._include = include;
181 }
182
183
184
185
186
187 public boolean getInclude() {
188 return this._include;
189 }
190
191
192
193
194
195 public String getEntryName() {
196 return this._entryName;
197 }
198
199
200
201
202
203 public void setEntryName(String entryName) {
204 this._entryName = entryName;
205 }
206
207
208
209
210
211 public Date getReleaseDate() {
212 return _releaseDate;
213 }
214
215 public void setReleaseDate(Date releaseDate) {
216 this._releaseDate = releaseDate;
217 }
218
219
220
221
222
223
224 public String getKeywordString() {
225 StringBuilder result = new StringBuilder();
226 boolean putComma = false;
227 for(String kw: getKeywords()) {
228 if(putComma) {
229 result.append(",");
230 } else {
231 putComma = true;
232 }
233 result.append(kw);
234 }
235 return result.toString();
236 }
237
238
239
240
241
242
243
244
245 public void setKeywordString(String keywords) {
246 getKeywords().clear();
247 getKeywords().addAll(StringUtil.getIndividualWords(keywords));
248 }
249
250
251
252
253
254
255 public boolean equals(Object o) {
256 if (o==null) return false;
257
258 if (o instanceof MusicArchiveEntryBean) {
259 MusicArchiveEntryBean b= (MusicArchiveEntryBean) o;
260 if(getSongIndex()==0) {
261 StringBuilder sb1 = new StringBuilder();
262 StringBuilder sb2 = new StringBuilder();
263 sb1.append(getBandName());
264 sb1.append(getSongName());
265 sb2.append(b.getBandName());
266 sb2.append(b.getSongName());
267 return b.getSongIndex()==0 && sb1.toString().equals(sb2.toString());
268 } else {
269 return getSongIndex() == b.getSongIndex();
270 }
271 } else {
272 return false;
273 }
274
275 }
276
277
278
279
280
281 public int hashCode() {
282 if (getSongIndex()==0) {
283 StringBuilder sb = new StringBuilder();
284 sb.append(getBandName());
285 sb.append(getSongName());
286 return sb.toString().hashCode();
287 } else {
288 return getSongIndex();
289 }
290 }
291
292
293
294
295
296
297 public int compareTo(MusicArchiveEntryBean o) {
298 if(getSongIndex()==0) {
299 int bandCompare = 0;
300 if(getBandName()==null) {
301 if(o.getBandName()==null) {
302
303 } else {
304 bandCompare = -1;
305 }
306 } else {
307 if(o.getBandName()==null) {
308 bandCompare = 1;
309 } else {
310 bandCompare = getBandName().compareTo(o.getBandName());
311 }
312 }
313 if(bandCompare!=0) {
314 return bandCompare;
315 }
316
317 int songCompare = 0;
318 if(getSongName()==null) {
319 if(o.getSongName()==null) {
320
321 } else {
322 songCompare = -1;
323 }
324 } else {
325 if(o.getSongName()==null) {
326 songCompare = 1;
327 } else {
328 songCompare = getSongName().compareTo(o.getSongName());
329 }
330 }
331 return songCompare;
332 } else {
333 return Integer.valueOf(getSongIndex()).compareTo(Integer.valueOf(o.getSongIndex()));
334 }
335 }
336 }