org.jaudiotagger.tag.id3
Class ID3v1Tag

java.lang.Object
  extended by org.jaudiotagger.tag.id3.AbstractTagItem
      extended by org.jaudiotagger.tag.id3.AbstractTag
          extended by org.jaudiotagger.tag.id3.AbstractID3Tag
              extended by org.jaudiotagger.tag.id3.AbstractID3v1Tag
                  extended by org.jaudiotagger.tag.id3.ID3v1Tag
All Implemented Interfaces:
Tag
Direct Known Subclasses:
ID3v11Tag

public class ID3v1Tag
extends AbstractID3v1Tag
implements Tag

Represents an ID3v1 tag.

Author:
: Eric Farng, : Paul Taylor

Field Summary
 
Fields inherited from class org.jaudiotagger.tag.id3.AbstractID3v1Tag
logger
 
Constructor Summary
ID3v1Tag()
          Creates a new ID3v1 datatype.
ID3v1Tag(AbstractTag mp3tag)
           
ID3v1Tag(ID3v1Tag copyObject)
           
ID3v1Tag(java.io.RandomAccessFile file)
          Deprecated. use ID3v1Tag(RandomAccessFile,String) instead
ID3v1Tag(java.io.RandomAccessFile file, java.lang.String loggingFilename)
          Creates a new ID3v1 datatype.
 
Method Summary
 void add(TagField field)
          Adds a tagfield to the structure.
 void addAlbum(java.lang.String album)
          Add Album

 void addArtist(java.lang.String artist)
          Add Artist

 void addComment(java.lang.String comment)
          Add Comment

 void addGenre(java.lang.String genre)
          Add Genre

 void addTitle(java.lang.String title)
          Add Title

 void addTrack(java.lang.String track)
          Adds a track to the tag.
 void addYear(java.lang.String year)
          Add Year

 void createStructure()
          Create strcutured representation of this item.
 TagField createTagField(TagFieldKey genericKey, java.lang.String value)
          Create Tag Field using generic key
 void deleteTagField(TagFieldKey genericKey)
          Delete any instance of tag fields with this key
 boolean equals(java.lang.Object obj)
          Determines whether another datatype is equal to this tag.
 java.util.List get(java.lang.String id)
          Returns a list of TagField objects whose "id" is the specified one.
 java.util.List<TagField> get(TagFieldKey genericKey)
          Returns a list of TagField objects whose "id" is the specified one.
 java.util.List getAlbum()
           
 java.util.List getArtist()
           
 java.util.List getComment()
           
 java.lang.String getEncoding()
           
 int getFieldCount()
          Return the number of fields
 java.util.Iterator getFields()
          Iterator over all the fields within the tag, handle multiple fields with the same id
 java.lang.String getFirst(java.lang.String genericKey)
          Retrieve the first value that exists for this key id
 java.lang.String getFirst(TagFieldKey genericKey)
          Retrieve the first value that exists for this generic key
 java.lang.String getFirstAlbum()
          Get Album
 java.lang.String getFirstArtist()
          Get Artist
 java.lang.String getFirstComment()
          Get Comment
 TagField getFirstField(java.lang.String id)
          Retrieve the first tagfield that exists for this key
 java.lang.String getFirstGenre()
          Get Genre
 java.lang.String getFirstTitle()
          Get title
 java.lang.String getFirstTrack()
           
 java.lang.String getFirstYear()
          Get year
 java.util.List getGenre()
          Get Genre field

 byte getMajorVersion()
          Retrieve the Major Version
 byte getRelease()
          Retrieve the Release
 byte getRevision()
          Retrieve the Revision
 java.util.List getTitle()
          Get title field

 java.util.List getTrack()
           
 java.util.List getYear()
          Get year field

 boolean hasCommonFields()
          Returns true, if at least one of the contained fields is a common field (TagField.isCommon()).
 boolean hasField(java.lang.String id)
          Determines whether the tag has at least one field with the specified "id".
 boolean isEmpty()
          Determines whether the tag has no fields specified.
 java.util.Iterator iterator()
           
 void read(java.nio.ByteBuffer byteBuffer)
           
 boolean seek(java.nio.ByteBuffer byteBuffer)
          Does a tag of this version exist within the byteBuffer
 void set(TagField field)
           
 void setAlbum(java.lang.String album)
          Set Album
 void setArtist(java.lang.String artist)
          Set Artist
 void setComment(java.lang.String comment)
          Set Comment
 boolean setEncoding(java.lang.String encoding)
           
 void setGenre(java.lang.String genreVal)
          Sets the genreID,

 void setTitle(java.lang.String title)
          Set Title
 void setTrack(java.lang.String track)
           
 void setYear(java.lang.String year)
          Set year
 void write(java.io.RandomAccessFile file)
          Write this tag to the file, replacing any tag previously existing
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractID3v1Tag
delete, getSize
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractID3Tag
getIdentifier, toString
 
