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 This is handled differently by different formats
 void addField(java.lang.String vorbisCommentKey, java.lang.String value)
          Create and add field with name of vorbisCommentkey
 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 createField(java.lang.String vorbisCommentFieldKey, java.lang.String value)
          Create Tag Field using ogg key

This method is provided to allow you to create key of any value because VorbisComment allows arbitary keys.

 TagField createField(VorbisCommentFieldKey vorbisCommentFieldKey, java.lang.String value)
          Create Tag Field using ogg key
 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
 void deleteField(java.lang.String id)
          Delete any fields with this Flac (Vorbis Comment) id
 java.util.List<Artwork> getArtworkList()
           
 int getFieldCount()
          Return the number of fields

 int getFieldCountIncludingSubValues()
          Return the number of fields taking multiple value fields into consideration Fields that actually contain multiple values are counted seperately i.e.
 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.util.List<TagField> getFields(java.lang.String 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 tag field 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()
           
 java.lang.String getSubValue(FieldKey id, int n, int m)
          The m parameter is effectively ignored
 java.lang.String getValue(FieldKey id, int index)
          Retrieve String value of the nth tag field that exists for this generic key
 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(java.lang.String vorbisCommentKey, java.lang.String value)
          Create and set field with name of vorbisCommentkey
 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

Specified by:
addField in interface Tag
Parameters:
field - The field to add.
Throws:
FieldDataInvalidException

getFields

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

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

Specified by:
getFields 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 This is handled differently by different formats

Specified by:
addField in interface Tag
Throws:
KeyNotFoundException
FieldDataInvalidException

setField

public void setField(java.lang.String vorbisCommentKey,
                     java.lang.String value)
              throws KeyNotFoundException,
                     FieldDataInvalidException
Create and set field with name of vorbisCommentkey

Parameters:
vorbisCommentKey -
value -
Throws:
KeyNotFoundException
FieldDataInvalidException

addField

public void addField(java.lang.String vorbisCommentKey,
                     java.lang.String value)
              throws KeyNotFoundException,
                     FieldDataInvalidException
Create and add field with name of vorbisCommentkey

Parameters:
vorbisCommentKey -
value -
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

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.

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

createField

public TagField createField(VorbisCommentFieldKey vorbisCommentFieldKey,
                            java.lang.String value)
                     throws KeyNotFoundException,
                            FieldDataInvalidException
Create Tag Field using ogg key

Parameters:
vorbisCommentFieldKey -
value -
Returns:
Throws:
KeyNotFoundException
FieldDataInvalidException

createField

public TagField createField(java.lang.String vorbisCommentFieldKey,
                            java.lang.String value)
Create Tag Field using ogg key

This method is provided to allow you to create key of any value because VorbisComment allows arbitary keys.

Parameters:
vorbisCommentFieldKey -
value -
Returns:

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:

getSubValue

public java.lang.String getSubValue(FieldKey id,
                                    int n,
                                    int m)
The m parameter is effectively ignored

Specified by:
getSubValue in interface Tag
Parameters:
id -
n -
m -
Returns:

getValue

public java.lang.String getValue(FieldKey id,
                                 int index)
                          throws KeyNotFoundException
Description copied from interface: Tag
Retrieve String value of the nth tag field that exists for this generic key

Specified by:
getValue in interface Tag
Returns:
Throws:
KeyNotFoundException

getFirst

public java.lang.String getFirst(FieldKey id)
                          throws KeyNotFoundException
Description copied from interface: Tag
Retrieve String value of the first tag field 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 doesn't 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

deleteField

public void deleteField(java.lang.String id)
                 throws KeyNotFoundException
Description copied from interface: Tag
Delete any fields with this Flac (Vorbis Comment) id

Specified by:
deleteField in interface Tag
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 separately i.e two TITLE fields in a Vorbis Comment file would count as two

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

getFieldCountIncludingSubValues

public int getFieldCountIncludingSubValues()
Description copied from interface: Tag
Return the number of fields taking multiple value fields into consideration Fields that actually contain multiple values are counted seperately i.e. a TCON frame in ID3v24 frame containing multiple genres would add to count for each genre.

Specified by:
getFieldCountIncludingSubValues in interface Tag
Returns:
total number of fields taking multiple value fields into consideration

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


Copyright © 2005-2010 java.net. All Rights Reserved.