org.jaudiotagger.tag.vorbiscomment
Class VorbisCommentTag

java.lang.Object
  extended by org.jaudiotagger.audio.generic.AbstractTag
      extended by org.jaudiotagger.tag.vorbiscomment.VorbisCommentTag
All Implemented Interfaces:
Tag

public class VorbisCommentTag
extends AbstractTag

This is the logical representation of Vorbis Comment Data


Field Summary
static java.lang.String DEFAULT_VENDOR
           
private static java.util.EnumMap<FieldKey,VorbisCommentFieldKey> tagFieldToOggField
           
 
Fields inherited from class org.jaudiotagger.audio.generic.AbstractTag
commonNumber, fields
 
Constructor Summary
VorbisCommentTag()
          Only used within Package, hidden because it doesnt set Vendor which should be done when created by end user
 
Method Summary
 void addField(Artwork artwork)
          Add artwork field
 void addField(java.lang.String vorbisCommentKey, java.lang.String value)
          Create and add field with name of vorbisCommentkey
 void addField(TagField field)
          Add Field

 TagField createField(Artwork artwork)
          Create Artwork field
 TagField createField(FieldKey genericKey, java.lang.String value)
          Create Tag Field using generic key
 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
private  MetadataBlockDataPicture createMetadataBlockDataPicture(Artwork artwork)
          Create MetadataBlockPicture field, this is the preferred way of storing artwork in VorbisComment tag now but has to be base encoded to be stored in VorbisComment
static VorbisCommentTag createNewTag()
          Use to construct a new tag properly initialized
 void deleteArtworkField()
          Delete all instance of artwork Field
 void deleteField(FieldKey genericKey)
          Delete fields with this generic key
 void deleteField(VorbisCommentFieldKey vorbisCommentFieldKey)
          Delete fields with this vorbisCommentFieldKey
 java.util.List<TagField> get(VorbisCommentFieldKey vorbisCommentKey)
          Retrieve the first value that exists for this vorbis comment key
 byte[] getArtworkBinaryData()
          Retrieve artwork raw data when using the deprecated COVERART format
 java.util.List<Artwork> getArtworkList()
           
 java.lang.String getArtworkMimeType()
          Retrieve artwork mimeType when using deprecated COVERART format
 java.util.List<TagField> getFields(FieldKey genericKey)
          Maps the generic key to the ogg key and return the list of values for this field
 java.lang.String getFirst(VorbisCommentFieldKey vorbisCommentKey)
          Retrieve the first value that exists for this vorbis comment key
 TagField getFirstField(FieldKey genericKey)
           
 java.lang.String getValue(FieldKey genericKey, int index)
          Retrieve String value of the nth tag field that exists for this generic key
 java.lang.String getVendor()
           
protected  boolean isAllowedEncoding(java.lang.String enc)
          Determines whether the given charset encoding may be used for the represented tagging system.
 boolean isEmpty()
          Is this tag empty

 void setArtworkField(byte[] data, java.lang.String mimeType)
          Deprecated. 
 void setField(Artwork artwork)
          Create and set artwork field
 void setField(java.lang.String vorbisCommentKey, java.lang.String value)
          Create and set field with name of vorbisCommentkey
 void setVendor(java.lang.String vendor)
          Set the vendor, known as the encoder generally

We dont want this to be blank, when written to file this field is written to a different location to all other fields but user of library can just reat it as another field

 java.lang.String toString()
          (overridden)
 
Methods inherited from class org.jaudiotagger.audio.generic.AbstractTag
addField, deleteField, getFieldCount, getFieldCountIncludingSubValues, getFields, getFields, getFirst, getFirst, getFirstArtwork, getFirstField, getItem, getSubValue, hasCommonFields, hasField, setEncoding, setField, setField
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tagFieldToOggField

private static java.util.EnumMap<FieldKey,VorbisCommentFieldKey> tagFieldToOggField

DEFAULT_VENDOR

public static final java.lang.String DEFAULT_VENDOR
See Also:
Constant Field Values
Constructor Detail

VorbisCommentTag

VorbisCommentTag()
Only used within Package, hidden because it doesnt set Vendor which should be done when created by end user

Method Detail

createNewTag

public static VorbisCommentTag createNewTag()
Use to construct a new tag properly initialized

Returns:

getVendor

public java.lang.String getVendor()
Returns:
the vendor, generically known as the encoder

setVendor

public void setVendor(java.lang.String vendor)
Set the vendor, known as the encoder generally

We dont want this to be blank, when written to file this field is written to a different location to all other fields but user of library can just reat it as another field

Parameters:
vendor -

isAllowedEncoding

protected boolean isAllowedEncoding(java.lang.String enc)
Description copied from class: AbstractTag
Determines whether the given charset encoding may be used for the represented tagging system.

