Coverage Report - org.jaudiotagger.tag.flac.FlacTag
 
Classes in this File Line Coverage Branch Coverage Complexity
FlacTag
67%
91/136
54%
26/48
0
 
 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  
  * Flac uses Vorbis Comment for most of its metadata and a Flac Picture Block for images
 26  
  * <p/>
 27  
  * <p/>
 28  
  * This class enscapulates the items into a single tag
 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  
      * @return images
 43  
      */
 44  
     public List<MetadataBlockDataPicture> getImages()
 45  
     {
 46  61
         return images;
 47  
     }
 48  
 
 49  
     /**
 50  
      * @return the vorbis tag (this is what handles text metadata)
 51  
      */
 52  
     public VorbisCommentTag getVorbisCommentTag()
 53  
     {
 54  60
         return tag;
 55  
     }
 56  
 
 57  
     /**
 58  
      * Adds a tagfield to the structure.<br>
 59  
      * <p/>
 60  
      * <p>It is not recommended to use this method for normal use of the
 61  
      * audiolibrary. The developer will circumvent the underlying
 62  
      * implementation. For example, if one adds a field with the field id
 63  
      * &quot;TALB&quot; for an mp3 file, and the given {@link org.jaudiotagger.tag.TagField}
 64  
      * implementation does not return a text field compliant data with
 65  
      * {@link org.jaudiotagger.tag.TagField#getRawContent()} other software and the audio library
 66  
      * won't read the file correctly, if they do read it at all. <br>
 67  
      * So for short:<br>
 68  
      * <uil>
 69  
      * <li>The field is stored without validation</li>
 70  
      * <li>No conversion of data is perfomed</li>
 71  
      * </ul>
 72  
      *
 73  
      * @param field The field to add.
 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  
      * Adds an album to the tag.<br>
 89  
      *
 90  
      * @param album Album description
 91  
      */
 92  
     public void addAlbum(String album) throws FieldDataInvalidException
 93  
     {
 94  2
         tag.addAlbum(album);
 95  2
     }
 96  
 
 97  
     /**
 98  
      * Adds an artist to the tag.<br>
 99  
      *
 100  
      * @param artist Artist's name
 101  
      */
 102  
     public void addArtist(String artist) throws FieldDataInvalidException
 103  
     {
 104  1
         tag.addArtist(artist);
 105  1
     }
 106  
 
 107  
     /**
 108  
      * Adds a comment to the tag.<br>
 109  
      *
 110  
      * @param comment Comment.
 111  
      */
 112  
     public void addComment(String comment) throws FieldDataInvalidException
 113  
     {
 114  0
         tag.addComment(comment);
 115  0
     }
 116  
 
 117  
     /**
 118  
      * Adds a genre to the tag.<br>
 119  
      *
 120  
      * @param genre Genre
 121  
      */
 122  
     public void addGenre(String genre) throws FieldDataInvalidException
 123  
     {
 124  2
         tag.addGenre(genre);
 125  2
     }
 126  
 
 127  
     /**
 128  
      * Adds a title to the tag.<br>
 129  
      *
 130  
      * @param title Title
 131  
      */
 132  
     public void addTitle(String title) throws FieldDataInvalidException
 133  
     {
 134  2
         tag.addTitle(title);
 135  2
     }
 136  
 
 137  
     /**
 138  
      * Adds a track to the tag.<br>
 139  
      *
 140  
      * @param track Track
 141  
      */
 142  
     public void addTrack(String track) throws FieldDataInvalidException
 143  
     {
 144  2
         tag.addTrack(track);
 145  2
     }
 146  
 
 147  
     /**
 148  
      * Adds a year to the Tag.<br>
 149  
      *
 150  
      * @param year Year
 151  
      */
 152  
     public void addYear(String year) throws FieldDataInvalidException
 153  
     {
 154  2
         tag.addYear(year);
 155  2
     }
 156  
 
 157  
     /**
 158  
      * Returns a {@linkplain List list} of {@link TagField} objects whose &quot;{@linkplain TagField#getId() id}&quot;
 159  
      * is the specified one.<br>
 160  
      *
 161  
      * @param id The field id.
 162  
      * @return A list of {@link TagField} objects with the given &quot;id&quot;.
 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  
      * @return
 183  
      */
 184  
     public List<TagField> getAlbum()
 185  
     {
 186  1
         return tag.getAlbum();
 187  
     }
 188  
 
 189  
 
 190  
     /**
 191  
      * @return
 192  
      */
 193  
     public List<TagField> getArtist()
 194  
     {
 195  1
         return tag.getArtist();
 196  
     }
 197  
 
 198  
     /**
 199  
      * @return
 200  
      */
 201  
     public List<TagField> getComment()
 202  
     {
 203  0
         return tag.getComment();
 204  
     }
 205  
 
 206  
     /**
 207  
      * @return
 208  
      */
 209  
     public List<TagField> getGenre()
 210  
     {
 211  1
         return tag.getGenre();
 212  
     }
 213  
 
 214  
     /**
 215  
      * @return
 216  
      */
 217  
     public List<TagField> getTitle()
 218  
     {
 219  1
         return tag.getTitle();
 220  
     }
 221  
 
 222  
     /**
 223  
      * @return
 224  
      */
 225  
     public List<TagField> getTrack()
 226  
     {
 227  1
         return tag.getTrack();
 228  
     }
 229  
 
 230  
     /**
 231  
      * @return
 232  
      */
 233  
     public List<TagField> getYear()
 234  
     {
 235  1
         return tag.getYear();
 236  
     }
 237  
 
 238  
 
 239  
     /**
 240  
      * @return
 241  
      */
 242  
     public String getFirstAlbum()
 243  
     {
 244  4
         return tag.getFirstAlbum();
 245  
     }
 246  
 
 247  
     /**
 248  
      * @return
 249  
      */
 250  
     public String getFirstArtist()
 251  
     {
 252  3
         return tag.getFirstArtist();
 253  
     }
 254  
 
 255  
 
 256  
     /**
 257  
      * @return
 258  
      */
 259  
     public String getFirstComment()
 260  
     {
 261  1
         return tag.getFirstComment();
 262  
     }
 263  
 
 264  
 
 265  
     /**
 266  
      * @return
 267  
      */
 268  
     public String getFirstGenre()
 269  
     {
 270  2
         return tag.getFirstGenre();
 271  
     }
 272  
 
 273  
 
 274  
     /**
 275  
      * @return
 276  
      */
 277  
     public String getFirstTitle()
 278  
     {
 279  2
         return tag.getFirstTitle();
 280  
     }
 281  
 
 282  
 
 283  
     /**
 284  
      * @return
 285  
      */
 286  
     public String getFirstTrack()
 287  
     {
 288  2
         return tag.getFirstTrack();
 289  
     }
 290  
 
 291  
 
 292  
     /**
 293  
      * @return
 294  
      */
 295  
     public String getFirstYear()
 296  
     {
 297  2
         return tag.getFirstYear();
 298  
     }
 299  
 
 300  
 
 301  
     /**
 302  
      * Returns <code>true</code>, if at least one of the contained
 303  
      * {@linkplain TagField fields} is a common field ({@link TagField#isCommon()}).
 304  
      *
 305  
      * @return <code>true</code> if a {@linkplain TagField#isCommon() common}
 306  
      *         field is present.
 307  
      */
 308  
     public boolean hasCommonFields()
 309  
     {
 310  0
         return tag.hasCommonFields();
 311  
     }
 312  
 
 313  
     /**
 314  
      * Determines whether the tag has at least one field with the specified
 315  
      * &quot;id&quot;.
 316  
      *
 317  
      * @param id The field id to look for.
 318  
      * @return <code>true</code> if tag contains a {@link TagField} with the
 319  
      *         given {@linkplain TagField#getId() id}.
 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  
      * Determines whether the tag has no fields specified.<br>
 335  
      * <p/>
 336  
      * <p>If there are no images we return empty if either there is no VorbisTag or if there is a
 337  
      * VorbisTag but it is empty
 338  
      *
 339  
      * @return <code>true</code> if tag contains no field.
 340  
      */
 341  
     public boolean isEmpty()
 342  
     {
 343  11
         return (tag == null || tag.isEmpty()) && images.size() == 0;
 344  
     }
 345  
 
 346  
     /**
 347  
      * @param field
 348  
      * @throws FieldDataInvalidException
 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  
      * @param s
 371  
      * @throws FieldDataInvalidException
 372  
      */
 373  
     public void setAlbum(String s) throws FieldDataInvalidException
 374  
     {
 375  2
         tag.setAlbum(s);
 376  2
     }
 377  
 
 378  
 
 379  
     /**
 380  
      * @param s
 381  
      * @throws FieldDataInvalidException
 382  
      */
 383  
     public void setArtist(String s) throws FieldDataInvalidException
 384  
     {
 385  1
         tag.setArtist(s);
 386  1
     }
 387  
 
 388  
     /**
 389  
      * @param s
 390  
      * @throws FieldDataInvalidException
 391  
      */
 392  
     public void setComment(String s) throws FieldDataInvalidException
 393  
     {
 394  0
         tag.setComment(s);
 395  0
     }
 396  
 
 397  
 
 398  
     /**
 399  
      * @param s
 400  
      * @throws FieldDataInvalidException
 401  
      */
 402  
     public void setGenre(String s) throws FieldDataInvalidException
 403  
     {
 404  0
         tag.setGenre(s);
 405  0
     }
 406  
 
 407  
     /**
 408  
      * @param s
 409  
      * @throws FieldDataInvalidException
 410  
      */
 411  
     public void setTitle(String s) throws FieldDataInvalidException
 412  
     {
 413  0
         tag.setTitle(s);
 414  0
     }
 415  
 
 416  
     /**
 417  
      * @param s
 418  
      * @throws FieldDataInvalidException
 419  
      */
 420  
     public void setTrack(String s) throws FieldDataInvalidException
 421  
     {
 422  0
         tag.setTrack(s);
 423  0
     }
 424  
 
 425  
     /**
 426  
      * @param s
 427  
      * @throws FieldDataInvalidException
 428  
      */
 429  
     public void setYear(String s) throws FieldDataInvalidException
 430  
     {
 431  0
         tag.setYear(s);
 432  0
     }
 433  
 
 434  
 
 435  
     /**
 436  
      * Create a new TagField based on generic key
 437  
      * <p/>
 438  
      * <p>Only textual data supported at the moment. The genericKey will be mapped
 439  
      * to the correct implementation key and return a TagField.
 440  
      *
 441  
      * @param genericKey is the generic key
 442  
      * @param value      to store
 443  
      * @return
 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  
      * Retrieve the first value that exists for this key
 460  
      *
 461  
      * @param id
 462  
      * @return
 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  
      * Retrieve String value of first tagfield that exists for this key
 478  
      *
 479  
      * @param id
 480  
      * @return String value or empty string
 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  
      * Retrieve the first tagfield that exists for this key
 497  
      * <p/>
 498  
      * <p>Can be used to retrieve fields with any identifier, useful if the identifier is not within  the
 499  
      * jaudiotagger enum
 500  
      *
 501  
      * @param id audio specific key
 502  
      * @return tag field or null if doesnt exist
 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  
      * Delete any instance of tag fields with this key
 542  
      *
 543  
      * @param tagFieldKey
 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  
      * Iterator over all the fields within the tag, handle multiple fields with the same id
 559  
      *
 560  
      * @return iterator over whole list
 561  
      */
 562  
     //TODO add images to iterator
 563  
     public Iterator<TagField> getFields()
 564  
     {
 565  0
         return tag.getFields();
 566  
     }
 567  
 
 568  
     /**
 569  
      * Return the number of fields
 570  
      * <p/>
 571  
      * <p>Fields with the same identifiers are counted seperately
 572  
      * i.e two title fields would contribute two to the count
 573  
      *
 574  
      * @return total number of fields
 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  
      * Returns a {@linkplain List list} of {@link TagField} objects whose &quot;{@linkplain TagField#getId() id}&quot;
 588  
      * is the specified one.<br>
 589  
      *
 590  
      * @param id The field id.
 591  
      * @return A list of {@link TagField} objects with the given &quot;id&quot;.
 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  
      * Create Artwork when have the raw image data
 613  
      *
 614  
      * @param imageData
 615  
      * @param pictureType
 616  
      * @param mimeType
 617  
      * @param description
 618  
      * @param width
 619  
      * @param height
 620  
      * @param colourDepth
 621  
      * @param indexedColouredCount
 622  
      * @return
 623  
      * @throws FieldDataInvalidException
 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  
      * Create Artwork when  have the bufferedimage
 632  
      *
 633  
      * @param pictureType
 634  
      * @param mimeType
 635  
      * @param description
 636  
      * @param colourDepth
 637  
      * @param indexedColouredCount
 638  
      * @return
 639  
      * @throws FieldDataInvalidException
 640  
      */
 641  
     public TagField createArtworkField(BufferedImage bi, int pictureType, String mimeType, String description, int colourDepth, int indexedColouredCount) throws FieldDataInvalidException
 642  
     {
 643  
         //Convert to byte array
 644  
         try
 645  
         {
 646  1
             final ByteArrayOutputStream output = new ByteArrayOutputStream();
 647  1
             ImageIO.write(bi, ImageFormats.getFormatForMimeType(mimeType), new DataOutputStream(output));
 648  
 
 649  
             //Add to image list
 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  
      * Create Link to Image File, not recommended because if either flac or image file is moved link
 660  
      * will be broken.
 661  
      */
 662  
     public TagField createLinkedArtworkField(String url)
 663  
     {
 664  
         //Add to image list
 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  
      * Create artwork field
 670  
      *
 671  
      * @return
 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  
      * Create field and then set within tag itself
 712  
      *
 713  
      * @param artwork
 714  
      * @throws FieldDataInvalidException
 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  
 }