com.beaglebuddy.id3.v1

## Class ID3v1Tag

- java.lang.Object
- - com.beaglebuddy.id3.v1.ID3v1Tag

-     public class ID3v1Tag
      extends java.lang.Object

  This class provides methods for reading and writing the ID3v1 and ID3v1.1 tags. This tag is 128 bytes long, and is found at the end of the .mp3 file as shown below. The format of the tag is very simple, as there are eight fixed length fields. All of the fields are ISO-8859-1 encoded strings with the exception of the genre and the track fields. The genre is a number which is an index into a predefined list of `music genres`, or categories if you like. For example, a genre value of 1 indicates that the song is "Classic Rock". Finally, the track is stored within the last byte of the comments field. When the track number is stored there, the tag is considered to be version ID3v1.1.

  ID1v1 Tag Format
  Field | Size (in bytes)
  --- | ---
  Tag Id | 3
  Song Title | 30
  Artist | 30
  Album | 30
  Year | 4
  Comments | 30
  Track | 0
  `Genre` | 1

  See Also:
    ID3 tag version 1 standard, wikipedia history of ID3 tags

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `TAG_SIZE` fixed size (in bytes) of ID3v1 tags

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ID3v1Tag(java.io.InputStream inputStream, int tagOffset, java.lang.String path)` called when reading in an existing ID3v1 tag from an .mp3 file.
    `ID3v1Tag(java.io.RandomAccessFile file)` constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getAlbum()` gets the album on which the song was released.
    `java.lang.String` | `getArtist()` gets the artist who recorded the song.
    `java.lang.String` | `getComment()` gets the description of the song.
    `byte` | `getGenre()` gets the genre of the song.
    `java.lang.String` | `getGenreAsString()` gets the genre name according to the predefined list of `music genres`.
    `java.lang.String` | `getTitle()` gets the title of the song.
    `byte` | `getTrack()` gets the track number of the song on the album.
    `java.lang.String` | `getVersion()` gets the version of the ID3 tag.
    `java.lang.String` | `getYear()` gets the year the song was released.
    `void` | `setAlbum(java.lang.String album)` sets the album on which the song was released.
    `void` | `setArtist(java.lang.String artist)` sets the artist who recorded the song.
    `void` | `setComment(java.lang.String comment)` sets the description of the song.
    `void` | `setGenre(byte genre)` sets the genre of the song.
    `void` | `setTitle(java.lang.String title)` sets the title of the song.
    `void` | `setTrack(byte track)` sets the track number of the song on the album.
    `void` | `setYear(java.lang.String year)` sets the year the song was released.
    `java.lang.String` | `toString()` gets a string representation of the ID3v1 tag showing all of its fields and their values.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TAG_SIZE

          public static final int TAG_SIZE

      fixed size (in bytes) of ID3v1 tags
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ID3v1Tag

          public ID3v1Tag(java.io.InputStream inputStream,
                  int tagOffset,
                  java.lang.String path)
                   throws java.io.IOException,
                          ParseException

      called when reading in an existing ID3v1 tag from an .mp3 file.
      Parameters:
        `inputStream` - input stream pointing to the ID3v1 tag in an .mp3 file.
        `tagOffset` - position in the .mp3 file where the ID3v1 tag is found.
        `path` - path to the .mp3 file whose ID3v1 tag we are trying to read.
      Throws:
        `java.io.IOException` - if there is an error reading in the ID3v1 tag from the .mp3 file.
        `ParseException` - if the .mp3 file does not contain an ID3v1 tag.

    - #### ID3v1Tag

          public ID3v1Tag(java.io.RandomAccessFile file)
                   throws java.io.IOException,
                          ParseException

      constructor.
      Parameters:
        `file` - random access file to read in the ID3v1 tag from an .mp3 file.
      Throws:
        `java.io.IOException` - if there is an error while reading the ID3v1 tag.
        `ParseException` - if an ID3v1 tag can not be found or if an invalid value is detected while parsing the ID3v1 tag.

  - ### Method Detail

    - #### getArtist

          public java.lang.String getArtist()

      gets the artist who recorded the song.
      Returns:
        the artist who recorded the song.
      See Also:
        `setArtist(String)`

    - #### setArtist

          public void setArtist(java.lang.String artist)

      sets the artist who recorded the song.
      Parameters:
        `artist` - the artist who recorded the song.
      See Also:
        `getArtist()`

    - #### getTitle

          public java.lang.String getTitle()

      gets the title of the song.
      Returns:
        the title of the song.
      See Also:
        `setTitle(String)`

    - #### setTitle

          public void setTitle(java.lang.String title)

      sets the title of the song.
      Parameters:
        `title` - the title of the song.
      See Also:
        `getTitle()`

    - #### getAlbum

          public java.lang.String getAlbum()

      gets the album on which the song was released.
      Returns:
        the album which contains the song.
      See Also:
        `setAlbum(String)`

    - #### setAlbum

          public void setAlbum(java.lang.String album)

      sets the album on which the song was released.
      Parameters:
        `album` - the album which contains the song.
      See Also:
        `getAlbum()`

    - #### getYear

          public java.lang.String getYear()

      gets the year the song was released.
      Returns:
        the year the song was released.
      See Also:
        `setYear(String)`

    - #### setYear

          public void setYear(java.lang.String year)

      sets the year the song was released.
      Parameters:
        `year` - the year the song was released.
      See Also:
        `getYear()`

    - #### getComment

          public java.lang.String getComment()

      gets the description of the song.
      Returns:
        description of the song.
      See Also:
        `setComment(String)`

    - #### setComment

          public void setComment(java.lang.String comment)

      sets the description of the song.
      Parameters:
        `comment` - the description of the song.
      See Also:
        `getComment()`

    - #### getTrack

          public byte getTrack()

      gets the track number of the song on the album.
      Returns:
        the track number of the song on the album.
      See Also:
        `setTrack(byte)`

    - #### setTrack

          public void setTrack(byte track)

      sets the track number of the song on the album.
      Parameters:
        `track` - the track number of the song on the album.
      See Also:
        `getTrack()`

    - #### getGenre

          public byte getGenre()

      gets the genre of the song.
      Returns:
        the genre of the song.
      See Also:
        `setGenre(byte)`

    - #### setGenre

          public void setGenre(byte genre)

      sets the genre of the song.

      Genre | description
      --- | ---
      0. | Blues
      1. | Classic Rock
      2. | Country
      3. | Dance
      4. | Disco
      5. | Funk
      6. | Grunge
      7. | Hip-Hop
      8. | Jazz
      9. | Metal
      10. | New Age
      11. | Oldies
      12. | Other
      13. | Pop
      14. | R&B
      15. | Rap
      16. | Reggae
      17. | Rock
      18. | Techno
      19. | Industrial
      20. | Alternative
      21. | Ska
      22. | Death Metal
      23. | Pranks
      24. | Soundtrack
      25. | Euro-Techno
      26. | Ambient
      27. | Trip-Hop
      28. | Vocal
      29. | Jazz+Funk
      30. | Fusion
      31. | Trance
      32. | Classical
      33. | Instrumental
      34. | Acid
      35. | House
      36. | Game
      37. | Sound Clip
      38. | Gospel
      39. | Noise
      40. | AlternRock
      41. | Bass
      42. | Soul
      43. | Punk
      44. | Space
      45. | Meditative
      46. | Instrumental Pop
      47. | Instrumental Rock
      48. | Ethnic
      49. | Gothic
      50. | Darkwave
      51. | Techno-Industrial
      52. | Electronic
      53. | Pop-Folk
      54. | Eurodance
      55. | Dream
      56. | Southern Rock
      57. | Comedy
      58. | Cult
      59. | Gangsta
      60. | Top 40
      61. | Christian Rap
      62. | Pop/Funk
      63. | Jungle
      64. | Native American
      65. | Cabaret
      66. | New Wave
      67. | Psychadelic
      68. | Rave
      69. | Showtunes
      70. | Trailer
      71. | Lo-Fi
      72. | Tribal
      73. | Acid Punk
      74. | Acid Jazz
      75. | Polka
      76. | Retro
      77. | Musical
      78. | Rock & Roll
      79. | Hard Rock

      Parameters:
        `genre` - the genre of the song.
      See Also:
        `getGenre()`

    - #### getGenreAsString

          public java.lang.String getGenreAsString()

      gets the genre name according to the predefined list of `music genres`.
      Returns:
        the genre as a string.

    - #### getVersion

          public java.lang.String getVersion()

      gets the version of the ID3 tag. It is either 1.0 or 1.1.
      Returns:
        version of the tag.

    - #### toString

          public java.lang.String toString()

      gets a string representation of the ID3v1 tag showing all of its fields and their values.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of the ID3v1 tag.