FileDocCategorySizeDatePackage
IndexFileNameFilter.javaAPI DocApache Lucene 2.2.03083Sat Jun 16 22:20:36 BST 2007org.apache.lucene.index

IndexFileNameFilter

public class IndexFileNameFilter extends Object implements FilenameFilter
Filename filter that accept filenames and extensions only created by Lucene.
author
Daniel Naber / Bernhard Messer
version
$rcs = ' $Id: Exp $ ' ;

Fields Summary
static IndexFileNameFilter
singleton
private HashSet
extensions
private HashSet
extensionsInCFS
Constructors Summary
public IndexFileNameFilter()


    
    extensions = new HashSet();
    for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.length; i++) {
      extensions.add(IndexFileNames.INDEX_EXTENSIONS[i]);
    }
    extensionsInCFS = new HashSet();
    for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE.length; i++) {
      extensionsInCFS.add(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]);
    }
  
Methods Summary
public booleanaccept(java.io.File dir, java.lang.String name)

    int i = name.lastIndexOf('.");
    if (i != -1) {
      String extension = name.substring(1+i);
      if (extensions.contains(extension)) {
        return true;
      } else if (extension.startsWith("f") &&
                 extension.matches("f\\d+")) {
        return true;
      } else if (extension.startsWith("s") &&
                 extension.matches("s\\d+")) {
        return true;
      }
    } else {
      if (name.equals(IndexFileNames.DELETABLE)) return true;
      else if (name.startsWith(IndexFileNames.SEGMENTS)) return true;
    }
    return false;
  
public static org.apache.lucene.index.IndexFileNameFiltergetFilter()

    return singleton;
  
public booleanisCFSFile(java.lang.String name)
Returns true if this is a file that would be contained in a CFS file. This function should only be called on files that pass the above "accept" (ie, are already known to be a Lucene index file).

    int i = name.lastIndexOf('.");
    if (i != -1) {
      String extension = name.substring(1+i);
      if (extensionsInCFS.contains(extension)) {
        return true;
      }
      if (extension.startsWith("f") &&
          extension.matches("f\\d+")) {
        return true;
      }
    }
    return false;