| 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 { |
| 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 | |
| 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 | /** |
| 167 | * The source of this story (which online library it was downloaded from). |
| 168 | * |
| 169 | * @return the source |
| 170 | */ |
| 171 | public String getSource() { |
| 172 | return source; |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * The source of this story (which online library it was downloaded from). |
| 177 | * |
| 178 | * @param source |
| 179 | * the source to set |
| 180 | */ |
| 181 | public void setSource(String source) { |
| 182 | this.source = source; |
| 183 | } |
| 184 | |
| 185 | /** |
| 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). |
| 206 | * |
| 207 | * @return the uuid |
| 208 | */ |
| 209 | public String getUuid() { |
| 210 | return uuid; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * A unique value representing the story (it is often a URL). |
| 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 | |
| 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 | |
| 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 | } |
| 317 | |
| 318 | @Override |
| 319 | public MetaData clone() { |
| 320 | MetaData meta = null; |
| 321 | try { |
| 322 | meta = (MetaData) super.clone(); |
| 323 | } catch (CloneNotSupportedException e) { |
| 324 | // Did the clones rebel? |
| 325 | System.err.println(e); |
| 326 | } |
| 327 | |
| 328 | if (tags != null) { |
| 329 | meta.tags = new ArrayList<String>(); |
| 330 | meta.tags.addAll(tags); |
| 331 | } |
| 332 | if (resume != null) { |
| 333 | meta.resume = new Chapter(resume.getNumber(), resume.getName()); |
| 334 | for (Paragraph para : resume) { |
| 335 | meta.resume.getParagraphs().add(para); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | return meta; |
| 340 | } |
| 341 | } |