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/HTMLFileFilter.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 HTML files. 027 * 028 * @version $Revision: 1.1 $ 029 */ 030 public class HTMLFileFilter 031 extends ZipCapableFileFilter { 032 033 /** 034 * Returns true if f is a HTML 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 JPEG 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 JPEG 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(".htm")) 069 return true; 070 if(name.endsWith(".HTM")) 071 return true; 072 if(name.endsWith(".html")) 073 return true; 074 if(name.endsWith(".HTML")) 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 "HTML File Filter"; 086 } 087 088 089 }