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


Field Summary
private  java.util.List<MetadataBlockDataPicture> images
           
private  VorbisCommentTag tag
           
 
Constructor Summary
FlacTag(VorbisCommentTag tag, java.util.List<MetadataBlockDataPicture> images)
           
 
Method Summary
 void addField(Artwork artwork)
          Create artwork field based on the data in artwork and then add it to the tag itself

 void addField(FieldKey genericKey, java.lang.String value)
          Create the field based on the generic key and add it to the tag
 void addField(TagField field)
          Adds a field to the structure, used internally by the library

 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)
           
 TagField createField(Artwork artwork)
          Create artwork field
 TagField createField(FieldKey genericKey, java.lang.String value)
          Create a new field based on generic key, used internally by the library

 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.
 void deleteArtworkField()
          Delete all instance of artwork Field
 void deleteField(FieldKey fieldKey)
          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<Artwork> getArtworkList()
           
 int getFieldCount()
          Return the number of fields

 java.util.Iterator<TagField> getFields()
          Iterator over all the fields within the tag, handle multiple fields with the same id
 java.util.List<TagField> getFields(FieldKey id)
          Returns a list of TagField objects whose "id" is the specified one.
 java.lang.String getFirst(FieldKey id)
          Retrieve String value of the first tagfield that exists for this generic key
 java.lang.String getFirst(java.lang.String id)
          Retrieve String value of the first value that exists for this format specific key

 Artwork getFirstArtwork()
           
 TagField getFirstField(FieldKey genericKey)
           
 TagField getFirstField(java.lang.String id)
          Retrieve the first field that exists for this format specific key

 java.util.List<MetadataBlockDataPicture> getImages()
           
 VorbisCommentTag getVorbisCommentTag()
           
 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.

 boolean setEncoding(java.lang.String enc)
           
 void setField(Artwork artwork)
          Create artwork field based on the data in artwork and then set it in the tag itself

 void setField(FieldKey genericKey, java.lang.String value)
          Create the field based on the generic key and set it in the tag
 void setField(TagField field)
          Sets a field in the structure, used internally by the library

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaudiotagger.tag.Tag
toString
 

Field Detail

tag

private VorbisCommentTag tag

images

private java.util.List<MetadataBlockDataPicture> images
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)

addField

public void addField(TagField field)
              throws FieldDataInvalidException
Description copied from interface: Tag
Adds a field to the structure, used internally by the library

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:
    addField in interface Tag
    Parameters:
    field - The field to add.
    Throws:
    FieldDataInvalidException

    get

    public java.util.List<TagField> 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".

    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()
    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.

    setField

    public void setField(FieldKey genericKey,
                         java.lang.String value)
                  throws KeyNotFoundException,
                         FieldDataInvalidException
    Description copied from interface: Tag
    Create the field based on the generic key and set it in the tag

    Specified by:
    setField in interface Tag
    Throws:
    KeyNotFoundException
    FieldDataInvalidException

    addField

    public void addField(FieldKey genericKey,
                         java.lang.String value)
                  throws KeyNotFoundException,
                         FieldDataInvalidException
    Description copied from interface: Tag
    Create the field based on the generic key and add it to the tag

    Specified by:
    addField in interface Tag
    Throws:
    KeyNotFoundException
    FieldDataInvalidException

    setField

    public void setField(TagField field)
                  throws FieldDataInvalidException
    Description copied from interface: Tag
    Sets a field in the structure, used internally by the library

    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:
    setField in interface Tag
    Parameters:
    field -
    Throws:
    FieldDataInvalidException

    createField

    public TagField createField(FieldKey genericKey,
                                java.lang.String value)
                         throws KeyNotFoundException,
                                FieldDataInvalidException
    Description copied from interface: Tag
    Create a new field based on generic key, used internally by the library

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

    It is not recommended to use this method for normal use of the audiolibrary, this is snot added to the structure

    Specified by:
    createField 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)
    Description copied from interface: Tag
    Retrieve String value of the first value that exists for this format specific key

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

    Specified by:
    getFirst in interface Tag
    Returns:

    getFirst

    public java.lang.String getFirst(FieldKey id)
                              throws KeyNotFoundException
    Description copied from interface: Tag
    Retrieve String value of the first tagfield that exists for this generic key

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

    getFirstField

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

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

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

    getFirstField

    public TagField getFirstField(FieldKey genericKey)
                           throws KeyNotFoundException
    Specified by:
    getFirstField in interface Tag
    Returns:
    the first field that matches this generic key
    Throws:
    KeyNotFoundException

    deleteField

    public void deleteField(FieldKey fieldKey)
                     throws KeyNotFoundException
    Delete any instance of tag fields with this key

    Specified by:
    deleteField in interface Tag
    Parameters:
    fieldKey -
    Throws:
    KeyNotFoundException

    getFields

    public java.util.Iterator<TagField> 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

    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

    setEncoding

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

    getFields

    public java.util.List<TagField> getFields(FieldKey id)
                                       throws KeyNotFoundException
    Description copied from interface: Tag
    Returns a list of TagField objects whose "id" is the specified one.

    Specified by:
    getFields 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
    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:
    bi -
    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.

    Parameters:
    url -
    Returns:

    createField

    public TagField createField(Artwork artwork)
                         throws FieldDataInvalidException
    Create artwork field

    Specified by:
    createField in interface Tag
    Returns:
    Throws:
    FieldDataInvalidException

    setField

    public void setField(Artwork artwork)
                  throws FieldDataInvalidException
    Description copied from interface: Tag
    Create artwork field based on the data in artwork and then set it in the tag itself

    Specified by:
    setField in interface Tag
    Throws:
    FieldDataInvalidException

    addField

    public void addField(Artwork artwork)
                  throws FieldDataInvalidException
    Description copied from interface: Tag
    Create artwork field based on the data in artwork and then add it to the tag itself

    Specified by:
    addField in interface Tag
    Throws:
    FieldDataInvalidException

    getArtworkList

    public java.util.List<Artwork> getArtworkList()
    Specified by:
    getArtworkList in interface Tag
    Returns:
    a list of all artwork in this file using the format indepedent Artwork class

    getFirstArtwork

    public Artwork getFirstArtwork()
    Specified by:
    getFirstArtwork in interface Tag
    Returns:
    first artwork or null if none exist

    deleteArtworkField

    public void deleteArtworkField()
                            throws KeyNotFoundException
    Delete all instance of artwork Field

    Specified by:
    deleteArtworkField in interface Tag
    Throws:
    KeyNotFoundException