de.vdheide.mp3
Class ID3

java.lang.Object
  extended byde.vdheide.mp3.ID3

public class ID3
extends java.lang.Object

Class to read and modify ID3 tags on MP3 files.

ID3 information is loaded

ID3 information is written

If a file does not contain an ID3 tag, each read access will throw a NoID3TagException. A write access will create an ID3 tag if none is present.


Constructor Summary
ID3(java.io.File mp3_file)
          Create a new ID3 tag which is based on mp3_file
 
Method Summary
 boolean checkForTag()
          Check if ID3 tag is present
 java.lang.String getAlbum()
          Read album from ID3 tag
 java.lang.String getArtist()
          Read artist from ID3 tag
 java.lang.String getComment()
          Read comment from ID3 tag
 int getGenre()
          Read genre from ID3 tag
 java.lang.String getTitle()
          Read title from ID3 tag
 int getTrack()
          Read track number from ID3 tag
 java.lang.String getYear()
          Read year from ID3 tag
 void readTag()
          Read ID3 tag and prepare for retrieval with getXXX.
 void setAlbum(java.lang.String album)
          Set album
 void setArtist(java.lang.String artist)
          Set artist
 void setComment(java.lang.String comment)
          Set comment
 void setGenre(int genre)
          Set genre
 void setTitle(java.lang.String title)
          Set title
 void setTrack(int track)
          Set track number
 void setYear(java.lang.String year)
          Set year
 void writeTag()
          Write information provided with setXXX to ID3 tag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ID3

public ID3(java.io.File mp3_file)
Create a new ID3 tag which is based on mp3_file

Parameters:
mp3_file - MP3 file to read ID3 tag to / write ID3 tag to
Method Detail

getTitle

public java.lang.String getTitle()
                          throws NoID3TagException
Read title from ID3 tag

Returns:
Title
Throws:
NoID3TagException - If file does not contain an ID3 tag

getArtist

public java.lang.String getArtist()
                           throws NoID3TagException
Read artist from ID3 tag

Returns:
Artist
Throws:
NoID3TagException - If file does not contain an ID3 tag

getAlbum

public java.lang.String getAlbum()
                          throws NoID3TagException
Read album from ID3 tag

Returns:
album
Throws:
NoID3TagException - If file does not contain an ID3 tag

getYear

public java.lang.String getYear()
                         throws NoID3TagException
Read year from ID3 tag

Returns:
Year
Throws:
NoID3TagException - If file does not contain an ID3 tag

getGenre

public int getGenre()
             throws NoID3TagException
Read genre from ID3 tag

Returns:
Genre
Throws:
NoID3TagException - If file does not contain an ID3 tag

getComment

public java.lang.String getComment()
                            throws NoID3TagException
Read comment from ID3 tag

Returns:
comment
Throws:
NoID3TagException - If file does not contain an ID3 tag

getTrack

public int getTrack()
             throws NoID3TagException
Read track number from ID3 tag

Returns:
Track number
Throws:
NoID3TagException - If file does not contain an ID3 tag

readTag

public void readTag()
             throws NoID3TagException,
                    java.io.IOException
Read ID3 tag and prepare for retrieval with getXXX. Use this method to reread tag if changed externally

Throws:
NoID3TagException - If file does not contain an ID3 tag
java.io.IOException - If I/O error occurs

setTitle

public void setTitle(java.lang.String title)
Set title

Parameters:
title - Title

setArtist

public void setArtist(java.lang.String artist)
Set artist

Parameters:
artist - Artist

setAlbum

public void setAlbum(java.lang.String album)
Set album

Parameters:
album - Album

setYear

public void setYear(java.lang.String year)
Set year

Parameters:
year - Year

setComment

public void setComment(java.lang.String comment)
Set comment

Parameters:
comment - Comment

setTrack

public void setTrack(int track)
              throws ID3IllegalFormatException
Set track number

Parameters:
track - Track number
Throws:
ID3IllegalFormatException - if track is negative or larger than 255

setGenre

public void setGenre(int genre)
              throws ID3IllegalFormatException
Set genre

Parameters:
genre - Genre
Throws:
ID3IllegalFormatException - if genre is negative or larger than 255

writeTag

public void writeTag()
              throws java.io.IOException
Write information provided with setXXX to ID3 tag

Throws:
java.io.IOException

checkForTag

public boolean checkForTag()
                    throws java.io.IOException
Check if ID3 tag is present

Returns:
true if tag present
Throws:
java.io.IOException