Coverage Report - org.jaudiotagger.tag.vorbiscomment.VorbisCommentTag
 
Classes in this File Line Coverage Branch Coverage Complexity
VorbisCommentTag
83%
130/157
52%
25/48
0
 
 1  
 /*
 2  
  * Entagged Audio Tag library
 3  
  * Copyright (c) 2003-2005 Rapha�l Slinckx <raphael@slinckx.net>
 4  
  * 
 5  
  * This library is free software; you can redistribute it and/or
 6  
  * modify it under the terms of the GNU Lesser General Public
 7  
  * License as published by the Free Software Foundation; either
 8  
  * version 2.1 of the License, or (at your option) any later version.
 9  
  *  
 10  
  * This library is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  * Lesser General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU Lesser General Public
 16  
  * License along with this library; if not, write to the Free Software
 17  
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.jaudiotagger.tag.vorbiscomment;
 20  
 
 21  
 import org.jaudiotagger.audio.generic.AbstractTag;
 22  
 import org.jaudiotagger.audio.ogg.util.VorbisHeader;
 23  
 import org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture;
 24  
 import org.jaudiotagger.logging.ErrorMessage;
 25  
 import org.jaudiotagger.tag.KeyNotFoundException;
 26  
 import org.jaudiotagger.tag.TagField;
 27  
 import org.jaudiotagger.tag.TagFieldKey;
 28  
 import org.jaudiotagger.tag.FieldDataInvalidException;
 29  
 import org.jaudiotagger.tag.mp4.field.Mp4TagCoverField;
 30  
 import org.jaudiotagger.tag.datatype.Artwork;
 31  
 import static org.jaudiotagger.tag.vorbiscomment.VorbisCommentFieldKey.*;
 32  
 import org.jaudiotagger.tag.vorbiscomment.util.Base64Coder;
 33  
 
 34  
 import java.util.EnumMap;
 35  
 import java.util.List;
 36  
 import java.util.ArrayList;
 37  
 
 38  
 /**
 39  
  * This is the logical representation of  Vorbis Comment Data
 40  
  */
 41  
 public class VorbisCommentTag extends AbstractTag
 42  
 {
 43  10
     private static EnumMap<TagFieldKey, VorbisCommentFieldKey> tagFieldToOggField = new EnumMap<TagFieldKey, VorbisCommentFieldKey>(TagFieldKey.class);
 44  
 
 45  
     static
 46  
     {
 47  10
         tagFieldToOggField.put(TagFieldKey.ARTIST, VorbisCommentFieldKey.ARTIST);
 48  10
         tagFieldToOggField.put(TagFieldKey.ALBUM, VorbisCommentFieldKey.ALBUM);
 49  10
         tagFieldToOggField.put(TagFieldKey.TITLE, VorbisCommentFieldKey.TITLE);
 50  10
         tagFieldToOggField.put(TagFieldKey.TRACK, VorbisCommentFieldKey.TRACKNUMBER);
 51  10
         tagFieldToOggField.put(TagFieldKey.YEAR, VorbisCommentFieldKey.DATE);
 52  10
         tagFieldToOggField.put(TagFieldKey.GENRE, VorbisCommentFieldKey.GENRE);
 53  10
         tagFieldToOggField.put(TagFieldKey.COMMENT, VorbisCommentFieldKey.COMMENT);
 54  10
         tagFieldToOggField.put(TagFieldKey.ALBUM_ARTIST, VorbisCommentFieldKey.ALBUMARTIST);
 55  10
         tagFieldToOggField.put(TagFieldKey.COMPOSER, VorbisCommentFieldKey.COMPOSER);
 56  10
         tagFieldToOggField.put(TagFieldKey.GROUPING, VorbisCommentFieldKey.GROUPING);
 57  10
         tagFieldToOggField.put(TagFieldKey.DISC_NO, VorbisCommentFieldKey.DISCNUMBER);
 58  10
         tagFieldToOggField.put(TagFieldKey.BPM, VorbisCommentFieldKey.BPM);
 59  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_ARTISTID, VorbisCommentFieldKey.MUSICBRAINZ_ARTISTID);
 60  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_RELEASEID, VorbisCommentFieldKey.MUSICBRAINZ_ALBUMID);
 61  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_RELEASEARTISTID, VorbisCommentFieldKey.MUSICBRAINZ_ALBUMARTISTID);
 62  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_TRACK_ID, VorbisCommentFieldKey.MUSICBRAINZ_TRACKID);
 63  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_DISC_ID, VorbisCommentFieldKey.MUSICBRAINZ_DISCID);
 64  10
         tagFieldToOggField.put(TagFieldKey.MUSICIP_ID, VorbisCommentFieldKey.MUSICIP_PUID);
 65  10
         tagFieldToOggField.put(TagFieldKey.AMAZON_ID, VorbisCommentFieldKey.ASIN);
 66  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_RELEASE_STATUS, VorbisCommentFieldKey.MUSICBRAINZ_ALBUMSTATUS);
 67  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_RELEASE_TYPE, VorbisCommentFieldKey.MUSICBRAINZ_ALBUMTYPE);
 68  10
         tagFieldToOggField.put(TagFieldKey.MUSICBRAINZ_RELEASE_COUNTRY, VorbisCommentFieldKey.RELEASECOUNTRY);
 69  10
         tagFieldToOggField.put(TagFieldKey.LYRICS, VorbisCommentFieldKey.LYRICS);
 70  10
         tagFieldToOggField.put(TagFieldKey.IS_COMPILATION, VorbisCommentFieldKey.COMPILATION);
 71  10
         tagFieldToOggField.put(TagFieldKey.ARTIST_SORT, VorbisCommentFieldKey.ARTISTSORT);
 72  10
         tagFieldToOggField.put(TagFieldKey.ALBUM_ARTIST_SORT, VorbisCommentFieldKey.ALBUMARTISTSORT);
 73  10
         tagFieldToOggField.put(TagFieldKey.ALBUM_SORT, VorbisCommentFieldKey.ALBUMSORT);
 74  10
         tagFieldToOggField.put(TagFieldKey.TITLE_SORT, VorbisCommentFieldKey.TITLESORT);
 75  10
         tagFieldToOggField.put(TagFieldKey.COMPOSER_SORT, VorbisCommentFieldKey.COMPOSERSORT);
 76  10
         tagFieldToOggField.put(TagFieldKey.ENCODER, VorbisCommentFieldKey.VENDOR);     //Known as vendor in VorbisComment
 77  10
         tagFieldToOggField.put(TagFieldKey.ISRC, VorbisCommentFieldKey.ISRC);
 78  10
         tagFieldToOggField.put(TagFieldKey.BARCODE, VorbisCommentFieldKey.BARCODE);
 79  10
         tagFieldToOggField.put(TagFieldKey.CATALOG_NO, VorbisCommentFieldKey.CATALOGNUMBER);
 80  10
         tagFieldToOggField.put(TagFieldKey.RECORD_LABEL, VorbisCommentFieldKey.LABEL);
 81  10
         tagFieldToOggField.put(TagFieldKey.LYRICIST, VorbisCommentFieldKey.LYRICIST);
 82  10
         tagFieldToOggField.put(TagFieldKey.CONDUCTOR, VorbisCommentFieldKey.CONDUCTOR);
 83  10
         tagFieldToOggField.put(TagFieldKey.REMIXER, VorbisCommentFieldKey.REMIXER);
 84  10
         tagFieldToOggField.put(TagFieldKey.MOOD, VorbisCommentFieldKey.MOOD);
 85  10
         tagFieldToOggField.put(TagFieldKey.MEDIA, VorbisCommentFieldKey.MEDIA);
 86  10
         tagFieldToOggField.put(TagFieldKey.URL_DISCOGS_ARTIST_SITE, VorbisCommentFieldKey.URL_DISCOGS_ARTIST_SITE);
 87  10
         tagFieldToOggField.put(TagFieldKey.URL_DISCOGS_RELEASE_SITE, VorbisCommentFieldKey.URL_DISCOGS_RELEASE_SITE);
 88  10
         tagFieldToOggField.put(TagFieldKey.URL_OFFICIAL_ARTIST_SITE, VorbisCommentFieldKey.URL_OFFICIAL_ARTIST_SITE);
 89  10
         tagFieldToOggField.put(TagFieldKey.URL_OFFICIAL_RELEASE_SITE, VorbisCommentFieldKey.URL_OFFICIAL_RELEASE_SITE);
 90  10
         tagFieldToOggField.put(TagFieldKey.URL_WIKIPEDIA_ARTIST_SITE, VorbisCommentFieldKey.URL_WIKIPEDIA_ARTIST_SITE);
 91  10
         tagFieldToOggField.put(TagFieldKey.URL_WIKIPEDIA_RELEASE_SITE, VorbisCommentFieldKey.URL_WIKIPEDIA_RELEASE_SITE);
 92  10
         tagFieldToOggField.put(TagFieldKey.LANGUAGE, VorbisCommentFieldKey.LANGUAGE);
 93  10
         tagFieldToOggField.put(TagFieldKey.KEY, VorbisCommentFieldKey.KEY);
 94  10
     }
 95  
 
 96  
     //This is the vendor string that will be written if no other is supplied. Should be the name of the software
 97  
     //that actually encoded the file in the first place.
 98  
     public static final String DEFAULT_VENDOR = "jaudiotagger";
 99  
 
 100  
     /**
 101  
      * Only used within Package, hidden because it doesnt set Vendor
 102  
      * which should be done when created by end user
 103  
      */
 104  
     VorbisCommentTag()
 105  72
     {
 106  
 
 107  72
     }
 108  
 
 109  
     /**
 110  
      * Use to construct a new tag properly initialized
 111  
      *
 112  
      * @return
 113  
      */
 114  
     public static VorbisCommentTag createNewTag()
 115  
     {
 116  6
         VorbisCommentTag tag = new VorbisCommentTag();
 117  6
         tag.setVendor(DEFAULT_VENDOR);
 118  6
         return tag;
 119  
     }
 120  
 
 121  
     public TagField createAlbumField(String content)
 122  
     {
 123  8
         if (content == null)
 124  
         {
 125  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 126  
         }
 127  8
         return new VorbisCommentTagField(getAlbumId(), content);
 128  
     }
 129  
 
 130  
     public TagField createArtistField(String content)
 131  
     {
 132  3
         if (content == null)
 133  
         {
 134  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 135  
         }
 136  3
         return new VorbisCommentTagField(getArtistId(), content);
 137  
     }
 138  
 
 139  
     public TagField createCommentField(String content)
 140  
     {
 141  1
         if (content == null)
 142  
         {
 143  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 144  
         }
 145  1
         return new VorbisCommentTagField(getCommentId(), content);
 146  
     }
 147  
 
 148  
     public TagField createGenreField(String content)
 149  
     {
 150  3
         if (content == null)
 151  
         {
 152  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 153  
         }
 154  3
         return new VorbisCommentTagField(getGenreId(), content);
 155  
     }
 156  
 
 157  
     public TagField createTitleField(String content)
 158  
     {
 159  6
         if (content == null)
 160  
         {
 161  1
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 162  
         }
 163  5
         return new VorbisCommentTagField(getTitleId(), content);
 164  
     }
 165  
 
 166  
     public TagField createTrackField(String content)
 167  
     {
 168  3
         if (content == null)
 169  
         {
 170  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 171  
         }
 172  3
         return new VorbisCommentTagField(getTrackId(), content);
 173  
     }
 174  
 
 175  
     public TagField createYearField(String content)
 176  
     {
 177  4
         if (content == null)
 178  
         {
 179  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 180  
         }
 181  4
         return new VorbisCommentTagField(getYearId(), content);
 182  
     }
 183  
 
 184  
     protected String getAlbumId()
 185  
     {
 186  17
         return ALBUM.name();
 187  
     }
 188  
 
 189  
     protected String getArtistId()
 190  
     {
 191  8
         return ARTIST.name();
 192  
     }
 193  
 
 194  
     protected String getCommentId()
 195  
     {
 196  3
         return COMMENT.name();
 197  
     }
 198  
 
 199  
     protected String getGenreId()
 200  
     {
 201  7
         return GENRE.name();
 202  
     }
 203  
 
 204  
     protected String getTitleId()
 205  
     {
 206  10
         return TITLE.name();
 207  
     }
 208  
 
 209  
     protected String getTrackId()
 210  
     {
 211  7
         return TRACKNUMBER.name();
 212  
     }
 213  
 
 214  
     /**
 215  
      * @return the vendor, generically known as the encoder
 216  
      */
 217  
     public String getVendor()
 218  
     {
 219  47
         return getFirst(VENDOR.name());
 220  
     }
 221  
 
 222  
     protected String getYearId()
 223  
     {
 224  8
         return DATE.toString();
 225  
     }
 226  
 
 227  
     /**
 228  
      * Set the vendor, known as the encoder  generally
 229  
      * <p/>
 230  
      * We dont want this to be blank, when written to file this field is written to a different location
 231  
      * to all other fields but user of library can just reat it as another field
 232  
      *
 233  
      * @param vendor
 234  
      */
 235  
     public void setVendor(String vendor)
 236  
     {
 237  73
         if (vendor == null)
 238  
         {
 239  0
             vendor = DEFAULT_VENDOR;
 240  
         }
 241  73
         super.set(new VorbisCommentTagField(VENDOR.name(), vendor));
 242  73
     }
 243  
 
 244  
     protected boolean isAllowedEncoding(String enc)
 245  
     {
 246  0
         return enc.equals(VorbisHeader.CHARSET_UTF_8);
 247  
     }
 248  
 
 249  
     public String toString()
 250  
     {
 251  0
         return "OGG " + super.toString();
 252  
     }
 253  
 
 254  
     /**
 255  
      * Create Tag Field using generic key
 256  
      */
 257  
     @Override
 258  
     public TagField createTagField(TagFieldKey genericKey, String value) throws KeyNotFoundException
 259  
     {
 260  24
         if (genericKey == null)
 261  
         {
 262  0
             throw new KeyNotFoundException();
 263  
         }
 264  24
         return createTagField(tagFieldToOggField.get(genericKey), value);
 265  
     }
 266  
 
 267  
     /**
 268  
      * Create Tag Field using ogg key
 269  
      *
 270  
      * @param vorbisCommentFieldKey
 271  
      * @param value
 272  
      * @return
 273  
      */
 274  
     public TagField createTagField(VorbisCommentFieldKey vorbisCommentFieldKey, String value) throws KeyNotFoundException
 275  
     {
 276  38
         if (value == null)
 277  
         {
 278  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 279  
         }
 280  38
         if (vorbisCommentFieldKey == null)
 281  
         {
 282  0
             throw new KeyNotFoundException();
 283  
         }
 284  38
         return new VorbisCommentTagField(vorbisCommentFieldKey.name(), value);
 285  
     }
 286  
 
 287  
     /**
 288  
      * Create Tag Field using ogg key
 289  
      * <p/>
 290  
      * This method is provided to allow you to create key of any value because VorbisComment allows
 291  
      * arbitary keys.
 292  
      *
 293  
      * @param vorbisCommentFieldKey
 294  
      * @param value
 295  
      * @return
 296  
      */
 297  
     public TagField createTagField(String vorbisCommentFieldKey, String value)
 298  
     {
 299  1
         if (value == null)
 300  
         {
 301  0
             throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
 302  
         }
 303  1
         return new VorbisCommentTagField(vorbisCommentFieldKey, value);
 304  
     }
 305  
 
 306  
     /**
 307  
      * Maps the generic key to the ogg key and return the list of values for this field
 308  
      *
 309  
      * @param genericKey
 310  
      */
 311  
     @Override
 312  
     public List<TagField> get(TagFieldKey genericKey) throws KeyNotFoundException
 313  
     {
 314  2
         VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
 315  2
         if (vorbisCommentFieldKey == null)
 316  
         {
 317  0
             throw new KeyNotFoundException();
 318  
         }
 319  2
         return super.get(vorbisCommentFieldKey.name());
 320  
     }
 321  
 
 322  
     /**
 323  
      * Retrieve the first value that exists for this vorbis comment key
 324  
      *
 325  
      * @param vorbisCommentKey
 326  
      * @return
 327  
      */
 328  
     public List<TagField> get(VorbisCommentFieldKey vorbisCommentKey) throws KeyNotFoundException
 329  
     {
 330  11
         if (vorbisCommentKey == null)
 331  
         {
 332  0
             throw new KeyNotFoundException();
 333  
         }
 334  11
         return super.get(vorbisCommentKey.name());
 335  
     }
 336  
 
 337  
     /**
 338  
      * Retrieve the first value that exists for this generic key
 339  
      *
 340  
      * @param genericKey
 341  
      * @return
 342  
      */
 343  
     public String getFirst(TagFieldKey genericKey) throws KeyNotFoundException
 344  
     {
 345  42
         VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
 346  42
         if (vorbisCommentFieldKey == null)
 347  
         {
 348  0
             throw new KeyNotFoundException();
 349  
         }
 350  42
         return super.getFirst(vorbisCommentFieldKey.name());
 351  
     }
 352  
 
 353  
     /**
 354  
      * Retrieve the first value that exists for this vorbis comment key
 355  
      *
 356  
      * @param vorbisCommentKey
 357  
      * @return
 358  
      */
 359  
     public String getFirst(VorbisCommentFieldKey vorbisCommentKey) throws KeyNotFoundException
 360  
     {
 361  63
         if (vorbisCommentKey == null)
 362  
         {
 363  0
             throw new KeyNotFoundException();
 364  
         }
 365  63
         return super.getFirst(vorbisCommentKey.name());
 366  
     }
 367  
 
 368  
     /**
 369  
      * Delete fields with this generic key
 370  
      *
 371  
      * @param genericKey
 372  
      */
 373  
     public void deleteTagField(TagFieldKey genericKey) throws KeyNotFoundException
 374  
     {
 375  0
         if (genericKey == null)
 376  
         {
 377  0
             throw new KeyNotFoundException();
 378  
         }
 379  0
         VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
 380  0
         deleteTagField(vorbisCommentFieldKey);
 381  0
     }
 382  
 
 383  
     /**
 384  
      * Delete fields with this vorbisCommentFieldKey
 385  
      *
 386  
      * @param vorbisCommentFieldKey
 387  
      */
 388  
     public void deleteTagField(VorbisCommentFieldKey vorbisCommentFieldKey) throws KeyNotFoundException
 389  
     {
 390  7
         if (vorbisCommentFieldKey == null)
 391  
         {
 392  0
             throw new KeyNotFoundException();
 393  
         }
 394  7
         super.deleteField(vorbisCommentFieldKey.name());
 395  7
     }
 396  
 
 397  
     /**
 398  
      * Create artwork field
 399  
      * <p/>
 400  
      * Actually create two fields , the data field and the mimetype
 401  
      *
 402  
      * @param data     raw image data
 403  
      * @param mimeType mimeType of data
 404  
      *                 <p/>
 405  
      *                 TODO could possibly work out mimetype from data, but unlike mp4 there is nothing to restrict to only png
 406  
      *                 or jpeg images
 407  
      * @return
 408  
      */
 409  
     public void setArtworkField(byte[] data, String mimeType)
 410  
     {
 411  1
         char[] testdata = Base64Coder.encode(data);
 412  1
         String base64image = new String(testdata);
 413  1
         VorbisCommentTagField dataField = new VorbisCommentTagField(VorbisCommentFieldKey.COVERART.name(), base64image);
 414  1
         VorbisCommentTagField mimeField = new VorbisCommentTagField(VorbisCommentFieldKey.COVERARTMIME.name(), mimeType);
 415  
 
 416  1
         set(dataField);
 417  1
         set(mimeField);
 418  
 
 419  1
     }
 420  
 
 421  
     /**
 422  
      * Retrieve artwork raw data
 423  
      *
 424  
      * @return
 425  
      */
 426  
     public byte[] getArtworkBinaryData()
 427  
     {
 428  19
         String base64data = this.getFirst(VorbisCommentFieldKey.COVERART);
 429  19
         byte[] rawdata = Base64Coder.decode(base64data.toCharArray());
 430  19
         return rawdata;
 431  
     }
 432  
 
 433  
     /**
 434  
      * @return mimetype
 435  
      */
 436  
     public String getArtworkMimeType()
 437  
     {
 438  7
         return this.getFirst(VorbisCommentFieldKey.COVERARTMIME);
 439  
     }
 440  
 
 441  
     /**
 442  
      * Is this tag empty
 443  
      * <p/>
 444  
      * <p>Overridden because check for size of one because there is always a vendor tag unless just
 445  
      * created an empty vorbis tag as part of flac tag in which case size could be zero
 446  
      *
 447  
      * @see org.jaudiotagger.tag.Tag#isEmpty()
 448  
      */
 449  
     public boolean isEmpty()
 450  
     {
 451  33
         return fields.size() <= 1;
 452  
     }
 453  
 
 454  
     /**
 455  
      * Add Field
 456  
      * <p/>
 457  
      * <p>Overidden because there can only be one vendor set
 458  
      *
 459  
      * @param field
 460  
      */
 461  
     public void add(TagField field)
 462  
     {
 463  342
         if (field.getId().equals(VorbisCommentFieldKey.VENDOR.name()))
 464  
         {
 465  1
             super.set(field);
 466  
         }
 467  
         else
 468  
         {
 469  341
             super.add(field);
 470  
         }
 471  342
     }
 472  
 
 473  
      public TagField getFirstField(TagFieldKey genericKey) throws KeyNotFoundException
 474  
     {
 475  0
         if (genericKey == null)
 476  
         {
 477  0
             throw new KeyNotFoundException();
 478  
         }
 479  0
         return getFirstField(tagFieldToOggField.get(genericKey).name());
 480  
     }
 481  
 
 482  
     public List<Artwork> getArtworkList()
 483  
     {
 484  6
         List<Artwork>  artworkList  = new ArrayList<Artwork>(1);
 485  
 
 486  6
         if(getArtworkBinaryData()!=null & getArtworkBinaryData().length>0)
 487  
         {
 488  6
             Artwork artwork=new Artwork();
 489  6
             artwork.setMimeType(getArtworkMimeType());
 490  6
             artwork.setBinaryData(getArtworkBinaryData());
 491  6
             artworkList.add(artwork);
 492  
         }
 493  6
         return artworkList;
 494  
     }
 495  
 
 496  
     /**
 497  
      * Create artwork field
 498  
      *
 499  
      * Not supported because reuire two fields to be created use
 500  
      * @return
 501  
      */
 502  
     public TagField createArtworkField(Artwork artwork) throws FieldDataInvalidException
 503  
     {
 504  0
         throw new UnsupportedOperationException("Please use createAndSetArtworkField instead");       
 505  
     }
 506  
 
 507  
     /**
 508  
      * Create artwork field
 509  
      *
 510  
      * Actually sets two fields
 511  
      *
 512  
      * @return
 513  
      */
 514  
     @Override
 515  
     public void createAndSetArtworkField(Artwork artwork) throws FieldDataInvalidException
 516  
     {
 517  1
         char[] testdata = Base64Coder.encode(artwork.getBinaryData());
 518  1
                   String base64image = new String(testdata);
 519  1
                TagField imageTagField  = createTagField(VorbisCommentFieldKey.COVERART, base64image);
 520  1
                    TagField imageTypeField = createTagField(VorbisCommentFieldKey.COVERARTMIME, artwork.getMimeType());
 521  
 
 522  1
         this.set(imageTagField);
 523  1
         this.set(imageTypeField);
 524  1
     }
 525  
 }
 526