1 16 package org.apache.commons.io.filefilter; 17 18 import java.io.FileFilter ; 19 import java.io.FilenameFilter ; 20 21 33 public class FileFilterUtils { 34 35 38 public FileFilterUtils() { 39 } 40 41 48 public static IOFileFilter prefixFileFilter(String prefix) { 49 return new PrefixFileFilter(prefix); 50 } 51 52 58 public static IOFileFilter suffixFileFilter(String suffix) { 59 return new SuffixFileFilter(suffix); 60 } 61 62 68 public static IOFileFilter nameFileFilter(String name) { 69 return new NameFileFilter(name); 70 } 71 72 77 public static IOFileFilter directoryFileFilter() { 78 return DirectoryFileFilter.INSTANCE; 79 } 80 81 89 public static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filter2) { 90 return new AndFileFilter(filter1, filter2); 91 } 92 93 100 public static IOFileFilter orFileFilter(IOFileFilter filter1, IOFileFilter filter2) { 101 return new OrFileFilter(filter1, filter2); 102 } 103 104 110 public static IOFileFilter notFileFilter(IOFileFilter filter) { 111 return new NotFileFilter(filter); 112 } 113 114 120 public static IOFileFilter trueFileFilter() { 121 return TrueFileFilter.INSTANCE; 122 } 123 124 129 public static IOFileFilter falseFileFilter() { 130 return FalseFileFilter.INSTANCE; 131 } 132 133 141 public static IOFileFilter asFileFilter(FileFilter filter) { 142 return new DelegateFileFilter(filter); 143 } 144 145 152 public static IOFileFilter asFileFilter(FilenameFilter filter) { 153 return new DelegateFileFilter(filter); 154 } 155 156 158 159 private static IOFileFilter cvsFilter = null; 160 161 169 public static IOFileFilter makeCVSAware(IOFileFilter filter) { 170 if (cvsFilter == null) { 171 cvsFilter = andFileFilter(directoryFileFilter(), 172 notFileFilter(nameFileFilter("CVS"))); 173 } 174 if (filter == null) { 175 return cvsFilter; 176 } else { 177 return andFileFilter(filter, cvsFilter); 178 } 179 } 180 181 } 182
| Popular Tags
|