package util;

import java.io.*;
import javax.swing.filechooser.FileFilter;
import java.util.*;


public class ExtensionFileFilter extends FileFilter{
   private String description="";
   private ArrayList arrayList=new ArrayList();
   
   public void addExtension(String extension){
	  if (!extension.startsWith("."))
		 extension="."+extension;
	  this.arrayList.add(extension.toLowerCase());     
   }

   public void setDescription(String description){
	  this.description = description;
   }

   public String getDescription(){
	  return description; 
   }

   public boolean accept(File file){
	  if (file.isDirectory()) return true;
	  String name = file.getName().toLowerCase();
	  for (int i = 0; i < this.arrayList.size(); i++)
		 if (name.endsWith((String)this.arrayList.get(i))) 
			return true;
	  return false;
   }
}
