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/XMLFileFilter.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 XML files.
027     *
028     * @version $Revision: 1.1 $
029     */
030    public class XMLFileFilter
031                extends ZipCapableFileFilter
032        implements java.io.FileFilter {
033    
034        /**
035         * Returns true if f is a HTML file.
036         *
037         * @param f a <code>File</code> value
038         * @return a <code>boolean</code> value
039         */
040        public  boolean accept(File f) {
041            if(f==null)
042                return false;
043            return checkName(f.getName());
044    
045    
046        }
047    
048        /**
049         * Returns true if f is a JPEG file.
050         *
051         * @param f a <code>ZipEntry</code> value
052         * @return a <code>boolean</code> value
053         */
054        public boolean accept(ZipEntry f) {
055            if(f==null)
056                return false;
057            return checkName(f.getName());
058        }
059    
060    
061        /**
062         * Determines if name represents a JPEG file/entry name.
063         *
064         * @param name a <code>String</code> value
065         * @return a <code>boolean</code> value
066         */
067        protected boolean checkName(String name) {
068            if(name==null)
069                return false;
070            if(name.endsWith(".xml"))
071                return true;
072            if(name.endsWith(".XML"))
073                return true;
074            if(name.endsWith(".Xml"))
075                return true;
076            return false;
077        }
078    
079        /**
080         * Returns description of this file filter.
081         *
082         * @return a <code>String</code> value
083         */
084        public String getDescription() {
085            return "XML File Filter";
086        }
087    
088    
089    }