refactoring so that filename extensions are in one place

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@168449 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2005-05-05 22:20:49 +00:00
parent 0209ce959b
commit c97ba92ebd
3 changed files with 18 additions and 18 deletions

View File

@ -50,6 +50,16 @@ import java.util.Set;
*/
public abstract class IndexReader {
/**
* This array contains all filename extensions used by Lucene's index files, with
* one exception, namely the extension made up from <code>.f</code> + a number.
* Also note that two of Lucene's files (<code>deletable</code> and
* <code>segments</code>) don't have any filename extension.
*/
public final static String FILENAME_EXTENSIONS[] = new String[] {
"cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del",
"tvx", "tvd", "tvf", "tvp" };
public static final class FieldOption {
private String option;
private FieldOption() { }

View File

@ -247,12 +247,9 @@ class SegmentReader extends IndexReader {
Vector files() throws IOException {
Vector files = new Vector(16);
final String ext[] = new String[]{
"cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del",
"tvx", "tvd", "tvf", "tvp" };
for (int i = 0; i < ext.length; i++) {
String name = segment + "." + ext[i];
for (int i = 0; i < FILENAME_EXTENSIONS.length; i++) {
String name = segment + "." + FILENAME_EXTENSIONS[i];
if (directory().fileExists(name))
files.addElement(name);
}

View File

@ -26,6 +26,7 @@ import java.util.Hashtable;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.util.Constants;
/**
@ -47,19 +48,11 @@ public class FSDirectory extends Directory {
* @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
*/
public boolean accept(File dir, String name) {
if (name.endsWith(".cfs")) return true;
else if (name.endsWith(".fnm")) return true;
else if (name.endsWith(".fdt")) return true;
else if (name.endsWith(".fdx")) return true;
else if (name.endsWith(".frq")) return true;
else if (name.endsWith(".prx")) return true;
else if (name.endsWith(".tii")) return true;
else if (name.endsWith(".tis")) return true;
else if (name.endsWith(".tvd")) return true;
else if (name.endsWith(".tvf")) return true;
else if (name.endsWith(".tvx")) return true;
else if (name.endsWith(".del")) return true;
else if (name.equals("deletable")) return true;
for (int i = 0; i < IndexReader.FILENAME_EXTENSIONS.length; i++) {
if (name.endsWith("."+IndexReader.FILENAME_EXTENSIONS[i]))
return true;
}
if (name.equals("deletable")) return true;
else if (name.equals("segments")) return true;
else if (name.matches(".+\\.f\\d+")) return true;
return false;