Specified by:
isAllowedEncoding in class AbstractTag
Parameters:
enc - charset encoding.
Returns:
true if the given encoding can be used.

toString

public java.lang.String toString()
Description copied from class: AbstractTag
(overridden)

Specified by:
toString in interface Tag
Overrides:
toString in class AbstractTag
See Also:
Object.toString()

createField

public TagField createField(FieldKey genericKey,
                            java.lang.String value)
                     throws KeyNotFoundException,
                            FieldDataInvalidException
Create Tag Field using generic key

Specified by:
createField in interface Tag
Specified by:
createField in class AbstractTag
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:

getFields

public java.util.List<TagField> getFields(FieldKey genericKey)
                                   throws KeyNotFoundException
Maps the generic key to the ogg key and return the list of values for this field

Specified by:
getFields in interface Tag
Overrides:
getFields in class AbstractTag
Parameters:
genericKey -
Returns:
A list of TagField objects with the given "id".
Throws:
KeyNotFoundException

get

public java.util.List<TagField> get(VorbisCommentFieldKey vorbisCommentKey)
                             throws KeyNotFoundException
Retrieve the first value that exists for this vorbis comment key

Parameters:
vorbisCommentKey -
Returns:
Throws:
KeyNotFoundException

getValue

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

Returns:
Throws:
KeyNotFoundException

getFirst

public java.lang.String getFirst(VorbisCommentFieldKey vorbisCommentKey)
                          throws KeyNotFoundException
Retrieve the first value that exists for this vorbis comment key

Parameters:
vorbisCommentKey -
Returns:
Throws:
KeyNotFoundException

deleteField

public void deleteField(FieldKey genericKey)
                 throws KeyNotFoundException
Delete fields with this generic key

Specified by:
deleteField in interface Tag
Specified by:
deleteField in class AbstractTag
Parameters:
genericKey -
Throws:
KeyNotFoundException

deleteField

public void deleteField(VorbisCommentFieldKey vorbisCommentFieldKey)
                 throws KeyNotFoundException
Delete fields with this vorbisCommentFieldKey

Parameters:
vorbisCommentFieldKey -
Throws:
KeyNotFoundException

getArtworkBinaryData

public byte[] getArtworkBinaryData()
Retrieve artwork raw data when using the deprecated COVERART format

Returns:

getArtworkMimeType

public java.lang.String getArtworkMimeType()
Retrieve artwork mimeType when using deprecated COVERART format

Returns:
mimetype

isEmpty

public boolean isEmpty()
Is this tag empty

Overridden because check for size of one because there is always a vendor tag unless just created an empty vorbis tag as part of flac tag in which case size could be zero

Specified by:
isEmpty in interface Tag
Overrides:
isEmpty in class AbstractTag
Returns:
true if tag contains no field.
See Also:
Tag.isEmpty()

addField

public void addField(TagField field)
Add Field

Overidden because there can only be one vendor set

Specified by:
addField in interface Tag
Overrides:
addField in class AbstractTag
Parameters:
field -
See Also:

Changed so add empty fields


getFirstField

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

getArtworkList

public java.util.List<Artwork> getArtworkList()
Returns:
list of artwork images

createMetadataBlockDataPicture

private MetadataBlockDataPicture createMetadataBlockDataPicture(Artwork artwork)
                                                         throws FieldDataInvalidException
Create MetadataBlockPicture field, this is the preferred way of storing artwork in VorbisComment tag now but has to be base encoded to be stored in VorbisComment

Returns:
MetadataBlockDataPicture
Throws:
FieldDataInvalidException

createField

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

Parameters:
artwork -
Returns:
Throws:
FieldDataInvalidException

setField

public void setField(Artwork artwork)
              throws FieldDataInvalidException
Create and set artwork field

Specified by:
setField in interface Tag
Overrides:
setField in class AbstractTag
Throws:
FieldDataInvalidException

addField

public void addField(Artwork artwork)
              throws FieldDataInvalidException
Add artwork field

Specified by:
addField in interface Tag
Overrides:
addField in class AbstractTag
Parameters:
artwork -
Throws:
FieldDataInvalidException

setArtworkField

@Deprecated
public void setArtworkField(byte[] data,
                                       java.lang.String mimeType)
Deprecated. 

Create artwork field using the non-standard COVERART tag

Actually create two fields , the data field and the mimetype. Its is not recommended that you use this method anymore.

Parameters:
data - raw image data
mimeType - mimeType of data


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

deleteArtworkField

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

Specified by:
deleteArtworkField in interface Tag
Overrides:
deleteArtworkField in class AbstractTag
Throws:
KeyNotFoundException


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