Methods inherited from class org.jaudiotagger.tag.id3.AbstractTagItem
isSubsetOf
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jaudiotagger.tag.Tag
toString
 

Constructor Detail

ID3v1Tag

public ID3v1Tag()
Creates a new ID3v1 datatype.


ID3v1Tag

public ID3v1Tag(ID3v1Tag copyObject)

ID3v1Tag

public ID3v1Tag(AbstractTag mp3tag)

ID3v1Tag

public ID3v1Tag(java.io.RandomAccessFile file,
                java.lang.String loggingFilename)
         throws TagNotFoundException,
                java.io.IOException
Creates a new ID3v1 datatype.

Parameters:
file -
loggingFilename -
Throws:
TagNotFoundException
java.io.IOException

ID3v1Tag

public ID3v1Tag(java.io.RandomAccessFile file)
         throws TagNotFoundException,
                java.io.IOException
Deprecated. use ID3v1Tag(RandomAccessFile,String) instead

Creates a new ID3v1 datatype.

Parameters:
file -
Throws:
TagNotFoundException
java.io.IOException
Method Detail

getRelease

public byte getRelease()
Retrieve the Release

Specified by:
getRelease in class AbstractID3Tag

getMajorVersion

public byte getMajorVersion()
Retrieve the Major Version

Specified by:
getMajorVersion in class AbstractID3Tag

getRevision

public byte getRevision()
Retrieve the Revision

Specified by:
getRevision in class AbstractID3Tag

add

public void add(TagField field)
Description copied from interface: Tag
Adds a tagfield to the structure.

