Subversion Repositories general

Rev

Rev 962 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
936 dev 1
package ak.photoalbum.util;
2
 
3
import java.io.File;
4
import java.io.FileFilter;
1249 dev 5
import java.util.List;
936 dev 6
import java.util.Set;
7
import java.util.HashSet;
1249 dev 8
import java.util.Iterator;
936 dev 9
 
10
public class ImagesFilter
11
  implements FileFilter
12
{
13
  Set extentions = new HashSet();
14
 
1249 dev 15
  public ImagesFilter(List imagesMasks)
936 dev 16
  {
1249 dev 17
    for(Iterator i = imagesMasks.iterator(); i.hasNext(); ) {
18
      String mask = (String)i.next();
936 dev 19
 
1249 dev 20
      if(mask.startsWith("*.")) mask = mask.substring(2);
936 dev 21
 
1249 dev 22
      extentions.add(mask.toLowerCase());
936 dev 23
    }
24
  }
25
 
26
  public boolean accept(File pathname)
27
  {
1249 dev 28
    if(pathname.getName().startsWith(".")) // skip hidden
29
      return false;
30
 
936 dev 31
    if(pathname.isDirectory()) {
1249 dev 32
      return true;
936 dev 33
    }
34
    else{
35
      return extentions.contains(FileUtils.extractFileExt(
36
        pathname.getName().toLowerCase()));
37
    }
38
  }
39
}