| 1 | |
package org.jaudiotagger.tag.flac; |
| 2 | |
|
| 3 | |
import org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture; |
| 4 | |
import org.jaudiotagger.audio.generic.Utils; |
| 5 | |
import org.jaudiotagger.audio.asf.tag.AsfTagField; |
| 6 | |
import org.jaudiotagger.audio.asf.tag.AsfTagCoverField; |
| 7 | |
import org.jaudiotagger.tag.*; |
| 8 | |
import org.jaudiotagger.tag.mp4.field.Mp4TagCoverField; |
| 9 | |
import org.jaudiotagger.tag.datatype.Artwork; |
| 10 | |
import org.jaudiotagger.tag.id3.valuepair.ImageFormats; |
| 11 | |
import org.jaudiotagger.tag.id3.valuepair.TextEncoding; |
| 12 | |
import org.jaudiotagger.tag.reference.PictureTypes; |
| 13 | |
import org.jaudiotagger.tag.vorbiscomment.VorbisCommentTag; |
| 14 | |
|
| 15 | |
import javax.imageio.ImageIO; |
| 16 | |
import java.awt.image.BufferedImage; |
| 17 | |
import java.io.ByteArrayOutputStream; |
| 18 | |
import java.io.DataOutputStream; |
| 19 | |
import java.io.IOException; |
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.Iterator; |
| 22 | |
import java.util.List; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
public class FlacTag implements Tag |
| 31 | |
{ |
| 32 | 25 | private VorbisCommentTag tag = null; |
| 33 | 25 | private List<MetadataBlockDataPicture> images = new ArrayList<MetadataBlockDataPicture>(); |
| 34 | |
|
| 35 | |
public FlacTag(VorbisCommentTag tag, List<MetadataBlockDataPicture> images) |
| 36 | 25 | { |
| 37 | 25 | this.tag = tag; |
| 38 | 25 | this.images = images; |
| 39 | 25 | } |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
public List<MetadataBlockDataPicture> getImages() |
| 45 | |
{ |
| 46 | 61 | return images; |
| 47 | |
} |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
public VorbisCommentTag getVorbisCommentTag() |
| 53 | |
{ |
| 54 | 60 | return tag; |
| 55 | |
} |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
public void add(TagField field) throws FieldDataInvalidException |
| 76 | |
{ |
| 77 | 2 | if (field instanceof MetadataBlockDataPicture) |
| 78 | |
{ |
| 79 | 1 | images.add((MetadataBlockDataPicture) field); |
| 80 | |
} |
| 81 | |
else |
| 82 | |
{ |
| 83 | 1 | tag.add(field); |
| 84 | |
} |
| 85 | 2 | } |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
public void addAlbum(String album) throws FieldDataInvalidException |
| 93 | |
{ |
| 94 | 2 | tag.addAlbum(album); |
| 95 | 2 | } |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
public void addArtist(String artist) throws FieldDataInvalidException |
| 103 | |
{ |
| 104 | 1 | tag.addArtist(artist); |
| 105 | 1 | } |
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
public void addComment(String comment) throws FieldDataInvalidException |
| 113 | |
{ |
| 114 | 0 | tag.addComment(comment); |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
public void addGenre(String genre) throws FieldDataInvalidException |
| 123 | |
{ |
| 124 | 2 | tag.addGenre(genre); |
| 125 | 2 | } |
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
public void addTitle(String title) throws FieldDataInvalidException |
| 133 | |
{ |
| 134 | 2 | tag.addTitle(title); |
| 135 | 2 | } |
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
public void addTrack(String track) throws FieldDataInvalidException |
| 143 | |
{ |
| 144 | 2 | tag.addTrack(track); |
| 145 | 2 | } |
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
public void addYear(String year) throws FieldDataInvalidException |
| 153 | |
{ |
| 154 | 2 | tag.addYear(year); |
| 155 | 2 | } |
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
public List<TagField> get(String id) |
| 165 | |
{ |
| 166 | 4 | if (id.equals(TagFieldKey.COVER_ART.name())) |
| 167 | |
{ |
| 168 | 3 | List<TagField> castImages = new ArrayList<TagField>(); |
| 169 | 3 | for (MetadataBlockDataPicture image : images) |
| 170 | |
{ |
| 171 | 5 | castImages.add(image); |
| 172 | |
} |
| 173 | 3 | return castImages; |
| 174 | |
} |
| 175 | |
else |
| 176 | |
{ |
| 177 | 1 | return tag.get(id); |
| 178 | |
} |
| 179 | |
} |
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
public List<TagField> getAlbum() |
| 185 | |
{ |
| 186 | 1 | return tag.getAlbum(); |
| 187 | |
} |
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
|
| 193 | |
public List<TagField> getArtist() |
| 194 | |
{ |
| 195 | 1 | return tag.getArtist(); |
| 196 | |
} |
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
public List<TagField> getComment() |
| 202 | |
{ |
| 203 | 0 | return tag.getComment(); |
| 204 | |
} |
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
public List<TagField> getGenre() |
| 210 | |
{ |
| 211 | 1 | return tag.getGenre(); |
| 212 | |
} |
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
public List<TagField> getTitle() |
| 218 | |
{ |
| 219 | 1 | return tag.getTitle(); |
| 220 | |
} |
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
public List<TagField> getTrack() |
| 226 | |
{ |
| 227 | 1 | return tag.getTrack(); |
| 228 | |
} |
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
public List<TagField> getYear() |
| 234 | |
{ |
| 235 | 1 | return tag.getYear(); |
| 236 | |
} |
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
|
| 242 | |
public String getFirstAlbum() |
| 243 | |
{ |
| 244 | 4 | return tag.getFirstAlbum(); |
| 245 | |
} |
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
|
| 250 | |
public String getFirstArtist() |
| 251 | |
{ |
| 252 | 3 | return tag.getFirstArtist(); |
| 253 | |
} |
| 254 | |
|
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | |
public String getFirstComment() |
| 260 | |
{ |
| 261 | 1 | return tag.getFirstComment(); |
| 262 | |
} |
| 263 | |
|
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
public String getFirstGenre() |
| 269 | |
{ |
| 270 | 2 | return tag.getFirstGenre(); |
| 271 | |
} |
| 272 | |
|
| 273 | |
|
| 274 | |
|
| 275 | |
|
| 276 | |
|
| 277 | |
public String getFirstTitle() |
| 278 | |
{ |
| 279 | 2 | return tag.getFirstTitle(); |
| 280 | |
} |
| 281 | |
|
| 282 | |
|
| 283 | |
|
| 284 | |
|
| 285 | |
|
| 286 | |
public String getFirstTrack() |
| 287 | |
{ |
| 288 | 2 | return tag.getFirstTrack(); |
| 289 | |
} |
| 290 | |
|
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
public String getFirstYear() |
| 296 | |
{ |
| 297 | 2 | return tag.getFirstYear(); |
| 298 | |
} |
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
|
| 307 | |
|
| 308 | |
public boolean hasCommonFields() |
| 309 | |
{ |
| 310 | 0 | return tag.hasCommonFields(); |
| 311 | |
} |
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
public boolean hasField(String id) |
| 322 | |
{ |
| 323 | 0 | if (id.equals(TagFieldKey.COVER_ART.name())) |
| 324 | |
{ |
| 325 | 0 | return images.size() > 0; |
| 326 | |
} |
| 327 | |
else |
| 328 | |
{ |
| 329 | 0 | return tag.hasField(id); |
| 330 | |
} |
| 331 | |
} |
| 332 | |
|
| 333 | |
|
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | |
public boolean isEmpty() |
| 342 | |
{ |
| 343 | 11 | return (tag == null || tag.isEmpty()) && images.size() == 0; |
| 344 | |
} |
| 345 | |
|
| 346 | |
|
| 347 | |
|
| 348 | |
|
| 349 | |
|
| 350 | |
public void set(TagField field) throws FieldDataInvalidException |
| 351 | |
{ |
| 352 | 7 | if (field instanceof MetadataBlockDataPicture) |
| 353 | |
{ |
| 354 | 3 | if (images.size() == 0) |
| 355 | |
{ |
| 356 | 2 | images.add(0, (MetadataBlockDataPicture) field); |
| 357 | |
} |
| 358 | |
else |
| 359 | |
{ |
| 360 | 1 | images.set(0, (MetadataBlockDataPicture) field); |
| 361 | |
} |
| 362 | |
} |
| 363 | |
else |
| 364 | |
{ |
| 365 | 4 | tag.set(field); |
| 366 | |
} |
| 367 | 7 | } |
| 368 | |
|
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
public void setAlbum(String s) throws FieldDataInvalidException |
| 374 | |
{ |
| 375 | 2 | tag.setAlbum(s); |
| 376 | 2 | } |
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
public void setArtist(String s) throws FieldDataInvalidException |
| 384 | |
{ |
| 385 | 1 | tag.setArtist(s); |
| 386 | 1 | } |
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
|
| 391 | |
|
| 392 | |
public void setComment(String s) throws FieldDataInvalidException |
| 393 | |
{ |
| 394 | 0 | tag.setComment(s); |
| 395 | 0 | } |
| 396 | |
|
| 397 | |
|
| 398 | |
|
| 399 | |
|
| 400 | |
|
| 401 | |
|
| 402 | |
public void setGenre(String s) throws FieldDataInvalidException |
| 403 | |
{ |
| 404 | 0 | tag.setGenre(s); |
| 405 | 0 | } |
| 406 | |
|
| 407 | |
|
| 408 | |
|
| 409 | |
|
| 410 | |
|
| 411 | |
public void setTitle(String s) throws FieldDataInvalidException |
| 412 | |
{ |
| 413 | 0 | tag.setTitle(s); |
| 414 | 0 | } |
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
|
| 420 | |
public void setTrack(String s) throws FieldDataInvalidException |
| 421 | |
{ |
| 422 | 0 | tag.setTrack(s); |
| 423 | 0 | } |
| 424 | |
|
| 425 | |
|
| 426 | |
|
| 427 | |
|
| 428 | |
|
| 429 | |
public void setYear(String s) throws FieldDataInvalidException |
| 430 | |
{ |
| 431 | 0 | tag.setYear(s); |
| 432 | 0 | } |
| 433 | |
|
| 434 | |
|
| 435 | |
|
| 436 | |
|
| 437 | |
|
| 438 | |
|
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
|
| 443 | |
|
| 444 | |
|
| 445 | |
public TagField createTagField(TagFieldKey genericKey, String value) throws KeyNotFoundException, FieldDataInvalidException |
| 446 | |
{ |
| 447 | 5 | if (genericKey.equals(TagFieldKey.COVER_ART)) |
| 448 | |
{ |
| 449 | 0 | throw new UnsupportedOperationException("Please use the createArtworkField methods to create coverart "); |
| 450 | |
} |
| 451 | |
else |
| 452 | |
{ |
| 453 | 5 | return tag.createTagField(genericKey, value); |
| 454 | |
} |
| 455 | |
} |
| 456 | |
|
| 457 | |
|
| 458 | |
|
| 459 | |
|
| 460 | |
|
| 461 | |
|
| 462 | |
|
| 463 | |
|
| 464 | |
public String getFirst(String id) |
| 465 | |
{ |
| 466 | 0 | if (id.equals(TagFieldKey.COVER_ART.name())) |
| 467 | |
{ |
| 468 | 0 | throw new UnsupportedOperationException("Please use the createArtworkField methods to create coverart "); |
| 469 | |
} |
| 470 | |
else |
| 471 | |
{ |
| 472 | 0 | return tag.getFirst(id); |
| 473 | |
} |
| 474 | |
} |
| 475 | |
|
| 476 | |
|
| 477 | |
|
| 478 | |
|
| 479 | |
|
| 480 | |
|
| 481 | |
|
| 482 | |
public String getFirst(TagFieldKey id) throws KeyNotFoundException |
| 483 | |
{ |
| 484 | 16 | if (id.equals(TagFieldKey.COVER_ART)) |
| 485 | |
{ |
| 486 | 0 | throw new UnsupportedOperationException("Please use the createArtworkField methods to create coverart "); |
| 487 | |
} |
| 488 | |
else |
| 489 | |
{ |
| 490 | 16 | return tag.getFirst(id); |
| 491 | |
} |
| 492 | |
|
| 493 | |
} |
| 494 | |
|
| 495 | |
|
| 496 | |
|
| 497 | |
|
| 498 | |
|
| 499 | |
|
| 500 | |
|
| 501 | |
|
| 502 | |
|
| 503 | |
|
| 504 | |
public TagField getFirstField(String id) |
| 505 | |
{ |
| 506 | 0 | if (id.equals(TagFieldKey.COVER_ART)) |
| 507 | |
{ |
| 508 | 0 | if (images.size() > 0) |
| 509 | |
{ |
| 510 | 0 | return images.get(0); |
| 511 | |
} |
| 512 | |
else |
| 513 | |
{ |
| 514 | 0 | return null; |
| 515 | |
} |
| 516 | |
} |
| 517 | |
else |
| 518 | |
{ |
| 519 | 0 | return tag.getFirstField(id); |
| 520 | |
} |
| 521 | |
} |
| 522 | |
|
| 523 | |
public TagField getFirstField(TagFieldKey genericKey) throws KeyNotFoundException |
| 524 | |
{ |
| 525 | 0 | if (genericKey == null) |
| 526 | |
{ |
| 527 | 0 | throw new KeyNotFoundException(); |
| 528 | |
} |
| 529 | |
|
| 530 | 0 | if(genericKey == TagFieldKey.COVER_ART ) |
| 531 | |
{ |
| 532 | 0 | return getFirstField(TagFieldKey.COVER_ART.name()); |
| 533 | |
} |
| 534 | |
else |
| 535 | |
{ |
| 536 | 0 | return tag.getFirstField(genericKey); |
| 537 | |
} |
| 538 | |
} |
| 539 | |
|
| 540 | |
|
| 541 | |
|
| 542 | |
|
| 543 | |
|
| 544 | |
|
| 545 | |
public void deleteTagField(TagFieldKey tagFieldKey) throws KeyNotFoundException |
| 546 | |
{ |
| 547 | 0 | if (tagFieldKey.equals(TagFieldKey.COVER_ART)) |
| 548 | |
{ |
| 549 | 0 | images.clear(); |
| 550 | |
} |
| 551 | |
else |
| 552 | |
{ |
| 553 | 0 | tag.deleteTagField(tagFieldKey); |
| 554 | |
} |
| 555 | 0 | } |
| 556 | |
|
| 557 | |
|
| 558 | |
|
| 559 | |
|
| 560 | |
|
| 561 | |
|
| 562 | |
|
| 563 | |
public Iterator<TagField> getFields() |
| 564 | |
{ |
| 565 | 0 | return tag.getFields(); |
| 566 | |
} |
| 567 | |
|
| 568 | |
|
| 569 | |
|
| 570 | |
|
| 571 | |
|
| 572 | |
|
| 573 | |
|
| 574 | |
|
| 575 | |
|
| 576 | |
public int getFieldCount() |
| 577 | |
{ |
| 578 | 0 | return tag.getFieldCount() + images.size(); |
| 579 | |
} |
| 580 | |
|
| 581 | |
public boolean setEncoding(String enc) throws FieldDataInvalidException |
| 582 | |
{ |
| 583 | 0 | return tag.setEncoding(enc); |
| 584 | |
} |
| 585 | |
|
| 586 | |
|
| 587 | |
|
| 588 | |
|
| 589 | |
|
| 590 | |
|
| 591 | |
|
| 592 | |
|
| 593 | |
public List<TagField> get(TagFieldKey id) throws KeyNotFoundException |
| 594 | |
{ |
| 595 | 2 | if (id.equals(TagFieldKey.COVER_ART)) |
| 596 | |
{ |
| 597 | 1 | List<TagField> castImages = new ArrayList<TagField>(); |
| 598 | 1 | for (MetadataBlockDataPicture image : images) |
| 599 | |
{ |
| 600 | 2 | castImages.add(image); |
| 601 | |
} |
| 602 | 1 | return castImages; |
| 603 | |
} |
| 604 | |
else |
| 605 | |
{ |
| 606 | 1 | return tag.get(id); |
| 607 | |
} |
| 608 | |
|
| 609 | |
} |
| 610 | |
|
| 611 | |
|
| 612 | |
|
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
|
| 617 | |
|
| 618 | |
|
| 619 | |
|
| 620 | |
|
| 621 | |
|
| 622 | |
|
| 623 | |
|
| 624 | |
|
| 625 | |
public TagField createArtworkField(byte[] imageData, int pictureType, String mimeType, String description, int width, int height, int colourDepth, int indexedColouredCount) throws FieldDataInvalidException |
| 626 | |
{ |
| 627 | 2 | return new MetadataBlockDataPicture(imageData, pictureType, mimeType, description, width, height, colourDepth, indexedColouredCount); |
| 628 | |
} |
| 629 | |
|
| 630 | |
|
| 631 | |
|
| 632 | |
|
| 633 | |
|
| 634 | |
|
| 635 | |
|
| 636 | |
|
| 637 | |
|
| 638 | |
|
| 639 | |
|
| 640 | |
|
| 641 | |
public TagField createArtworkField(BufferedImage bi, int pictureType, String mimeType, String description, int colourDepth, int indexedColouredCount) throws FieldDataInvalidException |
| 642 | |
{ |
| 643 | |
|
| 644 | |
try |
| 645 | |
{ |
| 646 | 1 | final ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| 647 | 1 | ImageIO.write(bi, ImageFormats.getFormatForMimeType(mimeType), new DataOutputStream(output)); |
| 648 | |
|
| 649 | |
|
| 650 | 1 | return new MetadataBlockDataPicture(output.toByteArray(), pictureType, mimeType, description, bi.getWidth(), bi.getHeight(), colourDepth, indexedColouredCount); |
| 651 | |
} |
| 652 | 0 | catch (IOException ioe) |
| 653 | |
{ |
| 654 | 0 | throw new FieldDataInvalidException("Unable to convert image to bytearray, check mimetype parameter"); |
| 655 | |
} |
| 656 | |
} |
| 657 | |
|
| 658 | |
|
| 659 | |
|
| 660 | |
|
| 661 | |
|
| 662 | |
public TagField createLinkedArtworkField(String url) |
| 663 | |
{ |
| 664 | |
|
| 665 | 1 | return new MetadataBlockDataPicture(Utils.getDefaultBytes(url, TextEncoding.CHARSET_ISO_8859_1), PictureTypes.DEFAULT_ID, MetadataBlockDataPicture.IMAGE_IS_URL, "", 0, 0, 0, 0); |
| 666 | |
} |
| 667 | |
|
| 668 | |
|
| 669 | |
|
| 670 | |
|
| 671 | |
|
| 672 | |
|
| 673 | |
public TagField createArtworkField(Artwork artwork) throws FieldDataInvalidException |
| 674 | |
{ |
| 675 | 1 | if(artwork.isLinked()) |
| 676 | |
{ |
| 677 | 0 | return new MetadataBlockDataPicture( |
| 678 | |
Utils.getDefaultBytes(artwork.getImageUrl(), TextEncoding.CHARSET_ISO_8859_1), |
| 679 | |
artwork.getPictureType(), |
| 680 | |
MetadataBlockDataPicture.IMAGE_IS_URL, |
| 681 | |
"", |
| 682 | |
0, |
| 683 | |
0, |
| 684 | |
0, |
| 685 | |
0); |
| 686 | |
} |
| 687 | |
else |
| 688 | |
{ |
| 689 | |
BufferedImage image; |
| 690 | |
try |
| 691 | |
{ |
| 692 | 1 | image = artwork.getImage(); |
| 693 | |
} |
| 694 | 0 | catch(IOException ioe) |
| 695 | |
{ |
| 696 | 0 | throw new FieldDataInvalidException("Unable to create bufferd image from the image"); |
| 697 | 1 | } |
| 698 | |
|
| 699 | 1 | return new MetadataBlockDataPicture(artwork.getBinaryData(), |
| 700 | |
artwork.getPictureType(), |
| 701 | |
artwork.getMimeType(), |
| 702 | |
artwork.getDescription(), |
| 703 | |
image.getWidth(), |
| 704 | |
image.getHeight(), |
| 705 | |
0, |
| 706 | |
0); |
| 707 | |
} |
| 708 | |
} |
| 709 | |
|
| 710 | |
|
| 711 | |
|
| 712 | |
|
| 713 | |
|
| 714 | |
|
| 715 | |
|
| 716 | |
public void createAndSetArtworkField(Artwork artwork) throws FieldDataInvalidException |
| 717 | |
{ |
| 718 | 1 | this.set(createArtworkField(artwork)); |
| 719 | 1 | } |
| 720 | |
|
| 721 | |
public List<Artwork> getArtworkList() |
| 722 | |
{ |
| 723 | 6 | List<Artwork> artworkList = new ArrayList<Artwork>(images.size()); |
| 724 | |
|
| 725 | 6 | for(MetadataBlockDataPicture coverArt:images) |
| 726 | |
{ |
| 727 | 12 | Artwork artwork = new Artwork(); |
| 728 | 12 | artwork.setMimeType(coverArt.getMimeType()); |
| 729 | 12 | artwork.setDescription(coverArt.getDescription()); |
| 730 | 12 | artwork.setPictureType(coverArt.getPictureType()); |
| 731 | 12 | if(coverArt.isImageUrl()) |
| 732 | |
{ |
| 733 | 6 | artwork.setLinked(coverArt.isImageUrl()); |
| 734 | 6 | artwork.setImageUrl(coverArt.getImageUrl()); |
| 735 | |
} |
| 736 | |
else |
| 737 | |
{ |
| 738 | 6 | artwork.setBinaryData(coverArt.getImageData()); |
| 739 | |
} |
| 740 | 12 | artworkList.add(artwork); |
| 741 | 12 | } |
| 742 | 6 | return artworkList; |
| 743 | |
} |
| 744 | |
|
| 745 | |
public Artwork getFirstArtwork() |
| 746 | |
{ |
| 747 | 2 | List<Artwork> artwork = getArtworkList(); |
| 748 | 2 | if(artwork.size()>0) |
| 749 | |
{ |
| 750 | 2 | return artwork.get(0); |
| 751 | |
} |
| 752 | 0 | return null; |
| 753 | |
} |
| 754 | |
} |