org.jaudiotagger.tag.flac
Class FlacTag

java.lang.Object
  extended by org.jaudiotagger.tag.flac.FlacTag
All Implemented Interfaces:
Tag

public class FlacTag
extends java.lang.Object
implements Tag

Flac uses Vorbis Comment for most of its metadata and a Flac Picture Block for images

This class enscapulates the items into a single tag


Constructor Summary
FlacTag(VorbisCommentTag tag, java.util.List<MetadataBlockDataPicture> images)
           
 
Method Summary
 void add(TagField field)
          Adds a tagfield to the structure.
 void addAlbum(java.lang.String album)
          Adds an album to the tag.
 void addArtist(java.lang.String artist)
          Adds an artist to the tag.
 void addComment(java.lang.String comment)
          Adds a comment to the tag.
 void addGenre(java.lang.String genre)
          Adds a genre to the tag.
 void addTitle(java.lang.String title)
          Adds a title to the tag.
 void addTrack(java.lang.String track)
          Adds a track to the tag.
 void addYear(java.lang.String year)
          Adds a year to the Tag.
 TagField createArtworkField(java.awt.image.BufferedImage bi, int pictureType, java.lang.String mimeType, java.lang.String description, int colourDepth, int indexedColouredCount)
          Create Artwork when have the bufferedimage
 TagField createArtworkField(byte[] imageData, int pictureType, java.lang.String mimeType, java.lang.String description, int width, int height, int colourDepth, int indexedColouredCount)
          Create Artwork when have the raw image data
 TagField createLinkedArtworkField(java.lang.String url)
          Create Link to Image File, not recommended because if either flac or image file is moved link will be broken.
 TagField createTagField(TagFieldKey genericKey, java.lang.String value)
          Create a new TagField based on generic key
 void deleteTagField(TagFieldKey tagFieldKey)
          Delete any instance of tag fields with this key
 java.util.List<TagField> get(java.lang.String id)
          Returns a list of TagField objects whose "id" is the specified one.
 java.util.List<TagField> get(TagFieldKey id)
          Returns a list of TagField objects whose "id" is the specified one.
 java.util.List<TagField> getAlbum()
           
 java.util.List<TagField> getArtist()
           
 java.util.List<TagField> getComment()
           
 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 id)
          Retrieve the first value that exists for this key
 java.lang.String getFirst(TagFieldKey id)
          Retrieve String value of first tagfield that exists for this key
 java.lang.String getFirstAlbum()
           
 java.lang.String getFirstArtist()
           
 java.lang.String getFirstComment()
           
 TagField getFirstField(java.lang.String id)
          Retrieve the first tagfield that exists for this key
 java.lang.String getFirstGenre()
           
 java.lang.String getFirstTitle()
           
 java.lang.String getFirstTrack()
           
 java.lang.String getFirstYear()
           
 java.util.List<TagField> getGenre()
           
 java.util.List<MetadataBlockDataPicture> getImages()
           
 java.util.List<TagField> getTitle()
           
 java.util.List<TagField> getTrack()
           
 VorbisCommentTag getVorbisCommentTag()
           
 java.util.List<TagField> getYear()
           
 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.
 void set(TagField field)
           
 void setAlbum(java.lang.String s)
           
 void setArtist(java.lang.String s)
           
 void setComment(java.lang.String s)
           
 boolean setEncoding(java.lang.String enc)
           
 void setGenre(java.lang.String s)
           
 void setTitle(java.lang.String s)
           
 void setTrack(java.lang.String s)
           
 void setYear(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaudiotagger.tag.Tag
toString
 

Constructor Detail

FlacTag

public FlacTag(VorbisCommentTag tag,
               java.util.List<MetadataBlockDataPicture> images)
Method Detail

getImages

public java.util.List<MetadataBlockDataPicture> getImages()
Returns:
images

getVorbisCommentTag

public VorbisCommentTag getVorbisCommentTag()
Returns:
the vorbis tag (this is what handles text metadata)

add

public void add(TagField field)
         throws FieldDataInvalidException
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 without validation
  • No conversion of data is perfomed
  • Specified by:
    add in interface Tag
    Parameters:
    field - The field to add.
    Throws:
    FieldDataInvalidException

    addAlbum

    public void addAlbum(java.lang.String album)
                  throws FieldDataInvalidException
    Adds an album to the tag.

    Specified by:
    addAlbum in interface Tag
    Parameters:
    album - Album description
    Throws:
    FieldDataInvalidException

    addArtist

    public void addArtist(java.lang.String artist)
                   throws FieldDataInvalidException
    Adds an artist to the tag.

    Specified by:
    addArtist in interface Tag
    Parameters:
    artist - Artist's name
    Throws:
    FieldDataInvalidException

    addComment

    public void addComment(java.lang.String comment)
                    throws FieldDataInvalidException
    Adds a comment to the tag.

    Specified by:
    addComment in interface Tag
    Parameters:
    comment - Comment.
    Throws:
    FieldDataInvalidException

    addGenre

    public void addGenre(java.lang.String genre)
                  throws FieldDataInvalidException
    Adds a genre to the tag.

    Specified by:
    addGenre in interface Tag
    Parameters:
    genre - Genre
    Throws:
    FieldDataInvalidException

    addTitle

    public void addTitle(java.lang.String title)
                  throws FieldDataInvalidException
    Adds a title to the tag.

    Specified by:
    addTitle in interface Tag
    Parameters:
    title - Title
    Throws:
    FieldDataInvalidException

    addTrack

    public void addTrack(java.lang.String track)
                  throws FieldDataInvalidException
    Adds a track to the tag.

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

    addYear

    public void addYear(java.lang.String year)
                 throws FieldDataInvalidException
    Adds a year to the Tag.

    Specified by:
    addYear in interface Tag
    Parameters:
    year - Year
    Throws:
    FieldDataInvalidException

    get

    public java.util.List<TagField> get(java.lang.String id)
    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".

    getAlbum

    public java.util.List<TagField> getAlbum()
    Specified by:
    getAlbum in interface Tag
    Returns:

    getArtist

    public java.util.List<TagField> getArtist()
    Specified by:
    getArtist in interface Tag
    Returns:

    getComment

    public java.util.List<TagField> getComment()
    Specified by:
    getComment in interface Tag
    Returns:

    getGenre

    public java.util.List<TagField> getGenre()
    Specified by:
    getGenre in interface Tag
    Returns:

    getTitle

    public java.util.List<TagField> getTitle()
    Specified by:
    getTitle in interface Tag
    Returns:

    getTrack

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

    getYear

    public java.util.List<TagField> getYear()
    Specified by:
    getYear in interface Tag
    Returns:

    getFirstAlbum

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

    getFirstArtist

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

    getFirstComment

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

    getFirstGenre

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

    getFirstTitle

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

    getFirstTrack

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

    getFirstYear

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

    hasCommonFields

    public boolean hasCommonFields()
    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)
    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()
    Determines whether the tag has no fields specified.

    If there are no images we return empty if either there is no VorbisTag or if there is a VorbisTag but it is empty

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

    set

    public void set(TagField field)
             throws FieldDataInvalidException
    Specified by:
    set in interface Tag
    Parameters:
    field -
    Throws:
    FieldDataInvalidException

    setAlbum

    public void setAlbum(java.lang.String s)
                  throws FieldDataInvalidException
    Specified by:
    setAlbum in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setArtist

    public void setArtist(java.lang.String s)
                   throws FieldDataInvalidException
    Specified by:
    setArtist in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setComment

    public void setComment(java.lang.String s)
                    throws FieldDataInvalidException
    Specified by:
    setComment in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setGenre

    public void setGenre(java.lang.String s)
                  throws FieldDataInvalidException
    Specified by:
    setGenre in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setTitle

    public void setTitle(java.lang.String s)
                  throws FieldDataInvalidException
    Specified by:
    setTitle in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setTrack

    public void setTrack(java.lang.String s)
                  throws FieldDataInvalidException
    Specified by:
    setTrack in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    setYear

    public void setYear(java.lang.String s)
                 throws FieldDataInvalidException
    Specified by:
    setYear in interface Tag
    Parameters:
    s -
    Throws:
    FieldDataInvalidException

    createTagField

    public TagField createTagField(TagFieldKey genericKey,
                                   java.lang.String value)
                            throws KeyNotFoundException,
                                   FieldDataInvalidException
    Create a new TagField based on generic key

    Only textual data supported at the moment. The genericKey will be mapped to the correct implementation key and return a TagField.

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

    getFirst

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

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

    getFirst

    public java.lang.String getFirst(TagFieldKey id)
                              throws KeyNotFoundException
    Retrieve String value of first tagfield that exists for this key

    Specified by:
    getFirst in interface Tag
    Parameters:
    id -
    Returns:
    String value or empty string
    Throws:
    KeyNotFoundException

    getFirstField

    public TagField getFirstField(java.lang.String id)
    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

    deleteTagField

    public void deleteTagField(TagFieldKey tagFieldKey)
                        throws KeyNotFoundException
    Delete any instance of tag fields with this key

    Specified by:
    deleteTagField in interface Tag
    Parameters:
    tagFieldKey -
    Throws:
    KeyNotFoundException

    getFields

    public java.util.Iterator getFields()
    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

    getFieldCount

    public int getFieldCount()
    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

    setEncoding

    public boolean setEncoding(java.lang.String enc)
                        throws FieldDataInvalidException
    Specified by:
    setEncoding in interface Tag
    Throws:
    FieldDataInvalidException

    get

    public java.util.List<TagField> get(TagFieldKey id)
                                 throws KeyNotFoundException
    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".
    Throws:
    KeyNotFoundException

    createArtworkField

    public TagField createArtworkField(byte[] imageData,
                                       int pictureType,
                                       java.lang.String mimeType,
                                       java.lang.String description,
                                       int width,
                                       int height,
                                       int colourDepth,
                                       int indexedColouredCount)
                                throws FieldDataInvalidException
    Create Artwork when have the raw image data

    Parameters:
    imageData -
    pictureType -
    mimeType -
    description -
    width -
    height -
    colourDepth -
    indexedColouredCount -
    Returns:
    Throws:
    FieldDataInvalidException

    createArtworkField

    public TagField createArtworkField(java.awt.image.BufferedImage bi,
                                       int pictureType,
                                       java.lang.String mimeType,
                                       java.lang.String description,
                                       int colourDepth,
                                       int indexedColouredCount)
                                throws FieldDataInvalidException
    Create Artwork when have the bufferedimage

    Parameters:
    pictureType -
    mimeType -
    description -
    colourDepth -
    indexedColouredCount -
    Returns:
    Throws:
    FieldDataInvalidException

    createLinkedArtworkField

    public TagField createLinkedArtworkField(java.lang.String url)
    Create Link to Image File, not recommended because if either flac or image file is moved link will be broken.