1 17 18 package org.apache.james.mailrepository.filepair; 19 20 import java.io.File ; 21 import java.io.FilenameFilter ; 22 23 28 public class NumberedRepositoryFileFilter implements FilenameFilter { 29 private String postfix; 30 private String prefix; 31 32 public NumberedRepositoryFileFilter(final String extension) { 33 postfix = extension; 34 prefix = "." + RepositoryManager.getName(); 35 } 36 37 public boolean accept(final File file, final String name) { 38 if (!name.endsWith(postfix)) { 41 return false; 42 } 43 int pos = name.length() - postfix.length(); 45 if (!Character.isDigit(name.charAt(pos - 1))) { 47 return false; 48 } 49 pos--; 50 while (pos >= 1 && Character.isDigit(name.charAt(pos - 1))) { 51 pos--; 53 } 54 return name.substring(0, pos).endsWith(prefix); 57 } 58 } 59 60 61 | Popular Tags |