Methods Summary |
---|
public void | addAudioFileModificationListener(AudioFileModificationListener listener)Adds an listener for all file formats.
this.modificationHandler.addAudioFileModificationListener(listener);
|
public void | checkFileExists(java.io.File file)Check does file exist
logger.config("Reading file:" + "path" + file.getPath() + ":abs:" + file.getAbsolutePath());
if (!file.exists())
{
logger.severe("Unable to find:" + file.getPath());
throw new FileNotFoundException(ErrorMessage.UNABLE_TO_FIND_FILE.getMsg(file.getPath()));
}
|
public static void | delete(AudioFile f)
Delete the tag, if any, contained in the given file.
getDefaultAudioFileIO().deleteTag(f);
|
public void | deleteTag(AudioFile f)
Delete the tag, if any, contained in the given file.
String ext = Utils.getExtension(f.getFile());
Object afw = writers.get(ext);
if (afw == null)
{
throw new CannotWriteException(ErrorMessage.NO_DELETER_FOR_THIS_FORMAT.getMsg(ext));
}
((AudioFileWriter) afw).delete(f);
|
public static org.jaudiotagger.audio.AudioFileIO | getDefaultAudioFileIO()This method returns the default instance for static use.
if (defaultInstance == null)
{
defaultInstance = new AudioFileIO();
}
return defaultInstance;
|
private void | prepareReadersAndWriters()Creates the readers and writers.
// Tag Readers
readers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileReader());
readers.put(SupportedFileFormat.FLAC.getFilesuffix(),new FlacFileReader());
readers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileReader());
readers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileReader());
readers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileReader());
readers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileReader());
readers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileReader());
readers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileReader());
readers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileReader());
final RealFileReader realReader = new RealFileReader();
readers.put(SupportedFileFormat.RA.getFilesuffix(), realReader);
readers.put(SupportedFileFormat.RM.getFilesuffix(), realReader);
// Tag Writers
writers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileWriter());
writers.put(SupportedFileFormat.FLAC.getFilesuffix(), new FlacFileWriter());
writers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileWriter());
writers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileWriter());
writers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileWriter());
writers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileWriter());
writers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileWriter());
writers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileWriter());
writers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileWriter());
// Register modificationHandler
Iterator<AudioFileWriter> it = writers.values().iterator();
for (AudioFileWriter curr : writers.values())
{
curr.setAudioFileModificationListener(this.modificationHandler);
}
|
public static AudioFile | read(java.io.File f)
Read the tag contained in the given file.
return getDefaultAudioFileIO().readFile(f);
|
public AudioFile | readFile(java.io.File f)
Read the tag contained in the given file.
checkFileExists(f);
String ext = Utils.getExtension(f);
AudioFileReader afr = readers.get(ext);
if (afr == null)
{
throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext));
}
return afr.read(f);
|
public void | removeAudioFileModificationListener(AudioFileModificationListener listener)Removes an listener for all file formats.
this.modificationHandler.removeAudioFileModificationListener(listener);
|
public static void | write(AudioFile f)
Write the tag contained in the audioFile in the actual file on the disk.
getDefaultAudioFileIO().writeFile(f);
|
public void | writeFile(AudioFile f)
Write the tag contained in the audioFile in the actual file on the disk.
String ext = Utils.getExtension(f.getFile());
AudioFileWriter afw = writers.get(ext);
if (afw == null)
{
throw new CannotWriteException(ErrorMessage.NO_WRITER_FOR_THIS_FORMAT.getMsg(ext));
}
afw.write(f);
|