1 /*
2 * This file is part of NetPisteur.
3 *
4 * Copyright 2001-2002 : Olivier CORNEC, David BOUANCHEAU, Loic LOPEZ,
5 * Gaetan BOUDARD, Mael LE LANNOU, Julien ROBINEAU
6 *
7 * Copyright 2002-2003 : Olivier BRIENS, Simon DEZE, Florence FRIGOULT,
8 * Olivier JOURNEAULT, Francois MARTINIER, Damien RAUDE-MORVAN
9 *
10 * Copyright 2004-2007 : Damien RAUDE-MORVAN
11 *
12 * NetPisteur is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * NetPisteur is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with NetPisteur; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 */
27 package com.drazzib.netpisteur.util;
28
29 import java.io.File;
30
31 import javax.swing.filechooser.FileFilter;
32
33 /**
34 * @author drazzib
35 */
36 public class HTMLFileFilter extends FileFilter {
37
38 private String[] auth = { "html", "html" }; //$NON-NLS-1$ //$NON-NLS-2$
39
40 /**
41 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
42 */
43 public boolean accept(File f) {
44 String ext = f.getName();
45 ext = ext.substring(ext.lastIndexOf(".") + 1).toLowerCase(); //$NON-NLS-1$
46 boolean ret = false;
47
48 if (f.isFile()) {
49 for (int i = 0; i < this.auth.length; i++) {
50 if (ext.compareTo(this.auth[i]) == 0) {
51 ret = true;
52 }
53 }
54 } else {
55 ret = true;
56 }
57
58 return ret;
59 }
60
61 /**
62 * @see javax.swing.filechooser.FileFilter#getDescription()
63 */
64 public String getDescription() {
65 return Messages.getString("HTMLFileFilter.WEB_PAGES"); //$NON-NLS-1$
66 }
67
68 }