Commit | Line | Data |
---|---|---|
08fe2e33 NR |
1 | package be.nikiroo.fanfix.data; |
2 | ||
301791d3 | 3 | import java.util.ArrayList; |
08fe2e33 NR |
4 | import java.util.List; |
5 | ||
16a81ef7 NR |
6 | import be.nikiroo.utils.Image; |
7 | ||
08fe2e33 NR |
8 | /** |
9 | * The meta data associated to a {@link Story} object. | |
10 | * | |
11 | * @author niki | |
12 | */ | |
22848428 | 13 | public class MetaData implements Cloneable, Comparable<MetaData> { |
08fe2e33 NR |
14 | private String title; |
15 | private String author; | |
16 | private String date; | |
17 | private Chapter resume; | |
18 | private List<String> tags; | |
16a81ef7 | 19 | private Image cover; |
08fe2e33 NR |
20 | private String subject; |
21 | private String source; | |
2206ef66 | 22 | private String url; |
08fe2e33 NR |
23 | private String uuid; |
24 | private String luid; | |
25 | private String lang; | |
26 | private String publisher; | |
fe999aa4 | 27 | private String type; |
08fe2e33 | 28 | private boolean imageDocument; |
793f1071 NR |
29 | private long words; |
30 | private String creationDate; | |
a9eb3f46 | 31 | private boolean fakeCover; |
08fe2e33 NR |
32 | |
33 | /** | |
34 | * The title of the story. | |
35 | * | |
36 | * @return the title | |
37 | */ | |
38 | public String getTitle() { | |
39 | return title; | |
40 | } | |
41 | ||
42 | /** | |
43 | * The title of the story. | |
44 | * | |
45 | * @param title | |
46 | * the title to set | |
47 | */ | |
48 | public void setTitle(String title) { | |
49 | this.title = title; | |
50 | } | |
51 | ||
52 | /** | |
53 | * The author of the story. | |
54 | * | |
55 | * @return the author | |
56 | */ | |
57 | public String getAuthor() { | |
58 | return author; | |
59 | } | |
60 | ||
61 | /** | |
62 | * The author of the story. | |
63 | * | |
64 | * @param author | |
65 | * the author to set | |
66 | */ | |
67 | public void setAuthor(String author) { | |
68 | this.author = author; | |
69 | } | |
70 | ||
71 | /** | |
72 | * The story publication date. | |
73 | * | |
74 | * @return the date | |
75 | */ | |
76 | public String getDate() { | |
77 | return date; | |
78 | } | |
79 | ||
80 | /** | |
81 | * The story publication date. | |
82 | * | |
83 | * @param date | |
84 | * the date to set | |
85 | */ | |
86 | public void setDate(String date) { | |
87 | this.date = date; | |
88 | } | |
89 | ||
90 | /** | |
91 | * The tags associated with this story. | |
92 | * | |
93 | * @return the tags | |
94 | */ | |
95 | public List<String> getTags() { | |
96 | return tags; | |
97 | } | |
98 | ||
99 | /** | |
100 | * The tags associated with this story. | |
101 | * | |
102 | * @param tags | |
103 | * the tags to set | |
104 | */ | |
105 | public void setTags(List<String> tags) { | |
106 | this.tags = tags; | |
107 | } | |
108 | ||
109 | /** | |
110 | * The story resume (a.k.a. description). | |
111 | * | |
112 | * @return the resume | |
113 | */ | |
114 | public Chapter getResume() { | |
115 | return resume; | |
116 | } | |
117 | ||
118 | /** | |
119 | * The story resume (a.k.a. description). | |
120 | * | |
121 | * @param resume | |
122 | * the resume to set | |
123 | */ | |
124 | public void setResume(Chapter resume) { | |
125 | this.resume = resume; | |
126 | } | |
127 | ||
128 | /** | |
129 | * The cover image of the story if any (can be NULL). | |
130 | * | |
131 | * @return the cover | |
132 | */ | |
16a81ef7 | 133 | public Image getCover() { |
08fe2e33 NR |
134 | return cover; |
135 | } | |
136 | ||
137 | /** | |
138 | * The cover image of the story if any (can be NULL). | |
139 | * | |
140 | * @param cover | |
141 | * the cover to set | |
142 | */ | |
16a81ef7 | 143 | public void setCover(Image cover) { |
08fe2e33 NR |
144 | this.cover = cover; |
145 | } | |
146 | ||
147 | /** | |
148 | * The subject of the story (or instance, if it is a fanfiction, what is the | |
149 | * original work; if it is a technical text, what is the technical | |
150 | * subject...). | |
151 | * | |
152 | * @return the subject | |
153 | */ | |
154 | public String getSubject() { | |
155 | return subject; | |
156 | } | |
157 | ||
158 | /** | |
159 | * The subject of the story (for instance, if it is a fanfiction, what is | |
160 | * the original work; if it is a technical text, what is the technical | |
161 | * subject...). | |
162 | * | |
163 | * @param subject | |
164 | * the subject to set | |
165 | */ | |
166 | public void setSubject(String subject) { | |
167 | this.subject = subject; | |
168 | } | |
169 | ||
170 | /** | |
2206ef66 | 171 | * The source of this story (which online library it was downloaded from). |
08fe2e33 NR |
172 | * |
173 | * @return the source | |
174 | */ | |
175 | public String getSource() { | |
176 | return source; | |
177 | } | |
178 | ||
179 | /** | |
2206ef66 | 180 | * The source of this story (which online library it was downloaded from). |
08fe2e33 NR |
181 | * |
182 | * @param source | |
183 | * the source to set | |
184 | */ | |
185 | public void setSource(String source) { | |
186 | this.source = source; | |
187 | } | |
188 | ||
189 | /** | |
2206ef66 NR |
190 | * The original URL from which this {@link Story} was imported. |
191 | * | |
192 | * @return the url | |
193 | */ | |
194 | public String getUrl() { | |
195 | return url; | |
196 | } | |
197 | ||
198 | /** | |
199 | * The original URL from which this {@link Story} was imported. | |
200 | * | |
201 | * @param url | |
202 | * the new url to set | |
203 | */ | |
204 | public void setUrl(String url) { | |
205 | this.url = url; | |
206 | } | |
207 | ||
208 | /** | |
209 | * A unique value representing the story (it is often a URL). | |
08fe2e33 NR |
210 | * |
211 | * @return the uuid | |
212 | */ | |
213 | public String getUuid() { | |
214 | return uuid; | |
215 | } | |
216 | ||
217 | /** | |
2206ef66 | 218 | * A unique value representing the story (it is often a URL). |
08fe2e33 NR |
219 | * |
220 | * @param uuid | |
221 | * the uuid to set | |
222 | */ | |
223 | public void setUuid(String uuid) { | |
224 | this.uuid = uuid; | |
225 | } | |
226 | ||
227 | /** | |
228 | * A unique value representing the story in the local library. | |
229 | * | |
230 | * @return the luid | |
231 | */ | |
232 | public String getLuid() { | |
233 | return luid; | |
234 | } | |
235 | ||
236 | /** | |
237 | * A unique value representing the story in the local library. | |
238 | * | |
0efd25e3 | 239 | * @param luid |
08fe2e33 NR |
240 | * the luid to set |
241 | */ | |
242 | public void setLuid(String luid) { | |
243 | this.luid = luid; | |
244 | } | |
245 | ||
246 | /** | |
247 | * The 2-letter code language of this story. | |
248 | * | |
249 | * @return the lang | |
250 | */ | |
251 | public String getLang() { | |
252 | return lang; | |
253 | } | |
254 | ||
255 | /** | |
256 | * The 2-letter code language of this story. | |
257 | * | |
258 | * @param lang | |
259 | * the lang to set | |
260 | */ | |
261 | public void setLang(String lang) { | |
262 | this.lang = lang; | |
263 | } | |
264 | ||
265 | /** | |
266 | * The story publisher (other the same as the source). | |
267 | * | |
268 | * @return the publisher | |
269 | */ | |
270 | public String getPublisher() { | |
271 | return publisher; | |
272 | } | |
273 | ||
274 | /** | |
275 | * The story publisher (other the same as the source). | |
276 | * | |
277 | * @param publisher | |
278 | * the publisher to set | |
279 | */ | |
280 | public void setPublisher(String publisher) { | |
281 | this.publisher = publisher; | |
282 | } | |
283 | ||
fe999aa4 NR |
284 | /** |
285 | * The output type this {@link Story} is in. | |
286 | * | |
287 | * @return the type the type | |
288 | */ | |
289 | public String getType() { | |
290 | return type; | |
291 | } | |
292 | ||
293 | /** | |
294 | * The output type this {@link Story} is in. | |
295 | * | |
296 | * @param type | |
297 | * the new type to set | |
298 | */ | |
299 | public void setType(String type) { | |
300 | this.type = type; | |
301 | } | |
302 | ||
08fe2e33 NR |
303 | /** |
304 | * Document catering mostly to image files. | |
305 | * | |
306 | * @return the imageDocument state | |
307 | */ | |
308 | public boolean isImageDocument() { | |
309 | return imageDocument; | |
310 | } | |
311 | ||
312 | /** | |
313 | * Document catering mostly to image files. | |
314 | * | |
315 | * @param imageDocument | |
316 | * the imageDocument state to set | |
317 | */ | |
318 | public void setImageDocument(boolean imageDocument) { | |
319 | this.imageDocument = imageDocument; | |
320 | } | |
301791d3 | 321 | |
793f1071 NR |
322 | /** |
323 | * The number of words in the related {@link Story}. | |
324 | * | |
325 | * @return the number of words | |
326 | */ | |
327 | public long getWords() { | |
328 | return words; | |
329 | } | |
330 | ||
331 | /** | |
332 | * The number of words in the related {@link Story}. | |
333 | * | |
334 | * @param words | |
335 | * the number of words to set | |
336 | */ | |
337 | public void setWords(long words) { | |
338 | this.words = words; | |
339 | } | |
340 | ||
341 | /** | |
342 | * The (Fanfix) {@link Story} creation date. | |
343 | * | |
344 | * @return the creationDate | |
345 | */ | |
346 | public String getCreationDate() { | |
347 | return creationDate; | |
348 | } | |
349 | ||
350 | /** | |
351 | * The (Fanfix) {@link Story} creation date. | |
352 | * | |
353 | * @param creationDate | |
354 | * the creationDate to set | |
355 | */ | |
356 | public void setCreationDate(String creationDate) { | |
357 | this.creationDate = creationDate; | |
358 | } | |
359 | ||
a9eb3f46 NR |
360 | /** |
361 | * The cover in this {@link MetaData} object is "fake", in the sens that it | |
362 | * comes from the actual content images. | |
363 | * | |
364 | * @return TRUE for a fake cover | |
365 | */ | |
366 | public boolean isFakeCover() { | |
367 | return fakeCover; | |
368 | } | |
369 | ||
370 | /** | |
371 | * The cover in this {@link MetaData} object is "fake", in the sens that it | |
372 | * comes from the actual content images | |
373 | * | |
374 | * @param fakeCover | |
375 | * TRUE for a fake cover | |
376 | */ | |
377 | public void setFakeCover(boolean fakeCover) { | |
378 | this.fakeCover = fakeCover; | |
379 | } | |
380 | ||
211f7ddb | 381 | @Override |
22848428 NR |
382 | public int compareTo(MetaData o) { |
383 | String oUuid = o == null ? null : o.getUuid(); | |
384 | return getUuid().compareTo(oUuid); | |
385 | } | |
386 | ||
301791d3 NR |
387 | @Override |
388 | public MetaData clone() { | |
389 | MetaData meta = null; | |
390 | try { | |
391 | meta = (MetaData) super.clone(); | |
392 | } catch (CloneNotSupportedException e) { | |
393 | // Did the clones rebel? | |
394 | System.err.println(e); | |
395 | } | |
396 | ||
397 | if (tags != null) { | |
39cd9738 | 398 | meta.tags = new ArrayList<String>(tags); |
301791d3 | 399 | } |
39cd9738 | 400 | |
301791d3 | 401 | if (resume != null) { |
39cd9738 | 402 | meta.resume = resume.clone(); |
301791d3 NR |
403 | } |
404 | ||
405 | return meta; | |
406 | } | |
08fe2e33 | 407 | } |