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