KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > jwi > jgallery > DirectoriesFilter


1 package de.jwi.jgallery;
2
3 /*
4  * jGallery - Java web application to display image galleries
5  *
6  * Copyright (C) 2004 Juergen Weber
7  *
8  * This file is part of jGallery.
9  *
10  * jGallery is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * jGallery is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with jGallery; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston
23  */

24
25 import java.io.File JavaDoc;
26
27 /**
28  * @author Jürgen Weber
29  * Source file created on 28.02.2004
30  *
31  */

32 public class DirectoriesFilter implements java.io.FilenameFilter JavaDoc
33 {
34     private String JavaDoc thumbsDirName;
35     private String JavaDoc ignoreFileName;
36     
37     public DirectoriesFilter(String JavaDoc thumbsDirName,String JavaDoc ignoreFileName)
38     {
39         this.thumbsDirName=thumbsDirName;
40         this.ignoreFileName=ignoreFileName;
41     }
42     public boolean accept(File JavaDoc dir, String JavaDoc name)
43     {
44         File JavaDoc f = new File JavaDoc(dir, name);
45         if (!f.isDirectory())
46         {
47             return false;
48         }
49         
50         if (thumbsDirName.equals(name)) return false;
51         
52         File JavaDoc f1 = new File JavaDoc(f,ignoreFileName);
53         if (f1.exists())
54         {
55             return false;
56         }
57
58         return true;
59     }
60 }
61
Popular Tags