It is not recommended to use this method for normal use of the audiolibrary. The developer will circumvent the underlying implementation. For example, if one adds a field with the field id "TALB" for an mp3 file, and the given TagField implementation does not return a text field compliant data with TagField.getRawContent() other software and the audio library won't read the file correctly, if they do read it at all.
So for short:

  • The field is stored withoud validation
  • No conversion of data is perfomed
  • Specified by:
    add in interface Tag
    Parameters:
    field - The field to add.

    get

    public java.util.List get(java.lang.String id)
    Description copied from interface: Tag
    Returns a list of TagField objects whose "id" is the specified one.

    Specified by:
    get in interface Tag
    Parameters:
    id - The field id.
    Returns:
    A list of TagField objects with the given "id".

    getFieldCount

    public int getFieldCount()
    Description copied from interface: Tag
    Return the number of fields

    Fields with the same identifiers are counted seperately i.e two title fields would contribute two to the count

    Specified by:
    getFieldCount in interface Tag
    Returns:
    total number of fields

    addAlbum

    public void addAlbum(java.lang.String album)
    Add Album

    Only one album can be added so if one already exists it will be replaced.

    Specified by:
    addAlbum in interface Tag
    Parameters:
    album -

    setAlbum

    public void setAlbum(java.lang.String album)
    Set Album

    Specified by:
    setAlbum in interface Tag
    Parameters:
    album -

    getFirstAlbum

    public java.lang.String getFirstAlbum()
    Get Album

    Specified by:
    getFirstAlbum in interface Tag
    Returns:
    album

    getAlbum

    public java.util.List getAlbum()
    Specified by:
    getAlbum in interface Tag
    Returns:
    album within list or empty if does not exist

    addArtist

    public void addArtist(java.lang.String artist)
    Add Artist

    Only one artist can be added so if one already exists it will be replaced.

    Specified by:
    addArtist in interface Tag
    Parameters:
    artist -

    setArtist

    public void setArtist(java.lang.String artist)
    Set Artist

    Specified by:
    setArtist in interface Tag
    Parameters:
    artist -

    getFirstArtist

    public java.lang.String getFirstArtist()
    Get Artist

    Specified by:
    getFirstArtist in interface Tag
    Returns:
    artist

    getArtist

    public java.util.List getArtist()
    Specified by:
    getArtist in interface Tag
    Returns:
    Artist within list or empty if does not exist

    addComment

    public void addComment(java.lang.String comment)
    Add Comment

    Only one comment can be added so if one already exists it will be replaced.

    Specified by:
    addComment in interface Tag
    Parameters:
    comment -

    setComment

    public void setComment(java.lang.String comment)
    Set Comment

    Specified by:
    setComment in interface Tag
    Parameters:
    comment -

    getComment

    public java.util.List getComment()
    Specified by:
    getComment in interface Tag
    Returns:
    comment within list or empty if does not exist

    getFirstComment

    public java.lang.String getFirstComment()
    Get Comment

    Specified by:
    getFirstComment in interface Tag
    Returns:
    comment

    addGenre

    public void addGenre(java.lang.String genre)
    Add Genre

    Only one Genre can be added so if one already exists it will be replaced.

    Specified by:
    addGenre in interface Tag
    Parameters:
    genre -

    setGenre

    public void setGenre(java.lang.String genreVal)
    Sets the genreID,

    ID3v1 only supports genres defined in a predefined list so if unable to find value in list set 255, which seems to be the value winamp uses for undefined.

    Specified by:
    setGenre in interface Tag
    Parameters:
    genreVal -

    getFirstGenre

    public java.lang.String getFirstGenre()
    Get Genre

    Specified by:
    getFirstGenre in interface Tag
    Returns:
    genre or empty string if not valid

    getGenre

    public java.util.List getGenre()
    Get Genre field

    Only a single genre is available in ID3v1

    Specified by:
    getGenre in interface Tag
    Returns:

    addTitle

    public void addTitle(java.lang.String title)
    Add Title

    Only one title can be added so if one already exists it will be replaced.

    Specified by:
    addTitle in interface Tag
    Parameters:
    title -

    setTitle

    public void setTitle(java.lang.String title)
    Set Title

    Specified by:
    setTitle in interface Tag
    Parameters:
    title -

    getFirstTitle

    public java.lang.String getFirstTitle()
    Get title

    Specified by:
    getFirstTitle in interface Tag
    Returns:
    Title

    getTitle

    public java.util.List getTitle()
    Get title field

    Only a single title is available in ID3v1

    Specified by:
    getTitle in interface Tag
    Returns:

    addYear

    public void addYear(java.lang.String year)
    Add Year

    Only one year can be added so if one already exists it will be replaced.

    Specified by:
    addYear in interface Tag
    Parameters:
    year -

    setYear

    public void setYear(java.lang.String year)
    Set year

    Specified by:
    setYear in interface Tag
    Parameters:
    year -

    getFirstYear

    public java.lang.String getFirstYear()
    Get year

    Specified by:
    getFirstYear in interface Tag
    Returns:
    year

    getYear

    public java.util.List getYear()
    Get year field

    Only a single year is available in ID3v1

    Specified by:
    getYear in interface Tag
    Returns:

    addTrack

    public void addTrack(java.lang.String track)
    Description copied from interface: Tag
    Adds a track to the tag.

    Specified by:
    addTrack in interface Tag
    Parameters:
    track - Track

    getFirstTrack

    public java.lang.String getFirstTrack()
    Specified by:
    getFirstTrack in interface Tag
    Returns:

    setTrack

    public void setTrack(java.lang.String track)
    Specified by:
    setTrack in interface Tag

    getTrack

    public java.util.List getTrack()
    Specified by:
    getTrack in interface Tag
    Returns:

    getFirstField

    public TagField getFirstField(java.lang.String id)
    Description copied from interface: Tag
    Retrieve the first tagfield that exists for this key

    Can be used to retrieve fields with any identifier, useful if the identifier is not within the jaudiotagger enum

    Specified by:
    getFirstField in interface Tag
    Parameters:
    id - audio specific key
    Returns:
    tag field or null if doesnt exist

    getFields

    public java.util.Iterator getFields()
    Description copied from interface: Tag
    Iterator over all the fields within the tag, handle multiple fields with the same id

    Specified by:
    getFields in interface Tag
    Returns:
    iterator over whole list

    hasCommonFields

    public boolean hasCommonFields()
    Description copied from interface: Tag
    Returns true, if at least one of the contained fields is a common field (TagField.isCommon()).

    Specified by:
    hasCommonFields in interface Tag
    Returns:
    true if a common field is present.

    hasField

    public boolean hasField(java.lang.String id)
    Description copied from interface: Tag
    Determines whether the tag has at least one field with the specified "id".

    Specified by:
    hasField in interface Tag
    Parameters:
    id - The field id to look for.
    Returns:
    true if tag contains a TagField with the given id.

    isEmpty

    public boolean isEmpty()
    Description copied from interface: Tag
    Determines whether the tag has no fields specified.

    Specified by:
    isEmpty in interface Tag
    Returns:
    true if tag contains no field.

    set

    public void set(TagField field)
    Specified by:
    set in interface Tag

    setEncoding

    public boolean setEncoding(java.lang.String encoding)
    Specified by:
    setEncoding in interface Tag
    Parameters:
    encoding -
    Returns:

    createTagField

    public TagField createTagField(TagFieldKey genericKey,
                                   java.lang.String value)
    Create Tag Field using generic key

    Specified by:
    createTagField in interface Tag
    Parameters:
    genericKey - is the generic key
    value - to store
    Returns:

    getEncoding

    public java.lang.String getEncoding()

    get

    public java.util.List<TagField> get(TagFieldKey genericKey)
    Returns a list of TagField objects whose "id" is the specified one.

    Specified by:
    get in interface Tag
    Parameters:
    genericKey - The generic field key
    Returns:
    A list of TagField objects with the given "id".

    getFirst

    public java.lang.String getFirst(java.lang.String genericKey)
    Retrieve the first value that exists for this key id

    Specified by:
    getFirst in interface Tag
    Parameters:
    genericKey -
    Returns:

    getFirst

    public java.lang.String getFirst(TagFieldKey genericKey)
    Retrieve the first value that exists for this generic key

    Specified by:
    getFirst in interface Tag
    Parameters:
    genericKey -
    Returns:

    deleteTagField

    public void deleteTagField(TagFieldKey genericKey)
    Delete any instance of tag fields with this key

    Specified by:
    deleteTagField in interface Tag
    Parameters:
    genericKey -

    equals

    public boolean equals(java.lang.Object obj)
    Description copied from class: AbstractTag
    Determines whether another datatype is equal to this tag. It just compares if they are the same class, then calls super.equals(obj).

    Overrides:
    equals in class AbstractTag
    Parameters:
    obj -
    Returns:
    true if this and obj are equivalent

    iterator

    public java.util.Iterator iterator()
    Specified by:
    iterator in class AbstractTag
    Returns:
    an iterator to iterate through the fields of the tag

    read

    public void read(java.nio.ByteBuffer byteBuffer)
              throws TagNotFoundException
    Specified by:
    read in class AbstractTagItem
    Parameters:
    byteBuffer -
    Throws:
    TagNotFoundException

    seek

    public boolean seek(java.nio.ByteBuffer byteBuffer)
    Does a tag of this version exist within the byteBuffer

    Specified by:
    seek in class AbstractTag
    Returns:
    whether tag exists within the byteBuffer

    write

    public void write(java.io.RandomAccessFile file)
               throws java.io.IOException
    Write this tag to the file, replacing any tag previously existing

    Specified by:
    write in class AbstractTag
    Parameters:
    file -
    Throws:
    java.io.IOException

    createStructure

    public void createStructure()
    Create strcutured representation of this item.