@@ -402,7 +402,9 @@ public String getTrack() {
402402
403403 @ Override
404404 public void setTrack (String track ) {
405- if (track != null && track .length () > 0 ) {
405+ if (track == null || track .isEmpty ()) {
406+ clearFrameSet (ID_TRACK );
407+ } else {
406408 invalidateDataLength ();
407409 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (track ));
408410 addFrame (createFrame (ID_TRACK , frameData .toBytes ()), true );
@@ -418,7 +420,9 @@ public String getPartOfSet() {
418420
419421 @ Override
420422 public void setPartOfSet (String partOfSet ) {
421- if (partOfSet != null && partOfSet .length () > 0 ) {
423+ if (partOfSet == null || partOfSet .isEmpty ()) {
424+ clearFrameSet (ID_PART_OF_SET );
425+ } else {
422426 invalidateDataLength ();
423427 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (partOfSet ));
424428 addFrame (createFrame (ID_PART_OF_SET , frameData .toBytes ()), true );
@@ -449,7 +453,9 @@ public String getGrouping() {
449453
450454 @ Override
451455 public void setGrouping (String grouping ) {
452- if (grouping != null && grouping .length () > 0 ) {
456+ if (grouping == null || grouping .isEmpty ()) {
457+ clearFrameSet (ID_GROUPING );
458+ } else {
453459 invalidateDataLength ();
454460 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (grouping ));
455461 addFrame (createFrame (ID_GROUPING , frameData .toBytes ()), true );
@@ -465,7 +471,9 @@ public String getArtist() {
465471
466472 @ Override
467473 public void setArtist (String artist ) {
468- if (artist != null && artist .length () > 0 ) {
474+ if (artist == null || artist .isEmpty ()) {
475+ clearFrameSet (ID_ARTIST );
476+ } else {
469477 invalidateDataLength ();
470478 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (artist ));
471479 addFrame (createFrame (ID_ARTIST , frameData .toBytes ()), true );
@@ -481,7 +489,9 @@ public String getAlbumArtist() {
481489
482490 @ Override
483491 public void setAlbumArtist (String albumArtist ) {
484- if (albumArtist != null && albumArtist .length () > 0 ) {
492+ if (albumArtist == null || albumArtist .isEmpty ()) {
493+ clearFrameSet (ID_ALBUM_ARTIST );
494+ } else {
485495 invalidateDataLength ();
486496 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (albumArtist ));
487497 addFrame (createFrame (ID_ALBUM_ARTIST , frameData .toBytes ()), true );
@@ -497,7 +507,9 @@ public String getTitle() {
497507
498508 @ Override
499509 public void setTitle (String title ) {
500- if (title != null && title .length () > 0 ) {
510+ if (title == null || title .isEmpty ()) {
511+ clearFrameSet (ID_TITLE );
512+ } else {
501513 invalidateDataLength ();
502514 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (title ));
503515 addFrame (createFrame (ID_TITLE , frameData .toBytes ()), true );
@@ -513,7 +525,9 @@ public String getAlbum() {
513525
514526 @ Override
515527 public void setAlbum (String album ) {
516- if (album != null && album .length () > 0 ) {
528+ if (album == null || album .isEmpty ()) {
529+ clearFrameSet (ID_ALBUM );
530+ } else {
517531 invalidateDataLength ();
518532 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (album ));
519533 addFrame (createFrame (ID_ALBUM , frameData .toBytes ()), true );
@@ -529,7 +543,9 @@ public String getYear() {
529543
530544 @ Override
531545 public void setYear (String year ) {
532- if (year != null && year .length () > 0 ) {
546+ if (year == null || year .isEmpty ()) {
547+ clearFrameSet (ID_YEAR );
548+ } else {
533549 invalidateDataLength ();
534550 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (year ));
535551 addFrame (createFrame (ID_YEAR , frameData .toBytes ()), true );
@@ -545,7 +561,9 @@ public String getDate() {
545561
546562 @ Override
547563 public void setDate (String date ) {
548- if (date != null && date .length () > 0 ) {
564+ if (date == null || date .isEmpty ()) {
565+ clearFrameSet (ID_DATE );
566+ } else {
549567 invalidateDataLength ();
550568 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (date ));
551569 addFrame (createFrame (ID_DATE , frameData .toBytes ()), true );
@@ -621,7 +639,9 @@ public String getKey() {
621639
622640 @ Override
623641 public void setKey (String key ) {
624- if (key != null && key .length () > 0 ) {
642+ if (key == null || key .isEmpty ()) {
643+ clearFrameSet (ID_KEY );
644+ } else {
625645 invalidateDataLength ();
626646 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (key ));
627647 addFrame (createFrame (ID_KEY , frameData .toBytes ()), true );
@@ -695,7 +715,9 @@ public String getComment() {
695715
696716 @ Override
697717 public void setComment (String comment ) {
698- if (comment != null && comment .length () > 0 ) {
718+ if (comment == null || comment .isEmpty ()) {
719+ clearFrameSet (ID_COMMENT );
720+ } else {
699721 invalidateDataLength ();
700722 ID3v2CommentFrameData frameData = new ID3v2CommentFrameData (useFrameUnsynchronisation (), "eng" , null , new EncodedText (comment ));
701723 addFrame (createFrame (ID_COMMENT , frameData .toBytes ()), true );
@@ -711,7 +733,9 @@ public String getItunesComment() {
711733
712734 @ Override
713735 public void setItunesComment (String itunesComment ) {
714- if (itunesComment != null && itunesComment .length () > 0 ) {
736+ if (itunesComment == null || itunesComment .isEmpty ()) {
737+ clearFrameSet (ID_COMMENT );
738+ } else {
715739 invalidateDataLength ();
716740 ID3v2CommentFrameData frameData = new ID3v2CommentFrameData (useFrameUnsynchronisation (), "eng" , new EncodedText (ITUNES_COMMENT_DESCRIPTION ), new EncodedText (itunesComment ));
717741 addFrame (createFrame (ID_COMMENT , frameData .toBytes ()), true );
@@ -752,7 +776,9 @@ public String getLyrics() {
752776
753777 @ Override
754778 public void setLyrics (String lyrics ) {
755- if (lyrics != null && lyrics .length () > 0 ) {
779+ if (lyrics == null || lyrics .isEmpty ()) {
780+ clearFrameSet (ID_TEXT_LYRICS );
781+ } else {
756782 invalidateDataLength ();
757783 ID3v2CommentFrameData frameData = new ID3v2CommentFrameData (useFrameUnsynchronisation (), "eng" , null , new EncodedText (lyrics ));
758784 addFrame (createFrame (ID_TEXT_LYRICS , frameData .toBytes ()), true );
@@ -768,7 +794,9 @@ public String getComposer() {
768794
769795 @ Override
770796 public void setComposer (String composer ) {
771- if (composer != null && composer .length () > 0 ) {
797+ if (composer == null || composer .isEmpty ()) {
798+ clearFrameSet (ID_COMPOSER );
799+ } else {
772800 invalidateDataLength ();
773801 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (composer ));
774802 addFrame (createFrame (ID_COMPOSER , frameData .toBytes ()), true );
@@ -784,7 +812,9 @@ public String getPublisher() {
784812
785813 @ Override
786814 public void setPublisher (String publisher ) {
787- if (publisher != null && publisher .length () > 0 ) {
815+ if (publisher == null || publisher .isEmpty ()) {
816+ clearFrameSet (ID_PUBLISHER );
817+ } else {
788818 invalidateDataLength ();
789819 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (publisher ));
790820 addFrame (createFrame (ID_PUBLISHER , frameData .toBytes ()), true );
@@ -800,7 +830,9 @@ public String getOriginalArtist() {
800830
801831 @ Override
802832 public void setOriginalArtist (String originalArtist ) {
803- if (originalArtist != null && originalArtist .length () > 0 ) {
833+ if (originalArtist == null || originalArtist .isEmpty ()) {
834+ clearFrameSet (ID_ORIGINAL_ARTIST );
835+ } else {
804836 invalidateDataLength ();
805837 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (originalArtist ));
806838 addFrame (createFrame (ID_ORIGINAL_ARTIST , frameData .toBytes ()), true );
@@ -816,7 +848,9 @@ public String getCopyright() {
816848
817849 @ Override
818850 public void setCopyright (String copyright ) {
819- if (copyright != null && copyright .length () > 0 ) {
851+ if (copyright == null || copyright .isEmpty ()) {
852+ clearFrameSet (ID_COPYRIGHT );
853+ } else {
820854 invalidateDataLength ();
821855 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (copyright ));
822856 addFrame (createFrame (ID_COPYRIGHT , frameData .toBytes ()), true );
@@ -832,7 +866,9 @@ public String getArtistUrl() {
832866
833867 @ Override
834868 public void setArtistUrl (String url ) {
835- if (url != null && url .length () > 0 ) {
869+ if (url == null || url .isEmpty ()) {
870+ clearFrameSet (ID_ARTIST_URL );
871+ } else {
836872 invalidateDataLength ();
837873 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
838874 addFrame (createFrame (ID_ARTIST_URL , frameData .toBytes ()), true );
@@ -848,7 +884,9 @@ public String getCommercialUrl() {
848884
849885 @ Override
850886 public void setCommercialUrl (String url ) {
851- if (url != null && url .length () > 0 ) {
887+ if (url == null || url .isEmpty ()) {
888+ clearFrameSet (ID_COMMERCIAL_URL );
889+ } else {
852890 invalidateDataLength ();
853891 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
854892 addFrame (createFrame (ID_COMMERCIAL_URL , frameData .toBytes ()), true );
@@ -864,7 +902,9 @@ public String getCopyrightUrl() {
864902
865903 @ Override
866904 public void setCopyrightUrl (String url ) {
867- if (url != null && url .length () > 0 ) {
905+ if (url == null || url .isEmpty ()) {
906+ clearFrameSet (ID_COPYRIGHT_URL );
907+ } else {
868908 invalidateDataLength ();
869909 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
870910 addFrame (createFrame (ID_COPYRIGHT_URL , frameData .toBytes ()), true );
@@ -880,7 +920,9 @@ public String getAudiofileUrl() {
880920
881921 @ Override
882922 public void setAudiofileUrl (String url ) {
883- if (url != null && url .length () > 0 ) {
923+ if (url == null || url .isEmpty ()) {
924+ clearFrameSet (ID_AUDIOFILE_URL );
925+ } else {
884926 invalidateDataLength ();
885927 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
886928 addFrame (createFrame (ID_AUDIOFILE_URL , frameData .toBytes ()), true );
@@ -896,7 +938,9 @@ public String getAudioSourceUrl() {
896938
897939 @ Override
898940 public void setAudioSourceUrl (String url ) {
899- if (url != null && url .length () > 0 ) {
941+ if (url == null || url .isEmpty ()) {
942+ clearFrameSet (ID_AUDIOSOURCE_URL );
943+ } else {
900944 invalidateDataLength ();
901945 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
902946 addFrame (createFrame (ID_AUDIOSOURCE_URL , frameData .toBytes ()), true );
@@ -912,7 +956,9 @@ public String getRadiostationUrl() {
912956
913957 @ Override
914958 public void setRadiostationUrl (String url ) {
915- if (url != null && url .length () > 0 ) {
959+ if (url == null || url .isEmpty ()) {
960+ clearFrameSet (ID_RADIOSTATION_URL );
961+ } else {
916962 invalidateDataLength ();
917963 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
918964 addFrame (createFrame (ID_RADIOSTATION_URL , frameData .toBytes ()), true );
@@ -928,7 +974,9 @@ public String getPaymentUrl() {
928974
929975 @ Override
930976 public void setPaymentUrl (String url ) {
931- if (url != null && url .length () > 0 ) {
977+ if (url == null || url .isEmpty ()) {
978+ clearFrameSet (ID_PAYMENT_URL );
979+ } else {
932980 invalidateDataLength ();
933981 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
934982 addFrame (createFrame (ID_PAYMENT_URL , frameData .toBytes ()), true );
@@ -944,7 +992,9 @@ public String getPublisherUrl() {
944992
945993 @ Override
946994 public void setPublisherUrl (String url ) {
947- if (url != null && url .length () > 0 ) {
995+ if (url == null || url .isEmpty ()) {
996+ clearFrameSet (ID_PUBLISHER_URL );
997+ } else {
948998 invalidateDataLength ();
949999 ID3v2WWWFrameData frameData = new ID3v2WWWFrameData (useFrameUnsynchronisation (), url );
9501000 addFrame (createFrame (ID_PUBLISHER_URL , frameData .toBytes ()), true );
@@ -960,7 +1010,9 @@ public String getUrl() {
9601010
9611011 @ Override
9621012 public void setUrl (String url ) {
963- if (url != null && url .length () > 0 ) {
1013+ if (url == null || url .isEmpty ()) {
1014+ clearFrameSet (ID_URL );
1015+ } else {
9641016 invalidateDataLength ();
9651017 ID3v2UrlFrameData frameData = new ID3v2UrlFrameData (useFrameUnsynchronisation (), null , url );
9661018 addFrame (createFrame (ID_URL , frameData .toBytes ()), true );
@@ -978,7 +1030,9 @@ public ArrayList<ID3v2ChapterFrameData> getChapters() {
9781030
9791031 @ Override
9801032 public void setChapters (ArrayList <ID3v2ChapterFrameData > chapters ) {
981- if (chapters != null ) {
1033+ if (chapters == null ) {
1034+ clearFrameSet (ID_CHAPTER );
1035+ } else {
9821036 invalidateDataLength ();
9831037 boolean first = true ;
9841038 for (ID3v2ChapterFrameData chapter : chapters ) {
@@ -1003,7 +1057,9 @@ public ArrayList<ID3v2ChapterTOCFrameData> getChapterTOC() {
10031057
10041058 @ Override
10051059 public void setChapterTOC (ArrayList <ID3v2ChapterTOCFrameData > toc ) {
1006- if (toc != null ) {
1060+ if (toc == null ) {
1061+ clearFrameSet (ID_CHAPTER_TOC );
1062+ } else {
10071063 invalidateDataLength ();
10081064 boolean first = true ;
10091065 for (ID3v2ChapterTOCFrameData ct : toc ) {
@@ -1026,7 +1082,9 @@ public String getEncoder() {
10261082
10271083 @ Override
10281084 public void setEncoder (String encoder ) {
1029- if (encoder != null && encoder .length () > 0 ) {
1085+ if (encoder == null || encoder .isEmpty ()) {
1086+ clearFrameSet (ID_ENCODER );
1087+ } else {
10301088 invalidateDataLength ();
10311089 ID3v2TextFrameData frameData = new ID3v2TextFrameData (useFrameUnsynchronisation (), new EncodedText (encoder ));
10321090 addFrame (createFrame (ID_ENCODER , frameData .toBytes ()), true );
@@ -1047,7 +1105,9 @@ public void setAlbumImage(byte[] albumImage, String mimeType) {
10471105
10481106 @ Override
10491107 public void setAlbumImage (byte [] albumImage , String mimeType , byte imageType , String imageDescription ) {
1050- if (albumImage != null && albumImage .length > 0 && mimeType != null && mimeType .length () > 0 ) {
1108+ if (albumImage == null || albumImage .length == 0 || mimeType == null || mimeType .isEmpty ()) {
1109+ clearFrameSet (ID_IMAGE );
1110+ } else {
10511111 invalidateDataLength ();
10521112 ID3v2PictureFrameData frameData = new ID3v2PictureFrameData (
10531113 useFrameUnsynchronisation (), mimeType , imageType ,
0 commit comments