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