Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

EDLFileFilter.java

00001 /*
00002  *  Copyright 2006-2007 Columbia University.
00003  *
00004  *  This file is part of MEAPsoft.
00005  *
00006  *  MEAPsoft is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License version 2 as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  MEAPsoft is distributed in the hope that it will be useful, but
00011  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with MEAPsoft; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00018  *  02110-1301 USA
00019  *
00020  *  See the file "COPYING" for the text of the license.
00021  */
00022 
00023 package com.meapsoft.gui;
00024 
00025 import java.io.File;
00026 import javax.swing.filechooser.FileFilter;
00027 
00028 /* ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
00029 public class EDLFileFilter extends FileFilter {
00030 
00031     //Accept all directories and only .wav files.
00032     public boolean accept(File f) {
00033         if (f.isDirectory()) {
00034             return true;
00035         }
00036 
00037         String extension = getExtension(f);
00038         if (extension != null) 
00039         {
00040             if (extension.equals("edl") || extension.equals("EDL"))
00041             {
00042                     return true;
00043             } 
00044             else 
00045             {
00046                 return false;
00047             }
00048         }
00049 
00050         return false;
00051     }
00052 
00053         /*
00054          * Get the extension of a file.
00055          */  
00056         public static String getExtension(File f) {
00057                 String ext = null;
00058                 String s = f.getName();
00059                 int i = s.lastIndexOf('.');
00060 
00061                 if (i > 0 &&  i < s.length() - 1) {
00062                         ext = s.substring(i+1).toLowerCase();
00063                 }
00064                 return ext;
00065         }
00066         
00067     //The description of this filter
00068     public String getDescription() {
00069         return "*.edl";
00070     }
00071 }

Generated on Tue Feb 6 19:02:26 2007 for MEAPsoft by doxygen1.2.18