/*
 * Decompiled with CFR 0_132.
 */
package save;

import java.io.File;
import javax.swing.filechooser.FileFilter;

public class Filter
extends FileFilter {
    private String extension = ".chr";
    private String description = "Chronogram File";

    public Filter(String ext, String descrip) {
        this.extension = ext;
        this.description = descrip;
    }

    @Override
    public boolean accept(File file) {
        String temp = this.removeChar(this.extension, ' ');
        String[] exts = temp.split(",");
        boolean res = file.isDirectory();
        int i = 0;
        while (i < exts.length) {
            res = res || file.getName().endsWith(exts[i]);
            ++i;
        }
        return res;
    }

    @Override
    public String getDescription() {
        return String.valueOf(this.extension) + " - " + this.description;
    }

    public String removeChar(String s, char c) {
        String res = "";
        int i = 0;
        while (i < s.length()) {
            if (s.charAt(i) != c) {
                res = String.valueOf(res) + s.charAt(i);
            }
            ++i;
        }
        return res;
    }
}

