|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jaudiotagger.tag.id3.AbstractTagItem
org.jaudiotagger.tag.id3.AbstractTag
org.jaudiotagger.tag.id3.AbstractID3Tag
org.jaudiotagger.tag.id3.AbstractID3v2Tag
public abstract class AbstractID3v2Tag
This is the abstract base class for all ID3v2 tags.
| Field Summary | |
|---|---|
java.util.HashMap |
frameMap
Map of all frames for this tag |
static int |
TAG_HEADER_LENGTH
|
| Fields inherited from class org.jaudiotagger.tag.id3.AbstractID3Tag |
|---|
logger |
| Constructor Summary | |
|---|---|
AbstractID3v2Tag()
Empty Constructor |
|
| Method Summary | |
|---|---|
void |
add(TagField field)
Adds a tagfield to the structure. |
void |
addAlbum(java.lang.String album)
Adds an album to the tag. |
void |
addArtist(java.lang.String artist)
Adds an artist to the tag. |
void |
addComment(java.lang.String comment)
Adds a comment to the tag. |
void |
addGenre(java.lang.String genre)
Adds a genre to the tag. |
void |
addTitle(java.lang.String title)
Adds a title to the tag. |
void |
addTrack(java.lang.String track)
Adds a track to the tag. |
void |
addYear(java.lang.String year)
Adds a year to the Tag. |
void |
adjustPadding(java.io.File file,
int paddingSize,
long audioStart)
Adjust the length of the padding at the beginning of the MP3 file, this is only called when there is currently not enough space before the start of the audio to write the tag. |
TagField |
createAlbumField(java.lang.String content)
|
void |
createAndSetArtworkField(Artwork artwork)
Create field and then set within tag itself |
TagField |
createArtistField(java.lang.String content)
|
TagField |
createCommentField(java.lang.String content)
|
abstract AbstractID3v2Frame |
createFrame(java.lang.String id)
Create Frame of correct ID3 version with the specified id |
TagField |
createGenreField(java.lang.String content)
|
TagField |
createLinkedArtworkField(java.lang.String url)
Create a link to artwork, this is not recommended because the link may be broken if the mp3 or image file is moved |
void |
createStructure()
|
void |
createStructureBody()
|
void |
createStructureHeader()
|
TagField |
createTagField(TagFieldKey genericKey,
java.lang.String value)
Create a new TagField Only textual data supported at the moment. |
TagField |
createTitleField(java.lang.String content)
|
TagField |
createTrackField(java.lang.String content)
|
TagField |
createYearField(java.lang.String content)
|
void |
delete(java.io.RandomAccessFile file)
Delete Tag |
void |
deleteTagField(TagFieldKey genericKey)
Delete fields with this generic key |
boolean |
equals(java.lang.Object obj)
Is this tag equivalent to another |
java.util.List<TagField> |
get(java.lang.String id)
Retrieve the values that exists for this id3 frame id |
java.util.List<TagField> |
get(TagFieldKey genericKey)
Get field(s) for this key |
java.util.List<TagField> |
getAlbum()
|
java.util.List<TagField> |
getArtist()
|
java.util.List<TagField> |
getComment()
|
int |
getDuplicateBytes()
Returns the number of bytes which come from duplicate frames |
java.lang.String |
getDuplicateFrameId()
Return the string which holds the ids of all duplicate frames. |
int |
getEmptyFrameBytes()
Returns the number of bytes which come from empty frames |
int |
getFieldCount()
Return the number of fields |
java.util.Iterator<TagField> |
getFields()
Iterator over all the fields within the tag, handle multiple fields with the same id |
int |
getFileReadBytes()
Returns the tag size as reported by the tag header |
java.lang.String |
getFirst(java.lang.String identifier)
Retrieve the first value that exists for this identifier If the value is a String it returns that, otherwise returns a summary of the fields information |
java.lang.String |
getFirst(TagFieldKey genericKey)
Retrieve the first value that exists for this generic key |
java.lang.String |
getFirstAlbum()
|
java.lang.String |
getFirstArtist()
|
Artwork |
getFirstArtwork()
|
java.lang.String |
getFirstComment()
|
AbstractID3v2Frame |
getFirstField(java.lang.String identifier)
Retrieve the first tagfield that exists for this identifier |
TagField |
getFirstField(TagFieldKey genericKey)
|
java.lang.String |
getFirstGenre()
|
java.lang.String |
getFirstTitle()
|
java.lang.String |
getFirstTrack()
|
java.lang.String |
getFirstYear()
|
java.lang.Object |
getFrame(java.lang.String identifier)
For single frames return the frame in this tag with given identifier if it exists, if multiple frames exist with the same identifier it will return a list containing all the frames with this identifier Warning the match is only done against the identifier so if a tag contains a frame with an unsupported body but happens to have an identifier that is valid for another version of the tag it will be returned. |
int |
getFrameCount()
Return the number of frames in this tag of a particular type, multiple frames of the same time will only be counted once |
java.util.Iterator |
getFrameOfType(java.lang.String identifier)
Return all frames which start with the identifier, this can be more than one which is useful if trying to retrieve similar frames e.g TIT1,TIT2,TIT3 ... |
java.util.List<TagField> |
getGenre()
|
int |
getInvalidFrameBytes()
Return byte count of invalid frames |
abstract java.util.Comparator |
getPreferredFrameOrderComparator()
|
int |
getSize()
Return tag size based upon the sizes of the tags rather than the physical no of bytes between start of ID3Tag and start of Audio Data.Should be extended by subclasses to include header. |
java.util.List<TagField> |
getTitle()
|
java.util.List<TagField> |
getTrack()
|
static long |
getV2TagSizeIfExists(java.io.File file)
Checks to see if the file contains an ID3tag and if so return its size as reported in the tag header and return the size of the tag (including header), if no such tag exists return zero. |
java.util.List<TagField> |
getYear()
|
boolean |
hasCommonFields()
Returns true, if at least one of the contained
fields is a common field (TagField.isCommon()). |
boolean |
hasField(java.lang.String id)
Does this tag contain a field with the specified id |
boolean |
hasFrame(java.lang.String identifier)
Return whether tag has frame with this identifier Warning the match is only done against the identifier so if a tag contains a frame with an unsuported body but happens to have an identifier that is valid for another version of the tag it will return true |
boolean |
hasFrameAndBody(java.lang.String identifier)
Return whether tag has frame with this identifier and a related body. |
boolean |
hasFrameOfType(java.lang.String identifier)
Return whether tag has frame starting with this identifier Warning the match is only done against the identifier so if a tag contains a frame with an unsupported body but happens to have an identifier that is valid for another version of the tag it will return true |
boolean |
isEmpty()
Is this tag empty |
java.util.Iterator |
iterator()
Return the frames in the order they were added |
void |
removeFrame(java.lang.String identifier)
Remove frame(s) with this identifier from tag |
void |
removeFrameOfType(java.lang.String identifier)
Remove any frames starting with this identifier from tag |
void |
removeUnsupportedFrames()
Remove all frame(s) which have an unsupported body, in other words remove all frames that are not part of the standard frameset for this tag |
boolean |
seek(java.nio.ByteBuffer byteBuffer)
Does a tag of the correct version exist in this file. |
void |
set(TagField field)
|
void |
setAlbum(java.lang.String s)
|
void |
setArtist(java.lang.String s)
|
void |
setComment(java.lang.String s)
|
boolean |
setEncoding(java.lang.String enc)
|
void |
setFrame(AbstractID3v2Frame frame)
Add a frame to this tag |
void |
setFrame(java.lang.String identifier,
java.util.List<AbstractID3v2Frame> multiFrame)
Used for setting multiple frames for a single frame Identifier Warning if frame(s) already exists for this identifier thay are overwritten TODO needs to ensure do not add an invalid frame for this tag |
void |
setGenre(java.lang.String s)
|
void |
setTitle(java.lang.String s)
|
void |
setTrack(java.lang.String s)
|
void |
setYear(java.lang.String s)
|
void |
write(java.io.File file,
long audioStartByte)
Write tag to file. |
void |
write(java.io.RandomAccessFile file)
Write tag to file. |
void |
write(java.nio.channels.WritableByteChannel channel)
Write tag to channel. |
| Methods inherited from class org.jaudiotagger.tag.id3.AbstractID3Tag |
|---|
getIdentifier, getMajorVersion, getRelease, getRevision, toString |
| Methods inherited from class org.jaudiotagger.tag.id3.AbstractTagItem |
|---|
isSubsetOf, read |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jaudiotagger.tag.Tag |
|---|
createArtworkField, getArtworkList, toString |
| Field Detail |
|---|
public static final int TAG_HEADER_LENGTH
public java.util.HashMap frameMap
| Constructor Detail |
|---|
public AbstractID3v2Tag()
| Method Detail |
|---|
public int getDuplicateBytes()
public java.lang.String getDuplicateFrameId()
public int getEmptyFrameBytes()
public int getInvalidFrameBytes()
public int getFileReadBytes()
public boolean hasFrame(java.lang.String identifier)
identifier - frameId to lookup
public boolean hasFrameAndBody(java.lang.String identifier)
identifier - frameId to lookup
public boolean hasFrameOfType(java.lang.String identifier)
identifier - start of frameId to lookup
public java.lang.Object getFrame(java.lang.String identifier)
identifier - is an ID3Frame identifier
public java.lang.String getFirst(java.lang.String identifier)
getFirst in interface Tagidentifier -
public TagField getFirstField(TagFieldKey genericKey)
throws KeyNotFoundException
getFirstField in interface TagKeyNotFoundExceptionpublic AbstractID3v2Frame getFirstField(java.lang.String identifier)
getFirstField in interface Tagidentifier -
public void setFrame(AbstractID3v2Frame frame)
frame - the frame to add
Warning if frame(s) already exists for this identifier thay are overwritten
public void set(TagField field)
throws FieldDataInvalidException
set in interface Tagfield -
FieldDataInvalidException
public void setAlbum(java.lang.String s)
throws FieldDataInvalidException
setAlbum in interface TagFieldDataInvalidException
public void setArtist(java.lang.String s)
throws FieldDataInvalidException
setArtist in interface TagFieldDataInvalidException
public void setComment(java.lang.String s)
throws FieldDataInvalidException
setComment in interface TagFieldDataInvalidException
public void setGenre(java.lang.String s)
throws FieldDataInvalidException
setGenre in interface TagFieldDataInvalidException
public void setTitle(java.lang.String s)
throws FieldDataInvalidException
setTitle in interface TagFieldDataInvalidException
public void setTrack(java.lang.String s)
throws FieldDataInvalidException
setTrack in interface TagFieldDataInvalidException
public void setYear(java.lang.String s)
throws FieldDataInvalidException
setYear in interface TagFieldDataInvalidException
public void add(TagField field)
throws FieldDataInvalidException
TagIt is not recommended to use this method for normal use of the
audiolibrary. The developer will circumvent the underlying
implementation. For example, if one adds a field with the field id
"TALB" for an mp3 file, and the given
TagField
implementation does not return a text field compliant data with
TagField.getRawContent() other software and the audio library
won't read the file correctly, if they do read it at all.
So for short:
field -
FieldDataInvalidException
public void addAlbum(java.lang.String album)
throws FieldDataInvalidException
addAlbum in interface Tagalbum - Album description
FieldDataInvalidException
public void addArtist(java.lang.String artist)
throws FieldDataInvalidException
addArtist in interface Tagartist - Artist's name
FieldDataInvalidException
public void addComment(java.lang.String comment)
throws FieldDataInvalidException
addComment in interface Tagcomment - Comment.
FieldDataInvalidException
public void addGenre(java.lang.String genre)
throws FieldDataInvalidException
addGenre in interface Taggenre - Genre
FieldDataInvalidException
public void addTitle(java.lang.String title)
throws FieldDataInvalidException
addTitle in interface Tagtitle - Title
FieldDataInvalidException
public void addTrack(java.lang.String track)
throws FieldDataInvalidException
addTrack in interface Tagtrack - Track
FieldDataInvalidException
public void addYear(java.lang.String year)
throws FieldDataInvalidException
addYear in interface Tagyear - Year
FieldDataInvalidException
public void setFrame(java.lang.String identifier,
java.util.List<AbstractID3v2Frame> multiFrame)
public int getFrameCount()
public java.util.Iterator getFrameOfType(java.lang.String identifier)
identifier -
public void delete(java.io.RandomAccessFile file)
throws java.io.IOException
delete in class AbstractTagfile - to delete the tag from
java.io.IOException - if problem accessing the file
public boolean equals(java.lang.Object obj)
equals in class AbstractTagobj - to test for equivalence
public java.util.Iterator iterator()
iterator in class AbstractTagpublic void removeFrame(java.lang.String identifier)
identifier - frameId to look forpublic void removeUnsupportedFrames()
public void removeFrameOfType(java.lang.String identifier)
identifier - start of frameId to look for
public void write(java.io.File file,
long audioStartByte)
throws java.io.IOException
file - audioStartByte -
java.io.IOException - TODO should be abstract
public void write(java.io.RandomAccessFile file)
throws java.io.IOException
write in class AbstractTagfile -
java.io.IOException - TODO should be abstract
public void write(java.nio.channels.WritableByteChannel channel)
throws java.io.IOException
channel -
java.io.IOException - TODO should be abstract
public static long getV2TagSizeIfExists(java.io.File file)
throws java.io.IOException
file -
java.io.IOExceptionpublic boolean seek(java.nio.ByteBuffer byteBuffer)
seek in class AbstractTagbyteBuffer - to search through
public void adjustPadding(java.io.File file,
int paddingSize,
long audioStart)
throws java.io.FileNotFoundException,
java.io.IOException
ID3v2 tag.
The old file will be deleted, and the new file renamed.
paddingSize - This is total size required to store tag before audiofile - The file to adjust the padding length of
java.io.FileNotFoundException - if the file exists but is a directory
rather than a regular file or cannot be opened for any other
reason
java.io.IOException - on any I/O errorpublic int getSize()
getSize in class AbstractTagItempublic abstract java.util.Comparator getPreferredFrameOrderComparator()
public void createStructure()
public void createStructureHeader()
public void createStructureBody()
public java.util.List<TagField> get(java.lang.String id)
throws KeyNotFoundException
get in interface Tagid - The field id.
TagField objects with the given "id".
KeyNotFoundExceptionpublic java.util.List<TagField> getAlbum()
getAlbum in interface Tagpublic java.util.List<TagField> getArtist()
getArtist in interface Tagpublic java.util.List<TagField> getComment()
getComment in interface Tagpublic java.util.List<TagField> getGenre()
getGenre in interface Tagpublic java.util.List<TagField> getTitle()
getTitle in interface Tagpublic java.util.List<TagField> getTrack()
getTrack in interface Tagpublic java.util.List<TagField> getYear()
getYear in interface Tagpublic java.lang.String getFirstAlbum()
getFirstAlbum in interface Tagpublic java.lang.String getFirstArtist()
getFirstArtist in interface Tagpublic java.lang.String getFirstComment()
getFirstComment in interface Tagpublic java.lang.String getFirstGenre()
getFirstGenre in interface Tagpublic java.lang.String getFirstTitle()
getFirstTitle in interface Tagpublic java.lang.String getFirstTrack()
getFirstTrack in interface Tagpublic java.lang.String getFirstYear()
getFirstYear in interface Tagpublic abstract AbstractID3v2Frame createFrame(java.lang.String id)
id -
public TagField createArtistField(java.lang.String content)
content -
public TagField createAlbumField(java.lang.String content)
content -
public TagField createTitleField(java.lang.String content)
content -
public TagField createTrackField(java.lang.String content)
content -
public TagField createYearField(java.lang.String content)
content -
public TagField createCommentField(java.lang.String content)
content -
public TagField createGenreField(java.lang.String content)
content -
public boolean hasCommonFields()
Tagtrue, if at least one of the contained
fields is a common field (TagField.isCommon()).
hasCommonFields in interface Tagtrue if a common
field is present.public boolean hasField(java.lang.String id)
hasField in interface Tagid - The field id to look for.
true if tag contains a TagField with the
given id.Tag.hasField(java.lang.String)public boolean isEmpty()
isEmpty in interface Tagtrue if tag contains no field.Tag.isEmpty()public java.util.Iterator<TagField> getFields()
Tag
getFields in interface Tagpublic int getFieldCount()
TagFields with the same identifiers are counted seperately i.e two title fields would contribute two to the count
getFieldCount in interface Tag
public boolean setEncoding(java.lang.String enc)
throws FieldDataInvalidException
setEncoding in interface TagFieldDataInvalidException
public java.lang.String getFirst(TagFieldKey genericKey)
throws KeyNotFoundException
getFirst in interface TaggenericKey -
KeyNotFoundException
public TagField createTagField(TagFieldKey genericKey,
java.lang.String value)
throws KeyNotFoundException,
FieldDataInvalidException
createTagField in interface TaggenericKey - is the generic keyvalue - to store
KeyNotFoundException
FieldDataInvalidExceptionpublic TagField createLinkedArtworkField(java.lang.String url)
url - specifies the link, it could be a local file or could be a full url
public void deleteTagField(TagFieldKey genericKey)
throws KeyNotFoundException
deleteTagField in interface TaggenericKey -
KeyNotFoundException
public java.util.List<TagField> get(TagFieldKey genericKey)
throws KeyNotFoundException
get in interface TaggenericKey -
KeyNotFoundExceptionpublic Artwork getFirstArtwork()
getFirstArtwork in interface Tag
public void createAndSetArtworkField(Artwork artwork)
throws FieldDataInvalidException
createAndSetArtworkField in interface Tagartwork -
FieldDataInvalidException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||