FileDocCategorySizeDatePackage
AbstractID3v1Tag.javaAPI DocJaudiotagger 2.0.45154Wed Jun 08 12:05:40 BST 2011org.jaudiotagger.tag.id3

AbstractID3v1Tag

public abstract class AbstractID3v1Tag extends AbstractID3Tag
This is the abstract base class for all ID3v1 tags.
author
: Eric Farng
author
: Paul Taylor

Fields Summary
public static Logger
logger
protected static final byte
END_OF_FIELD
protected static Pattern
endofStringPattern
protected static final byte[]
TAG_ID
protected static final int
TAG_LENGTH
protected static final int
TAG_DATA_LENGTH
protected static final int
FIELD_TAGID_LENGTH
protected static final int
FIELD_TITLE_LENGTH
protected static final int
FIELD_ARTIST_LENGTH
protected static final int
FIELD_ALBUM_LENGTH
protected static final int
FIELD_YEAR_LENGTH
protected static final int
FIELD_GENRE_LENGTH
protected static final int
FIELD_TAGID_POS
protected static final int
FIELD_TITLE_POS
protected static final int
FIELD_ARTIST_POS
protected static final int
FIELD_ALBUM_POS
protected static final int
FIELD_YEAR_POS
protected static final int
FIELD_GENRE_POS
protected static final String
TYPE_TITLE
protected static final String
TYPE_ARTIST
protected static final String
TYPE_ALBUM
protected static final String
TYPE_YEAR
protected static final String
TYPE_GENRE
Constructors Summary
public AbstractID3v1Tag()



     
    
    
public AbstractID3v1Tag(AbstractID3v1Tag copyObject)

        super(copyObject);
    
Methods Summary
public voiddelete(java.io.RandomAccessFile file)
Delete tag from file Looks for tag and if found lops it off the file.

param
file to delete the tag from
throws
IOException if there was a problem accessing the file

        //Read into Byte Buffer
        logger.config("Deleting ID3v1 from file if exists");

        FileChannel fc;
        ByteBuffer byteBuffer;
        fc = file.getChannel();

        if(file.length() < TAG_LENGTH)
        {
            throw new IOException("File not not appear large enough to contain a tag");
        }
        fc.position(file.length() - TAG_LENGTH);
        byteBuffer = ByteBuffer.allocate(TAG_LENGTH);
        fc.read(byteBuffer);
        byteBuffer.rewind();
        if (AbstractID3v1Tag.seekForV1OrV11Tag(byteBuffer))
        {
            logger.config("Deleted ID3v1 tag");
            file.setLength(file.length() - TAG_LENGTH);
        }
        else
        {
            logger.config("Unable to find ID3v1 tag to deleteField");
        }
    
public intgetSize()
Return the size of this tag, the size is fixed for tags of this type

return
size of this tag in bytes


                               
      
    
        return TAG_LENGTH;
    
public static booleanseekForV1OrV11Tag(java.nio.ByteBuffer byteBuffer)
Does a v1tag or a v11tag exist

return
whether tag exists 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));