KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lucene > index > IndexFileNameFilter


1 package org.apache.lucene.index;
2
3 /**
4  * Copyright 2005 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.io.File JavaDoc;
20 import java.io.FilenameFilter JavaDoc;
21
22 /**
23  * Filename filter that accept filenames and extensions only created by Lucene.
24  *
25  * @author Daniel Naber / Bernhard Messer
26  * @version $rcs = ' $Id: Exp $ ' ;
27  */

28 public class IndexFileNameFilter implements FilenameFilter JavaDoc {
29
30   /* (non-Javadoc)
31    * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
32    */

33   public boolean accept(File JavaDoc dir, String JavaDoc name) {
34     for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.length; i++) {
35       if (name.endsWith("."+IndexFileNames.INDEX_EXTENSIONS[i]))
36         return true;
37     }
38     if (name.equals(IndexFileNames.DELETABLE)) return true;
39     else if (name.equals(IndexFileNames.SEGMENTS)) return true;
40     else if (name.matches(".+\\.f\\d+")) return true;
41     return false;
42   }
43
44 }
45
Popular Tags