FileDocCategorySizeDatePackage
NumberedRepositoryFileFilter.javaAPI DocApache James 2.3.12580Fri Jan 12 12:56:24 GMT 2007org.apache.james.mailrepository.filepair

NumberedRepositoryFileFilter

public class NumberedRepositoryFileFilter extends Object implements FilenameFilter
This filters files based on the extension and is tailored to provide backwards compatibility of the numbered repositories that Avalon does.

Fields Summary
private String
postfix
private String
prefix
Constructors Summary
public NumberedRepositoryFileFilter(String extension)

        postfix = extension;
        prefix = "." + RepositoryManager.getName();
    
Methods Summary
public booleanaccept(java.io.File file, java.lang.String name)

        //System.out.println("check: " + name);
        //System.out.println("post: " + postfix);
        if (!name.endsWith(postfix)) {
            return false;
        }
        //Look for a couple of digits next
        int pos = name.length() - postfix.length();
        //We have to find at least one digit... if not then this isn't what we want
        if (!Character.isDigit(name.charAt(pos - 1))) {
            return false;
        }
        pos--;
        while (pos >= 1 && Character.isDigit(name.charAt(pos - 1))) {
            //System.out.println("back one");
            pos--;
        }
        //System.out.println("sub: " + name.substring(0, pos));
        //Now want to check that we match the rest
        return name.substring(0, pos).endsWith(prefix);