View Javadoc

1   package com.melloware.jukes.file.filter;
2   
3   import java.io.File;
4   
5   import javax.swing.filechooser.FileFilter;
6   
7   import org.apache.commons.io.FilenameUtils;
8   
9   /**
10   * Filters for M3U "winamp" files in JFileChooser.  Such as .m3u files.
11   * <p>
12   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
13   * @author Emil A. Lefkof III <info@melloware.com>
14   * @version 4.0
15   */
16  public final class M3uFilter extends FileFilter {
17      
18      public final static String M3U = "m3u";
19      public final static String[] EXTENSIONS = new String[] {M3U};
20      
21      /**
22       * Default Constuctor
23       */
24      public M3uFilter() {
25          super();
26      }
27  
28      /**
29       * Accept all music files such as .m3u.
30       * <p>
31       * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
32       */
33      public boolean accept(final File aFile) {
34          if (aFile.isDirectory()) {
35              return true;
36          }
37          
38          return FilenameUtils.isExtension(aFile.getName().toLowerCase(),EXTENSIONS);
39      }
40  
41      /* (non-Javadoc)
42       * @see javax.swing.filechooser.FileFilter#getDescription()
43       */
44      public String getDescription() {
45          return "M3U 'Winamp' Files (*.m3u)";
46      }
47      
48      
49  
50  }