Coverage Report - org.jaudiotagger.audio.asf.tag.AsfFieldKey
 
Classes in this File Line Coverage Branch Coverage Complexity
AsfFieldKey
100%
70/70
100%
2/2
0
 
 1  
 package org.jaudiotagger.audio.asf.tag;
 2  
 
 3  
 import org.jaudiotagger.audio.asf.util.Utils;
 4  
 
 5  
 import org.jaudiotagger.tag.TagFieldKey;
 6  
 
 7  
 import java.util.HashMap;
 8  
 
 9  
 /**
 10  
  * Field keys which need to be mapped for ASF files, or only specified for ASF.
 11  
  * 
 12  
  * @author Christian Laireiter
 13  
  */
 14  23
 public enum AsfFieldKey
 15  
 {
 16  6
     ALBUM("WM/AlbumTitle", false),
 17  6
     ALBUM_ARTIST("WM/AlbumArtist", false),
 18  6
     ALBUM_ARTIST_SORT("WM/AlbumArtistSortOrder", false),
 19  6
     ALBUM_SORT("WM/AlbumSortOrder", false),
 20  6
     AMAZON_ID("ASIN", false),
 21  6
     ARTIST("Artist", false),
 22  6
     ARTIST_SORT("WM/ArtistSortOrder", false),
 23  6
     BARCODE("WM/Barcode",  false),
 24  6
     BPM("WM/BeatsPerMinute", false),
 25  6
     CATALOG_NO("WM/CatalogNo",  false),
 26  6
     COMMENT("WM/Comments", false),
 27  6
     COMPOSER("WM/Composer",  false),
 28  6
     COMPOSER_SORT("WM/ComposerSort",  false),
 29  6
     CONDUCTOR("WM/Conductor",  false),
 30  6
     COPYRIGHT("COPYRIGHT", false),
 31  6
     COVER_ART("WM/Picture",  false),
 32  6
     DISC_NO("WM/PartOfSet",  false),
 33  6
     ENCODER("WM/ToolName",  false),
 34  6
     GENRE("WM/Genre",  false),
 35  6
     GENRE_ID("WM/GenreID",false),
 36  6
     GROUPING("WM/ContentGroupDescription", false),
 37  6
     IS_COMPILATION("WM/IsCompilation",  false),
 38  6
     ISRC("WM/ISRC", false),
 39  6
     ISVBR("IsVBR",  false),
 40  6
     LYRICIST("WM/Writer", false),
 41  6
     LYRICS("WM/Lyrics", false),
 42  6
     MEDIA("WM/Media",  false),
 43  6
     MOOD("WM/Mood",  false),
 44  6
     MUSICBRAINZ_ARTISTID("MusicBrainz/Artist Id", false),
 45  6
     MUSICBRAINZ_DISC_ID("MusicBrainz/Disc Id", false),
 46  6
     MUSICBRAINZ_RELEASE_COUNTRY("MusicBrainz/Album Release Country", false),
 47  6
     MUSICBRAINZ_RELEASE_STATUS("MusicBrainz/Album Status",  false),
 48  6
     MUSICBRAINZ_RELEASE_TYPE("MusicBrainz/Album Type", false),
 49  6
     MUSICBRAINZ_RELEASEARTISTID("MusicBrainz/Album Artist Id", false),
 50  6
     MUSICBRAINZ_RELEASEID("MusicBrainz/Album Id",  false),
 51  6
     MUSICBRAINZ_TRACK_ID("MusicBrainz/Track Id",  false),
 52  6
     MUSICIP_ID("MusicIP/PUID", false),
 53  6
     RATING("RATING",false),
 54  6
     RECORD_LABEL("WM/Publisher", false),
 55  6
     REMIXER("WM/ModifiedBy", false),
 56  6
     TITLE("Title", false),
 57  6
     TITLE_SORT("WM/TitleSortOrder", false),
 58  6
     TRACK("WM/TrackNumber", false),
 59  6
     URL_DISCOGS_ARTIST_SITE("WM/DiscogsArtistUrl", false),
 60  6
     URL_DISCOGS_RELEASE_SITE("WM/DiscogsReleaseUrl", false),
 61  6
     URL_OFFICIAL_ARTIST_SITE("WM/OfficialArtistUrl", false),
 62  6
     URL_OFFICIAL_RELEASE_SITE("WM/OfficialReleaseUrl", false),
 63  6
     URL_WIKIPEDIA_ARTIST_SITE("WM/WikipediaArtistUrl", false),
 64  6
     URL_WIKIPEDIA_RELEASE_SITE("WM/WikipediaReleaseUrl", false),
 65  6
     YEAR("WM/Year", false),
 66  6
     LANGUAGE("WM/Language", false),
 67  6
     KEY("WM/Key", false),
 68  
     ;
 69  
 
 70  
     /**
 71  
      * Stores the {@link AsfFieldKey#fieldName} to the field key.
 72  
      */
 73  
     private final static HashMap<String, AsfFieldKey> FIELD_ID_MAP;
 74  
 
 75  
     static
 76  
     {
 77  6
         FIELD_ID_MAP = new HashMap<String, AsfFieldKey>(AsfFieldKey.values().length);
 78  318
         for (AsfFieldKey curr : AsfFieldKey.values())
 79  
         {
 80  312
             FIELD_ID_MAP.put(curr.getFieldName(), curr);
 81  
         }
 82  6
     }
 83  
 
 84  
 
 85  
     /**
 86  
      * Searches for an ASF field key which represents the given id string.<br>
 87  
      * 
 88  
      * @param fieldName the fieldname used for this key
 89  
      * @return tjhe Enum that represents this field
 90  
      */
 91  
     public static AsfFieldKey getAsfFieldKey(String fieldName)
 92  
     {
 93  3216
        return FIELD_ID_MAP.get(fieldName);
 94  
     }
 95  
 
 96  
     /**
 97  
      * Tests whether the field is enabled for multiple values.<br>
 98  
      * @param id field id to test.
 99  
      * @return <code>true</code> if ASF implementation supports multiple values for the field.
 100  
      */
 101  
     public static boolean isMultiValued(String id)
 102  
     {
 103  968
         boolean result = false; // For now, there is no support for multi values.
 104  968
         AsfFieldKey fieldKey = getAsfFieldKey(id);
 105  968
         if (fieldKey != null)
 106  
         {
 107  698
             result = fieldKey.isMultiValued();
 108  
         }
 109  968
         return result;
 110  
     }
 111  
 
 112  
 
 113  
     /**
 114  
      * If set, the field has a standard id assigned.
 115  
      */
 116  
     private String fieldName;
 117  
 
 118  
     /**
 119  
      * If <code>true</code>, the field will be stored repeatedly if occurs so in tags.
 120  
      */
 121  
     private boolean multiValued;
 122  
 
 123  
     /**
 124  
      * Creates an instance<br>
 125  
      * 
 126  
      * @param asfFieldId standard field identifier.
 127  
      * @param multiValue <code>true</code> if the this ASF field can have multiple values.
 128  
      */
 129  
     private AsfFieldKey(String asfFieldId, boolean multiValue)
 130  312
     {
 131  312
         this.fieldName = asfFieldId;
 132  312
         this.multiValued = multiValue;
 133  312
     }
 134  
 
 135  
 
 136  
 
 137  
     /**
 138  
      * Returns the standard field id.
 139  
      * 
 140  
      * @return the standard field id. (may be <code>null</code>)
 141  
      */
 142  
     public String getFieldName()
 143  
     {
 144  1597
         return this.fieldName;
 145  
     }
 146  
 
 147  
 
 148  
 
 149  
     /**
 150  
      * Returns <code>true</code> if this field can store multiple values.
 151  
      * 
 152  
      * @return <code>true</code> if multiple values are supported for this field.
 153  
      */
 154  
     public boolean isMultiValued()
 155  
     {
 156  698
         return this.multiValued;
 157  
     }
 158  
 
 159  
     /**
 160  
      * {@inheritDoc}
 161  
      */
 162  
     @Override
 163  
     public String toString()
 164  
     {
 165  1
         return getFieldName();
 166  
     }
 167  
 }