Methods Summary |
---|
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()));
}
|
protected java.io.RandomAccessFile | checkFilePermissions(java.io.File file, boolean readOnly)Checks the file is accessible with the correct permissions, otherwise exception occurs
RandomAccessFile newFile;
checkFileExists(file);
// Unless opened as readonly the file must be writable
if (readOnly)
{
newFile = new RandomAccessFile(file, "r");
}
else
{
if (!file.canWrite())
{
logger.severe("Unable to write:" + file.getPath());
throw new ReadOnlyFileException(ErrorMessage.NO_PERMISSIONS_TO_WRITE_TO_FILE.getMsg(file.getPath()));
}
newFile = new RandomAccessFile(file, "rws");
}
return newFile;
|
public void | commit()Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the AudioFileIO.write(this) method.
AudioFileIO.write(this);
|
public org.jaudiotagger.tag.Tag | createDefaultTag()Create Default Tag
if(SupportedFileFormat.FLAC.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new FlacTag(VorbisCommentTag.createNewTag(), new ArrayList< MetadataBlockDataPicture >());
}
else if(SupportedFileFormat.OGG.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return VorbisCommentTag.createNewTag();
}
else if(SupportedFileFormat.MP4.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new Mp4Tag();
}
else if(SupportedFileFormat.M4A.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new Mp4Tag();
}
else if(SupportedFileFormat.M4P.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new Mp4Tag();
}
else if(SupportedFileFormat.WMA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new AsfTag();
}
else if(SupportedFileFormat.WAV.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new WavTag();
}
else if(SupportedFileFormat.RA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new RealTag();
}
else if(SupportedFileFormat.RM.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('."))))
{
return new RealTag();
}
else
{
throw new RuntimeException("Unable to create default tag for this file format");
}
|
public java.lang.String | displayStructureAsPlainText()Optional debugging method
return "";
|
public java.lang.String | displayStructureAsXML()Optional debugging method
return "";
|
public AudioHeader | getAudioHeader()Return audio header
return audioHeader;
|
public static java.lang.String | getBaseFilename(java.io.File file)
int index=file.getName().toLowerCase().lastIndexOf(".");
if(index>0)
{
return file.getName().substring(0,index);
}
return file.getName();
|
public java.io.File | getFile()Retrieve the physical file
return file;
|
public org.jaudiotagger.tag.Tag | getTag()Returns the tag contained in this AudioFile, the Tag contains any useful meta-data, like
artist, album, title, etc. If the file does not contain any tag the null is returned. Some audio formats do
not allow there to be no tag so in this case the reader would return an empty tag whereas for others such
as mp3 it is purely optional.
return tag;
|
public org.jaudiotagger.tag.Tag | getTagOrCreateAndSetDefault()Get the tag or if the file doesn't have one at all, create a default tag and set it
Tag tag = getTag();
if(tag==null)
{
tag = createDefaultTag();
setTag(tag);
return tag;
}
return tag;
|
public org.jaudiotagger.tag.Tag | getTagOrCreateDefault()Get the tag or if the file doesn't have one at all, create a default tag and return
Tag tag = getTag();
if(tag==null)
{
return createDefaultTag();
}
return tag;
|
public void | setFile(java.io.File file)Set the file to store the info in
this.file = file;
|
public void | setTag(org.jaudiotagger.tag.Tag tag)
this.tag = tag;
|
public java.lang.String | toString()Returns a multi-line string with the file path, the encoding audioHeader, and the tag contents.
return "AudioFile " + getFile().getAbsolutePath()
+ " --------\n" + audioHeader.toString() + "\n" + ((tag == null) ? "" : tag.toString()) + "\n-------------------";
|