/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.nplusc.izc.tools.baseTools;

import de.nplusc.izc.tools.IOtools.FileTK;
import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author LH
 */
public class FIleLImiter extends FileFilter
{

    private String[] availExts;

    @Override
    public boolean accept(File f)
    {
        //f.getName().endsWith(".txt")
        try
        {
            for (String aex : availExts)
            {
                if(FileTK.getFileExt(f.toString()).toLowerCase().equalsIgnoreCase(aex))
                    return true;
            }
        }
        catch(Exception e)
        {
            
        }
        return f.isDirectory();
    }

    @Override
    public String getDescription()
    {
        String ret = "Verzeicnisse ";
        //        return "*.txt *.java *.xml";
        try
        {
            for (String dir : availExts)
            {
                ret += "*." + dir;
            }
        }
        catch (Exception e)
        {
        }
        return ret +";";
    }

    public void setExtensions(String[] exts)
    {
        availExts = exts;
    }
}
