001 /* PAVLOV -- Multiple Choice Study System
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/zipUtilities/SoundFileFilter.java,v 1.1 2004/05/10 15:33:22 tj_willis Exp $
019 */
020 package net.sourceforge.pavlov.zipUtilities;
021
022 import java.util.zip.ZipEntry;
023 import java.io.File;
024
025 /**
026 * A FileFilter that accepts only Audio files and zip/jar entries.
027 *
028 * @version $Revision: 1.1 $
029 */
030 public class SoundFileFilter
031 extends ZipCapableFileFilter {
032
033 /**
034 * Returns true if f is a Audio file.
035 *
036 * @param f a <code>File</code> value
037 * @return a <code>boolean</code> value
038 */
039 public boolean accept(File f) {
040 if(f==null)
041 return false;
042 return checkName(f.getName());
043
044
045 }
046
047 /**
048 * Returns true if f is a Audio file.
049 *
050 * @param f a <code>ZipEntry</code> value
051 * @return a <code>boolean</code> value
052 */
053 public boolean accept(ZipEntry f) {
054 if(f==null)
055 return false;
056 return checkName(f.getName());
057 }
058
059 /**
060 * Determines if name represents a Audio file/entry name.
061 *
062 * @param name a <code>String</code> value
063 * @return a <code>boolean</code> value
064 */
065 protected boolean checkName(String name) {
066 if(name==null)
067 return false;
068 if(name.endsWith(".au"))
069 return true;
070 if(name.endsWith(".aif"))
071 return true;
072 if(name.endsWith(".mid"))
073 return true;
074 if(name.endsWith(".rmf"))
075 return true;
076 if(name.endsWith(".wav"))
077 return true;
078 if(name.endsWith(".AU"))
079 return true;
080 if(name.endsWith(".AIF"))
081 return true;
082 if(name.endsWith(".MID"))
083 return true;
084 if(name.endsWith(".RMF"))
085 return true;
086 if(name.endsWith(".WAV"))
087 return true;
088 return false;
089 }
090
091 /**
092 * Returns description of this file filter.
093 *
094 * @return a <code>String</code> value
095 */
096 public String getDescription() {
097 return "Audio File Filter";
098 }
099
100
101 }