KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > project > ProjectDirectoryFilter


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.project;
21
22 import java.io.File JavaDoc;
23 import java.io.FileFilter JavaDoc;
24 import java.io.IOException JavaDoc;
25
26
27 public class ProjectDirectoryFilter implements FileFilter JavaDoc {
28     public boolean accept(File JavaDoc input) {
29         // deny WEB-INF, META-INF, .., only directories
30
boolean accept = false;
31
32         try {
33             String JavaDoc canonpath = input.getCanonicalPath();
34
35             if (input.isDirectory() && (canonpath.indexOf("CVS") < 0)
36                     && (canonpath.indexOf("WEB-INF") < 0)
37                     && (canonpath.indexOf("META-INF") < 0)
38                     && (canonpath.indexOf("..") < 0)) {
39                 // System.out.println("potentially valid projectpath");
40
accept = true;
41             }
42         } catch (IOException JavaDoc e) {
43             e.printStackTrace();
44         }
45
46         return accept;
47     }
48 }
49
Popular Tags