FileDocCategorySizeDatePackage
AudioFileFilter.javaAPI DocJaudiotagger 2.0.42644Wed Mar 30 16:11:54 BST 2011org.jaudiotagger.audio

AudioFileFilter

public class AudioFileFilter extends Object implements FileFilter

This is a simple FileFilter that will only allow the file supported by this library.

It will also accept directories. An additional condition is that file must be readable (read permission) and are not hidden (dot files, or hidden files)

author
Raphael Slinckx
version
$Id: AudioFileFilter.java 836 2009-11-12 15:44:07Z paultaylor $
since
v0.01

Fields Summary
private final boolean
allowDirectories
allows Directories
Constructors Summary
public AudioFileFilter(boolean allowDirectories)

        this.allowDirectories=allowDirectories;
    
public AudioFileFilter()

        this(true);
    
Methods Summary
public booleanaccept(java.io.File f)

Check whether the given file meet the required conditions (supported by the library OR directory). The File must also be readable and not hidden.

param
f The file to test
return
a boolean indicating if the file is accepted or not

        if (f.isHidden() || !f.canRead())
        {
            return false;
        }

        if (f.isDirectory())
        {
            return allowDirectories;
        }

        String ext = Utils.getExtension(f);

        try
        {
            if (SupportedFileFormat.valueOf(ext.toUpperCase()) != null)
            {
                return true;
            }
        }
        catch(IllegalArgumentException iae)
        {
            //Not known enum value
            return false;    
        }
        return false;