Methods Summary |
---|
public void | addField(TagField field)Add Field
Overidden because there can only be one vendor set
if (field.getId().equals(VorbisCommentFieldKey.VENDOR.getFieldName()))
{
super.setField(field);
}
else
{
super.addField(field);
}
|
public void | addField(org.jaudiotagger.tag.images.Artwork artwork)Add artwork field
this.addField(createField(artwork));
|
public void | addField(java.lang.String vorbisCommentKey, java.lang.String value)Create and add field with name of vorbisCommentkey
TagField tagfield = createField(vorbisCommentKey,value);
addField(tagfield);
|
public TagField | createField(org.jaudiotagger.tag.images.Artwork artwork)Create Artwork field
try
{
char[] testdata = Base64Coder.encode(createMetadataBlockDataPicture(artwork).getRawContent());
String base64image = new String(testdata);
TagField imageTagField = createField(VorbisCommentFieldKey.METADATA_BLOCK_PICTURE, base64image);
return imageTagField;
}
catch(UnsupportedEncodingException uee)
{
throw new RuntimeException(uee);
}
|
public TagField | createField(FieldKey genericKey, java.lang.String value)Create Tag Field using generic key
if (genericKey == null)
{
throw new KeyNotFoundException();
}
return createField(tagFieldToOggField.get(genericKey), value);
|
public TagField | createField(VorbisCommentFieldKey vorbisCommentFieldKey, java.lang.String value)Create Tag Field using ogg key
if (value == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
if (vorbisCommentFieldKey == null)
{
throw new KeyNotFoundException();
}
return new VorbisCommentTagField(vorbisCommentFieldKey.getFieldName(), value);
|
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.
if (value == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
return new VorbisCommentTagField(vorbisCommentFieldKey, value);
|
private org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture | createMetadataBlockDataPicture(org.jaudiotagger.tag.images.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
if(artwork.isLinked())
{
return new MetadataBlockDataPicture(
Utils.getDefaultBytes(artwork.getImageUrl(), TextEncoding.CHARSET_ISO_8859_1),
artwork.getPictureType(),
MetadataBlockDataPicture.IMAGE_IS_URL,
"",
0,
0,
0,
0);
}
else
{
if(!artwork.setImageFromData())
{
throw new FieldDataInvalidException("Unable to create MetadataBlockDataPicture from buffered");
}
return new MetadataBlockDataPicture(artwork.getBinaryData(),
artwork.getPictureType(),
artwork.getMimeType(),
artwork.getDescription(),
artwork.getWidth(),
artwork.getHeight(),
0,
0);
}
|
public static org.jaudiotagger.tag.vorbiscomment.VorbisCommentTag | createNewTag()Use to construct a new tag properly initialized
VorbisCommentTag tag = new VorbisCommentTag();
tag.setVendor(DEFAULT_VENDOR);
return tag;
|
public void | deleteArtworkField()Delete all instance of artwork Field
//New Method
this.deleteField(VorbisCommentFieldKey.METADATA_BLOCK_PICTURE);
//Old Method
this.deleteField(VorbisCommentFieldKey.COVERART);
this.deleteField(VorbisCommentFieldKey.COVERARTMIME);
|
public void | deleteField(FieldKey genericKey)Delete fields with this generic key
if (genericKey == null)
{
throw new KeyNotFoundException();
}
VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
deleteField(vorbisCommentFieldKey);
|
public void | deleteField(VorbisCommentFieldKey vorbisCommentFieldKey)Delete fields with this vorbisCommentFieldKey
if (vorbisCommentFieldKey == null)
{
throw new KeyNotFoundException();
}
super.deleteField(vorbisCommentFieldKey.getFieldName());
|
public java.util.List | get(VorbisCommentFieldKey vorbisCommentKey)Retrieve the first value that exists for this vorbis comment key
if (vorbisCommentKey == null)
{
throw new KeyNotFoundException();
}
return super.getFields(vorbisCommentKey.getFieldName());
|
public byte[] | getArtworkBinaryData()Retrieve artwork raw data when using the deprecated COVERART format
String base64data = this.getFirst(VorbisCommentFieldKey.COVERART);
byte[] rawdata = Base64Coder.decode(base64data.toCharArray());
return rawdata;
|
public java.util.List | getArtworkList()
List<Artwork> artworkList = new ArrayList<Artwork>(1);
//Read Old Format
if(getArtworkBinaryData()!=null & getArtworkBinaryData().length>0)
{
Artwork artwork= ArtworkFactory.getNew();
artwork.setMimeType(getArtworkMimeType());
artwork.setBinaryData(getArtworkBinaryData());
artworkList.add(artwork);
}
//New Format (Supports Multiple Images)
List<TagField> metadataBlockPics = this.get(VorbisCommentFieldKey.METADATA_BLOCK_PICTURE);
for(TagField tagField:metadataBlockPics)
{
try
{
byte[] imageBinaryData = Base64Coder.decode(((TagTextField)tagField).getContent());
MetadataBlockDataPicture coverArt = new MetadataBlockDataPicture(ByteBuffer.wrap(imageBinaryData));
Artwork artwork=ArtworkFactory.createArtworkFromMetadataBlockDataPicture(coverArt);
artworkList.add(artwork);
}
catch(IOException ioe)
{
throw new RuntimeException(ioe);
}
catch(InvalidFrameException ife)
{
throw new RuntimeException(ife);
}
}
return artworkList;
|
public java.lang.String | getArtworkMimeType()Retrieve artwork mimeType when using deprecated COVERART format
return this.getFirst(VorbisCommentFieldKey.COVERARTMIME);
|
public java.util.List | getFields(FieldKey genericKey)Maps the generic key to the ogg key and return the list of values for this field
VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
if (vorbisCommentFieldKey == null)
{
throw new KeyNotFoundException();
}
return super.getFields(vorbisCommentFieldKey.getFieldName());
|
public java.lang.String | getFirst(VorbisCommentFieldKey vorbisCommentKey)Retrieve the first value that exists for this vorbis comment key
if (vorbisCommentKey == null)
{
throw new KeyNotFoundException();
}
return super.getFirst(vorbisCommentKey.getFieldName());
|
public TagField | getFirstField(FieldKey genericKey)
if (genericKey == null)
{
throw new KeyNotFoundException();
}
return getFirstField(tagFieldToOggField.get(genericKey).getFieldName());
|
public java.lang.String | getValue(FieldKey genericKey, int index)
VorbisCommentFieldKey vorbisCommentFieldKey = tagFieldToOggField.get(genericKey);
if (vorbisCommentFieldKey == null)
{
throw new KeyNotFoundException();
}
return super.getItem(vorbisCommentFieldKey.getFieldName(),index);
|
public java.lang.String | getVendor()
return getFirst(VENDOR.getFieldName());
|
public boolean | hasField(FieldKey genericKey)
VorbisCommentFieldKey vorbisFieldKey = tagFieldToOggField.get(genericKey);
return getFields(vorbisFieldKey.getFieldName()).size() != 0;
|
public boolean | hasField(VorbisCommentFieldKey vorbisFieldKey)
return getFields(vorbisFieldKey.getFieldName()).size() != 0;
|
protected boolean | isAllowedEncoding(java.lang.String enc)
return enc.equals(VorbisHeader.CHARSET_UTF_8);
|
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
return fields.size() <= 1;
|
public void | setArtworkField(byte[] data, java.lang.String mimeType)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.
char[] testdata = Base64Coder.encode(data);
String base64image = new String(testdata);
VorbisCommentTagField dataField = new VorbisCommentTagField(VorbisCommentFieldKey.COVERART.getFieldName(), base64image);
VorbisCommentTagField mimeField = new VorbisCommentTagField(VorbisCommentFieldKey.COVERARTMIME.getFieldName(), mimeType);
setField(dataField);
setField(mimeField);
|
public void | setField(org.jaudiotagger.tag.images.Artwork artwork)Create and set artwork field
//Set field
this.setField(createField(artwork));
//If worked okay above then that should be first artwork and if we still had old coverart format
//that should be removed
if(this.getFirst(VorbisCommentFieldKey.COVERART).length()>0)
{
this.deleteField(VorbisCommentFieldKey.COVERART);
this.deleteField(VorbisCommentFieldKey.COVERARTMIME);
}
|
public void | setField(java.lang.String vorbisCommentKey, java.lang.String value)Create and set field with name of vorbisCommentkey
TagField tagfield = createField(vorbisCommentKey,value);
setField(tagfield);
|
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
if (vendor == null)
{
vendor = DEFAULT_VENDOR;
}
super.setField(new VorbisCommentTagField(VENDOR.getFieldName(), vendor));
|
public java.lang.String | toString()
return "OGG " + super.toString();
|