⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filefilter.java

📁 非常好用的代码源代码统计分析工具的源代码
💻 JAVA
字号:
/* * FileFilter.java - a generic file filter. * Copyright (C) 2003-2004 Rob Spoor * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */package nl.icemanx.io;import java.io.File;import java.util.*;/** * A generic file filter. * * @author Rob Spoor * @version 0.4, 2003-12-29 */public class FileFilter extends javax.swing.filechooser.FileFilter                        implements java.io.FileFilter{    /**     * A set with extensions.     */    protected Set extensions;    /**     * The description of the file filter.     */    protected String description;    /**     * Creates a generic file filter.     *     * @param extensions A set with extensions to filter on.     * @param description The description of the file filter.     */    public FileFilter(Set extensions, String description)    {        this.extensions = extensions;        this.description = description;    }    /**     * Creates a generic file filter.     *     * @param extensions An array with extensions to filter on.     * @param description The description of the file filter.     */    public FileFilter(String[] extensions, String description)    {        this(new HashSet(Arrays.asList(extensions)), description);    }    /**     * Creates a generic file filter.     *     * @param extension An extension to filter on.     * @param description The description of the file filter.     * @since 0.3     */    public FileFilter(String extension, String description)    {        this(new HashSet(Collections.singleton(extension)), description);    }    /**     * Creates a generic file filter without any extensions.     *     * @param description The description of the file filter.     * @since 0.3     */    public FileFilter(String description)    {        this(new HashSet(), description);    }    /**     * Adds an extension with a description if it was not yet present.     *     * @param extension The extension to add.     * @return This file filter.     * @since 0.3     */    public FileFilter addExtension(String extension)    {        extensions.add(extension);        return this;    }    /**     * Removes an extension with its description if it was present.     *     * @param extension The extension to remove.     * @return This file filter.     * @since 0.3     */    public FileFilter removeExtension(String extension)    {        extensions.remove(extension);        return this;    }    /**     * Whether the given file is accepted by this filter.     *     * @param f The file to check.     * @return <tt>true</tt> iff <tt>f</tt> has one of the extensions of the     *         file filter.     */    public boolean accept(File f)    {        if (f.isDirectory())        {            return true;        }        String filename = f.getName();        for (Iterator i = extensions.iterator(); i.hasNext(); )        {            if (filename.endsWith("." + i.next()))            {                return true;            }        }        return false;    }    /**     * @return The description of this filter.     * @since 0.3     */    public String getDescription()    {        return description;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -