com.melloware.jukes.file.tag
Class Mp3Tag

java.lang.Object
  extended by com.melloware.jukes.file.tag.MusicTag
      extended by com.melloware.jukes.file.tag.Mp3Tag
All Implemented Interfaces:
ITag, java.lang.Comparable

public final class Mp3Tag
extends MusicTag

MusicTag class used for editing MP3 file tags. Both version ID3v1.1 and IDv2.4 are supported.

The JAudioTagger (https://jaudiotagger.dev.java.net/) library is used to read these types of Tags.

Copyright (c) 2006 Melloware, Inc.

Version:
4.0
Author:
Emil A. Lefkof III

Field Summary
static java.lang.String V2_CODE_ALBUM
           
static java.lang.String V2_CODE_ARTIST
           
static java.lang.String V2_CODE_COMMENT
           
static java.lang.String V2_CODE_ENCODE
           
static java.lang.String V2_CODE_GENRE
           
static java.lang.String V2_CODE_LENGTH
           
static java.lang.String V2_CODE_TITLE
           
static java.lang.String V2_CODE_TRACK
           
static java.lang.String V2_CODE_YEAR
           
 
Fields inherited from class com.melloware.jukes.file.tag.MusicTag
artist, bitRate, comment, CURRENT_YEAR, DEFAULT_FILE_FORMAT, disc, encodedBy, file, genre, header, NO_TAG, title, track, trackLength, year
 
Constructor Summary
Mp3Tag(java.io.File aFile)
          Constructor that takes a file.
 
Method Summary
 java.lang.String getArtist()
          Gets the artist.
 java.lang.Long getBitRate()
          Gets the maximum bitrate for this file.
 java.lang.String getComment()
          Gets the comment.
 java.lang.String getCopyrighted()
           
 java.lang.String getDisc()
          Gets the disc.
 java.lang.String getEmphasis()
           
 java.lang.String getEncodedBy()
          Gets the encodedBy.
 java.lang.String getFrequency()
           
 java.lang.String getGenre()
          Gets the genre.
 java.util.Map getHeader()
          Gets the header.
 java.lang.String getLayer()
           
 java.lang.String getMode()
           
 java.lang.String getTitle()
          Gets the title.
 java.lang.String getTrack()
          Gets the track.
 long getTrackLength()
          Gets the track length in seconds.
 java.lang.String getVersion()
           
 java.lang.String getYear()
          Gets the year.
 boolean isVBR()
          Is this file a variable bit rate.
 void removeTags()
          Removes tags from the audio file.
 boolean renameFile(java.lang.String aFormat)
          Renames this Music file based on a format from prefs.
 void save()
          Saves the tag back to the file.
 void setArtist(java.lang.String aArtist)
          Sets the artist.
 void setComment(java.lang.String aComment)
          Sets the comment.
 void setDisc(java.lang.String aDisc)
          Sets the disc.
 void setEncodedBy(java.lang.String aEncodedBy)
          Sets the Encoded By.
 void setGenre(java.lang.String aGenre)
          Sets the genre.
 void setTitle(java.lang.String aTitle)
          Sets the title.
 void setTrack(java.lang.String aTrack)
          Sets the track.
 void setTrack(java.lang.String aTrack, int aPadding)
          Sets the track.
 void setTrackLength(long aTrackLength)
          Sets the trackLength.
 void setYear(java.lang.String aYear)
          Sets the year.
 
Methods inherited from class com.melloware.jukes.file.tag.MusicTag
compareTo, createFilenameFromFormat, equals, extractTitleFromFilename, fileExists, getAbsolutePath, getBitRateAsString, getFile, getGenreTypes, getHeaderInfo, getHeaderValue, getTrackLengthAsString, hashCode, renameFile, synchronize, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

V2_CODE_ALBUM

public static final java.lang.String V2_CODE_ALBUM
See Also:
Constant Field Values

V2_CODE_TITLE

public static final java.lang.String V2_CODE_TITLE
See Also:
Constant Field Values

V2_CODE_ARTIST

public static final java.lang.String V2_CODE_ARTIST
See Also:
Constant Field Values

V2_CODE_YEAR

public static final java.lang.String V2_CODE_YEAR
See Also:
Constant Field Values

V2_CODE_COMMENT

public static final java.lang.String V2_CODE_COMMENT
See Also:
Constant Field Values

V2_CODE_GENRE

public static final java.lang.String V2_CODE_GENRE
See Also:
Constant Field Values

V2_CODE_TRACK

public static final java.lang.String V2_CODE_TRACK
See Also:
Constant Field Values

V2_CODE_ENCODE

public static final java.lang.String V2_CODE_ENCODE
See Also:
Constant Field Values

V2_CODE_LENGTH

public static final java.lang.String V2_CODE_LENGTH
See Also:
Constant Field Values
Constructor Detail

Mp3Tag

public Mp3Tag(java.io.File aFile)
       throws MusicTagException
Constructor that takes a file.

Parameters:
aFile - the music file
Throws:
MusicTagException - if any error occurs reading file
Method Detail

getArtist

public java.lang.String getArtist()
Gets the artist.

Specified by:
getArtist in interface ITag
Specified by:
getArtist in class MusicTag
Returns:
Returns the artist.

getBitRate

public java.lang.Long getBitRate()
Gets the maximum bitrate for this file.

Specified by:
getBitRate in interface ITag
Specified by:
getBitRate in class MusicTag
Returns:
Returns the maximum bitrate for this file

getComment

public java.lang.String getComment()
Gets the comment.

Specified by:
getComment in interface ITag
Specified by:
getComment in class MusicTag
Returns:
Returns the comment.

getCopyrighted

public java.lang.String getCopyrighted()
Specified by:
getCopyrighted in interface ITag
Specified by:
getCopyrighted in class MusicTag

getDisc

public java.lang.String getDisc()
Gets the disc.

Specified by:
getDisc in interface ITag
Specified by:
getDisc in class MusicTag
Returns:
Returns the disc.

getEmphasis

public java.lang.String getEmphasis()
Specified by:
getEmphasis in interface ITag
Specified by:
getEmphasis in class MusicTag

getEncodedBy

public java.lang.String getEncodedBy()
Gets the encodedBy.

Specified by:
getEncodedBy in interface ITag
Specified by:
getEncodedBy in class MusicTag
Returns:
Returns the encodedBy.

getFrequency

public java.lang.String getFrequency()
Specified by:
getFrequency in interface ITag
Specified by:
getFrequency in class MusicTag

getGenre

public java.lang.String getGenre()
Gets the genre.

Specified by:
getGenre in interface ITag
Specified by:
getGenre in class MusicTag
Returns:
Returns the genre.

getHeader

public java.util.Map getHeader()
Description copied from class: MusicTag
Gets the header.

Specified by:
getHeader in interface ITag
Specified by:
getHeader in class MusicTag
Returns:
Returns the header.

getLayer

public java.lang.String getLayer()
Specified by:
getLayer in interface ITag
Specified by:
getLayer in class MusicTag

getMode

public java.lang.String getMode()
Specified by:
getMode in interface ITag
Specified by:
getMode in class MusicTag

getTitle

public java.lang.String getTitle()
Gets the title.

Specified by:
getTitle in interface ITag
Specified by:
getTitle in class MusicTag
Returns:
Returns the title.

getTrack

public java.lang.String getTrack()
Gets the track.

Specified by:
getTrack in interface ITag
Specified by:
getTrack in class MusicTag
Returns:
Returns the track.

getTrackLength

public long getTrackLength()
Gets the track length in seconds.

Specified by:
getTrackLength in interface ITag
Specified by:
getTrackLength in class MusicTag
Returns:
Returns the track length in seconds.

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface ITag
Specified by:
getVersion in class MusicTag

getYear

public java.lang.String getYear()
Gets the year.

Specified by:
getYear in interface ITag
Specified by:
getYear in class MusicTag
Returns:
Returns the year.

setArtist

public void setArtist(java.lang.String aArtist)
Sets the artist.

Specified by:
setArtist in interface ITag
Specified by:
setArtist in class MusicTag
Parameters:
aArtist - The artist to set.

setComment

public void setComment(java.lang.String aComment)
Sets the comment.

Specified by:
setComment in interface ITag
Specified by:
setComment in class MusicTag
Parameters:
aComment - The comment to set.

setDisc

public void setDisc(java.lang.String aDisc)
Sets the disc.

Specified by:
setDisc in interface ITag
Specified by:
setDisc in class MusicTag
Parameters:
aDisc - The disc to set.

setEncodedBy

public void setEncodedBy(java.lang.String aEncodedBy)
Sets the Encoded By.

Specified by:
setEncodedBy in interface ITag
Specified by:
setEncodedBy in class MusicTag
Parameters:
aEncodedBy - The encoded by to set.

setGenre

public void setGenre(java.lang.String aGenre)
Sets the genre.

Specified by:
setGenre in interface ITag
Specified by:
setGenre in class MusicTag
Parameters:
aGenre - The genre to set.

setTitle

public void setTitle(java.lang.String aTitle)
Sets the title.

Specified by:
setTitle in interface ITag
Specified by:
setTitle in class MusicTag
Parameters:
aTitle - The title to set.

setTrack

public void setTrack(java.lang.String aTrack)
Sets the track.

Specified by:
setTrack in interface ITag
Specified by:
setTrack in class MusicTag
Parameters:
aTrack - The track to set.

setTrack

public void setTrack(java.lang.String aTrack,
                     int aPadding)
Sets the track.

Specified by:
setTrack in interface ITag
Specified by:
setTrack in class MusicTag
Parameters:
aTrack - The track to set.
aPadding - the number of 0's to pad this track with

setTrackLength

public void setTrackLength(long aTrackLength)
Sets the trackLength.

Specified by:
setTrackLength in class MusicTag
Parameters:
aTrackLength - The trackLength to set.

setYear

public void setYear(java.lang.String aYear)
Sets the year.

Specified by:
setYear in interface ITag
Specified by:
setYear in class MusicTag
Parameters:
aYear - The year to set.

isVBR

public boolean isVBR()
Is this file a variable bit rate.

Specified by:
isVBR in interface ITag
Specified by:
isVBR in class MusicTag
Returns:
true if variable false if constant bit rate

removeTags

public void removeTags()
                throws MusicTagException
Removes tags from the audio file.

Specified by:
removeTags in class MusicTag
Throws:
MusicTagException - if any error occurs removing the tag

renameFile

public boolean renameFile(java.lang.String aFormat)
Renames this Music file based on a format from prefs. The format is in aFormat and can have values %n for track number, %t for title, %a for artist, and %d for disc. Replaces any invalid characters (\\, /, :, , *, ?, ", <, >, or |) with underscores _ to prevent any errors on file systems. Examples: %n -%t = 01 - Track.mp3 %a - %d - %n - %t = Artist - Album - 01 - Track.mp3

Specified by:
renameFile in class MusicTag
Parameters:
aFormat - the string format like %n -%t to rename 01 - Track.mp3
Returns:
true if renamed, false if failure

save

public void save()
          throws MusicTagException
Saves the tag back to the file.

Specified by:
save in class MusicTag
Throws:
MusicTagException - if any error occurs saving the file


Copyright © 1999-2008 Melloware Inc. All Rights Reserved.