Methods Summary |
---|
public void | addField(FieldKey genericKey, java.lang.String value)
setField(genericKey,value);
|
public void | addField(org.jaudiotagger.tag.images.Artwork artwork)
throw new UnsupportedOperationException(ErrorMessage.GENERIC_NOT_SUPPORTED.getMsg());
|
public void | addField(TagField field)
//TODO
|
public TagField | createField(FieldKey genericKey, java.lang.String value)Create Tag Field using generic key
return new ID3v1TagField(tagFieldToID3v1Field.get(genericKey).name(), value);
|
public TagField | createField(org.jaudiotagger.tag.images.Artwork artwork)
throw new UnsupportedOperationException(ErrorMessage.GENERIC_NOT_SUPPORTED.getMsg());
|
public void | createStructure()Create structured representation of this item.
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
//Header
MP3File.getStructureFormatter().addElement(TYPE_TITLE, this.title);
MP3File.getStructureFormatter().addElement(TYPE_ARTIST, this.artist);
MP3File.getStructureFormatter().addElement(TYPE_ALBUM, this.album);
MP3File.getStructureFormatter().addElement(TYPE_YEAR, this.year);
MP3File.getStructureFormatter().addElement(TYPE_COMMENT, this.comment);
MP3File.getStructureFormatter().addElement(TYPE_GENRE, this.genre);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
|
public void | deleteArtworkField()Delete all instance of artwork Field
throw new UnsupportedOperationException(ErrorMessage.GENERIC_NOT_SUPPORTED.getMsg());
|
public void | deleteField(FieldKey genericKey)Delete any instance of tag fields with this key
switch (genericKey)
{
case ARTIST:
setArtist("");
break;
case ALBUM:
setAlbum("");
break;
case TITLE:
setTitle("");
break;
case GENRE:
setGenre("");
break;
case YEAR:
setYear("");
break;
case COMMENT:
setComment("");
break;
}
|
public void | deleteField(java.lang.String id)
FieldKey key = FieldKey.valueOf(id);
if(key!=null)
{
deleteField(key);
}
|
public boolean | equals(java.lang.Object obj)
if (!(obj instanceof ID3v1Tag))
{
return false;
}
ID3v1Tag object = (ID3v1Tag) obj;
if (!this.album.equals(object.album))
{
return false;
}
if (!this.artist.equals(object.artist))
{
return false;
}
if (!this.comment.equals(object.comment))
{
return false;
}
if (this.genre != object.genre)
{
return false;
}
if (!this.title.equals(object.title))
{
return false;
}
return this.year.equals(object.year) && super.equals(obj);
|
public java.util.List | getAlbum()
if (getFirstAlbum().length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.ALBUM.name(), getFirstAlbum());
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public java.util.List | getArtist()
if (getFirstArtist().length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.ARTIST.name(), getFirstArtist());
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public java.util.List | getArtworkList()
return Collections.emptyList();
|
public java.util.List | getComment()
if (getFirstComment().length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.COMMENT.name(), getFirstComment());
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public java.lang.String | getEncoding()
return "ISO-8859-1";
|
public int | getFieldCount()
return 6;
|
public int | getFieldCountIncludingSubValues()
return getFieldCount();
|
public java.util.List | getFields(java.lang.String id)
if (FieldKey.ARTIST.name().equals(id))
{
return getArtist();
}
else if (FieldKey.ALBUM.name().equals(id))
{
return getAlbum();
}
else if (FieldKey.TITLE.name().equals(id))
{
return getTitle();
}
else if (FieldKey.GENRE.name().equals(id))
{
return getGenre();
}
else if (FieldKey.YEAR.name().equals(id))
{
return getYear();
}
else if (FieldKey.COMMENT.name().equals(id))
{
return getComment();
}
return new ArrayList<TagField>();
|
public java.util.Iterator | getFields()
throw new UnsupportedOperationException("TODO:Not done yet");
|
public java.util.List | getFields(FieldKey genericKey)Returns a {@linkplain List list} of {@link TagField} objects whose "{@linkplain TagField#getId() id}"
is the specified one.
switch (genericKey)
{
case ARTIST:
return getArtist();
case ALBUM:
return getAlbum();
case TITLE:
return getTitle();
case GENRE:
return getGenre();
case YEAR:
return getYear();
case COMMENT:
return getComment();
default:
return new ArrayList<TagField>();
}
|
public java.lang.String | getFirst(java.lang.String genericKey)Retrieve the first value that exists for this key id
FieldKey matchingKey = FieldKey.valueOf(genericKey);
if (matchingKey != null)
{
return getFirst(matchingKey);
}
else
{
return "";
}
|
public java.lang.String | getFirst(FieldKey genericKey)Retrieve the first value that exists for this generic key
switch (genericKey)
{
case ARTIST:
return getFirstArtist();
case ALBUM:
return getFirstAlbum();
case TITLE:
return getFirstTitle();
case GENRE:
return getFirstGenre();
case YEAR:
return getFirstYear();
case COMMENT:
return getFirstComment();
default:
return "";
}
|
public java.lang.String | getFirstAlbum()Get Album
return album;
|
public java.lang.String | getFirstArtist()Get Artist
return artist;
|
public org.jaudiotagger.tag.images.Artwork | getFirstArtwork()
return null;
|
public java.lang.String | getFirstComment()Get Comment
return comment;
|
public TagField | getFirstField(java.lang.String id)
List<TagField> results = null;
if (FieldKey.ARTIST.name().equals(id))
{
results = getArtist();
}
else if (FieldKey.ALBUM.name().equals(id))
{
results = getAlbum();
}
else if (FieldKey.TITLE.name().equals(id))
{
results = getTitle();
}
else if (FieldKey.GENRE.name().equals(id))
{
results = getGenre();
}
else if (FieldKey.YEAR.name().equals(id))
{
results = getYear();
}
else if (FieldKey.COMMENT.name().equals(id))
{
results = getComment();
}
if (results != null)
{
if (results.size() > 0)
{
return results.get(0);
}
}
return null;
|
public TagField | getFirstField(FieldKey genericKey)
List<TagField> l = getFields(genericKey);
return (l.size() != 0) ? l.get(0) : null;
|
public java.lang.String | getFirstGenre()Get Genre
Integer genreId = genre & BYTE_TO_UNSIGNED;
String genreValue = GenreTypes.getInstanceOf().getValueForId(genreId);
if (genreValue == null)
{
return "";
}
else
{
return genreValue;
}
|
public java.lang.String | getFirstTitle()Get title
return title;
|
public java.lang.String | getFirstTrack()
throw new UnsupportedOperationException("ID3v10 cannot store track numbers");
|
public java.lang.String | getFirstYear()Get year
return year;
|
public java.util.List | getGenre()Get Genre field
Only a single genre is available in ID3v1
if (getFirst(FieldKey.GENRE).length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.GENRE.name(), getFirst(FieldKey.GENRE));
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public byte | getMajorVersion()Retrieve the Major Version
return MAJOR_VERSION;
|
public byte | getRelease()Retrieve the Release
return RELEASE;
|
public byte | getRevision()Retrieve the Revision
return REVISION;
|
public java.lang.String | getSubValue(FieldKey id, int n, int m)The m parameter is effectively ignored
return getValue(id,n);
|
public java.util.List | getTitle()Get title field
Only a single title is available in ID3v1
if (getFirst(FieldKey.TITLE).length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.TITLE.name(), getFirst(FieldKey.TITLE));
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public java.util.List | getTrack()
throw new UnsupportedOperationException("ID3v10 cannot store track numbers");
|
public java.lang.String | getValue(FieldKey genericKey, int index)
return getFirst(genericKey);
|
public java.util.List | getYear()Get year field
Only a single year is available in ID3v1
if (getFirst(FieldKey.YEAR).length() > 0)
{
ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.YEAR.name(), getFirst(FieldKey.YEAR));
return returnFieldToList(field);
}
else
{
return new ArrayList<TagField>();
}
|
public boolean | hasCommonFields()
//TODO
return true;
|
public boolean | hasField(FieldKey genericKey)
return getFirst(genericKey).length() > 0;
|
public boolean | hasField(java.lang.String id)
try
{
FieldKey key = FieldKey.valueOf(id.toUpperCase());
return hasField(key);
}
catch(java.lang.IllegalArgumentException iae)
{
return false;
}
|
public boolean | isEmpty()
return !(getFirst(FieldKey.TITLE).length() > 0 ||
getFirstArtist().length() > 0 ||
getFirstAlbum().length() > 0 ||
getFirst(FieldKey.GENRE).length() > 0 ||
getFirst(FieldKey.YEAR).length() > 0 ||
getFirstComment().length() > 0);
|
public java.util.Iterator | iterator()
return new ID3v1Iterator(this);
|
public void | read(java.nio.ByteBuffer byteBuffer)
if (!seek(byteBuffer))
{
throw new TagNotFoundException(getLoggingFilename() + ":" + "ID3v1 tag not found");
}
logger.finer(getLoggingFilename() + ":" + "Reading v1 tag");
//Do single file read of data to cut down on file reads
byte[] dataBuffer = new byte[TAG_LENGTH];
byteBuffer.position(0);
byteBuffer.get(dataBuffer, 0, TAG_LENGTH);
title = Utils.getString(dataBuffer, FIELD_TITLE_POS, FIELD_TITLE_LENGTH, "ISO-8859-1").trim();
Matcher m = AbstractID3v1Tag.endofStringPattern.matcher(title);
if (m.find())
{
title = title.substring(0, m.start());
}
artist = Utils.getString(dataBuffer, FIELD_ARTIST_POS, FIELD_ARTIST_LENGTH, "ISO-8859-1").trim();
m = AbstractID3v1Tag.endofStringPattern.matcher(artist);
if (m.find())
{
artist = artist.substring(0, m.start());
}
album = Utils.getString(dataBuffer, FIELD_ALBUM_POS, FIELD_ALBUM_LENGTH, "ISO-8859-1").trim();
m = AbstractID3v1Tag.endofStringPattern.matcher(album);
logger.finest(getLoggingFilename() + ":" + "Orig Album is:" + comment + ":");
if (m.find())
{
album = album.substring(0, m.start());
logger.finest(getLoggingFilename() + ":" + "Album is:" + album + ":");
}
year = Utils.getString(dataBuffer, FIELD_YEAR_POS, FIELD_YEAR_LENGTH, "ISO-8859-1").trim();
m = AbstractID3v1Tag.endofStringPattern.matcher(year);
if (m.find())
{
year = year.substring(0, m.start());
}
comment = Utils.getString(dataBuffer, FIELD_COMMENT_POS, FIELD_COMMENT_LENGTH, "ISO-8859-1").trim();
m = AbstractID3v1Tag.endofStringPattern.matcher(comment);
logger.finest(getLoggingFilename() + ":" + "Orig Comment is:" + comment + ":");
if (m.find())
{
comment = comment.substring(0, m.start());
logger.finest(getLoggingFilename() + ":" + "Comment is:" + comment + ":");
}
genre = dataBuffer[FIELD_GENRE_POS];
|
protected java.util.List | returnFieldToList(ID3v1TagField field)
List<TagField> fields = new ArrayList<TagField>();
fields.add(field);
return fields;
|
public boolean | seek(java.nio.ByteBuffer byteBuffer)Does a tag of this version exist within the byteBuffer
byte[] buffer = new byte[FIELD_TAGID_LENGTH];
// read the TAG value
byteBuffer.get(buffer, 0, FIELD_TAGID_LENGTH);
return (Arrays.equals(buffer, TAG_ID));
|
public void | setAlbum(java.lang.String album)Set Album
if (album == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
this.album = ID3Tags.truncate(album, FIELD_ALBUM_LENGTH);
|
public void | setArtist(java.lang.String artist)Set Artist
if (artist == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
this.artist = ID3Tags.truncate(artist, FIELD_ARTIST_LENGTH);
|
public void | setComment(java.lang.String comment)Set Comment
if (comment == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
this.comment = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH);
|
public boolean | setEncoding(java.lang.String encoding)
return true;
|
public void | setField(FieldKey genericKey, java.lang.String value)
TagField tagfield = createField(genericKey,value);
setField(tagfield);
|
public void | setField(TagField field)
FieldKey genericKey = FieldKey.valueOf(field.getId());
switch (genericKey)
{
case ARTIST:
setArtist(field.toString());
break;
case ALBUM:
setAlbum(field.toString());
break;
case TITLE:
setTitle(field.toString());
break;
case GENRE:
setGenre(field.toString());
break;
case YEAR:
setYear(field.toString());
break;
case COMMENT:
setComment(field.toString());
break;
}
|
public void | setField(org.jaudiotagger.tag.images.Artwork artwork)
throw new UnsupportedOperationException(ErrorMessage.GENERIC_NOT_SUPPORTED.getMsg());
|
public void | setGenre(java.lang.String genreVal)Sets the genreID,
ID3v1 only supports genres defined in a predefined list
so if unable to find value in list set 255, which seems to be the value
winamp uses for undefined.
if (genreVal == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
Integer genreID = GenreTypes.getInstanceOf().getIdForValue(genreVal);
if (genreID != null)
{
this.genre = genreID.byteValue();
}
else
{
this.genre = (byte) GENRE_UNDEFINED;
}
|
public void | setTitle(java.lang.String title)Set Title
if (title == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
this.title = ID3Tags.truncate(title, FIELD_TITLE_LENGTH);
|
public void | setYear(java.lang.String year)Set year
this.year = ID3Tags.truncate(year, FIELD_YEAR_LENGTH);
|
public void | write(java.io.RandomAccessFile file)Write this tag to the file, replacing any tag previously existing
logger.config("Saving ID3v1 tag to file");
byte[] buffer = new byte[TAG_LENGTH];
int i;
String str;
delete(file);
file.seek(file.length());
//Copy the TAGID into new buffer
System.arraycopy(TAG_ID, FIELD_TAGID_POS, buffer, FIELD_TAGID_POS, TAG_ID.length);
int offset = FIELD_TITLE_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveTitle())
{
str = ID3Tags.truncate(title, FIELD_TITLE_LENGTH);
for (i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
}
offset = FIELD_ARTIST_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveArtist())
{
str = ID3Tags.truncate(artist, FIELD_ARTIST_LENGTH);
for (i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
}
offset = FIELD_ALBUM_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveAlbum())
{
str = ID3Tags.truncate(album, FIELD_ALBUM_LENGTH);
for (i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
}
offset = FIELD_YEAR_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveYear())
{
str = ID3Tags.truncate(year, AbstractID3v1Tag.FIELD_YEAR_LENGTH);
for (i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
}
offset = FIELD_COMMENT_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveComment())
{
str = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH);
for (i = 0; i < str.length(); i++)
{
buffer[i + offset] = (byte) str.charAt(i);
}
}
offset = FIELD_GENRE_POS;
if (TagOptionSingleton.getInstance().isId3v1SaveGenre())
{
buffer[offset] = genre;
}
file.write(buffer);
logger.config("Saved ID3v1 tag to file");
|