1 16 package org.apache.commons.io.filefilter; 17 18 import java.io.File ; 19 import java.io.FileFilter ; 20 import java.io.FilenameFilter ; 21 22 31 public class DelegateFileFilter extends AbstractFileFilter { 32 33 34 private FilenameFilter filenameFilter; 35 36 private FileFilter fileFilter; 37 38 43 public DelegateFileFilter(FilenameFilter filter) { 44 if (filter == null) { 45 throw new IllegalArgumentException ("The FilenameFilter must not be null"); 46 } 47 this.filenameFilter = filter; 48 } 49 50 55 public DelegateFileFilter(FileFilter filter) { 56 if (filter == null) { 57 throw new IllegalArgumentException ("The FileFilter must not be null"); 58 } 59 this.fileFilter = filter; 60 } 61 62 68 public boolean accept(File file) { 69 if (fileFilter != null) { 70 return fileFilter.accept(file); 71 } else { 72 return super.accept(file); 73 } 74 } 75 76 83 public boolean accept(File dir, String name) { 84 if (filenameFilter != null) { 85 return filenameFilter.accept(dir, name); 86 } else { 87 return super.accept(dir, name); 88 } 89 } 90 91 } 92 | Popular Tags |