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(TagField field)
          Add Field

 TagField createField(Artwork artwork)
          Create artwork field Not supported because reuire two fields to be created use
 TagField createField(FieldKey genericKey, java.lang.String value)
          Create Tag Field using generic key
static VorbisCommentTag createNewTag()
          Use to construct a new tag properly initialized
 TagField createTagField(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 createTagField(VorbisCommentFieldKey vorbisCommentFieldKey, java.lang.String value)
          Create Tag Field using ogg key
 void deleteArtworkField()
          Delete all instance of artwork Field
 void deleteField(FieldKey genericKey)
          Delete fields with this generic key
 void deleteTagField(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
private  java.lang.String getAlbumId()
           
 byte[] getArtworkBinaryData()
          Retrieve artwork raw data
 java.util.List<Artwork> getArtworkList()
           
 java.lang.String getArtworkMimeType()
           
 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(FieldKey genericKey)
          Retrieve the first value that exists for this generic key
 java.lang.String getFirst(VorbisCommentFieldKey vorbisCommentKey)
          Retrieve the first value that exists for this vorbis comment key
 TagField getFirstField(FieldKey genericKey)
           
 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)
          Create artwork field

Actually create two fields , the data field and the mimetype

 void setField(Artwork artwork)
          Create artwork field Actually sets two fields
 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, addField, deleteField, get, getFieldCount, getFields, getFirst, getFirstArtwork, getFirstField, 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:

getAlbumId

private java.lang.String getAlbumId()

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

createTagField

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

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

createTagField

public TagField createTagField(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

getFirst

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

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

deleteTagField

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

Parameters:
vorbisCommentFieldKey -
Throws:
KeyNotFoundException

setArtworkField

public void setArtworkField(byte[] data,
                            java.lang.String mimeType)
Create artwork field

Actually create two fields , the data field and the mimetype

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

TODO could possibly work out mimetype from data, but unlike mp4 there is nothing to restrict to only png or jpeg images


getArtworkBinaryData

public byte[] getArtworkBinaryData()
Retrieve artwork raw data

Returns:

getArtworkMimeType

public java.lang.String getArtworkMimeType()
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:
a list of all artwork in this file using the format indepedent Artwork class

createField

public TagField createField(Artwork artwork)
                     throws FieldDataInvalidException
Create artwork field Not supported because reuire two fields to be created use

Returns:
Throws:
FieldDataInvalidException

setField

public void setField(Artwork artwork)
              throws FieldDataInvalidException
Create artwork field Actually sets two fields

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