- package org.jr.swing.filter;
-
- /**
- * Copyright: Copyright (c) 2002-2004
- * Company: JavaResearch(http://www.javaresearch.org)
- * 最后更新日期:2003年4月2日
- * @author Cherami
- */
-
- import java.io.*;
-
- /**
- * 文件名前后限定过滤器。
- * @since 0.6
- */
-
- public class FileNameFilter
- extends CombineFileFilter {
- String start;
- String end;
- /**
- * 根据指定参数构造一个FileNameFilter。
- * @param start 文件名的开始字符串
- * @param end 文件名的结束字符串
- * @param type 过滤器类型
- * @since 0.6
- */
- public FileNameFilter(String start, String end,int type) {
- super(type);
- this.start = (start == null) ? "" : start;
- this.end = (end == null) ? "" : end;
- }
- /**
- * 根据指定的参数构造一个FileNameFilter。
- * @param start 文件名的开始字符串
- * @param end 文件名的结束字符串
- * @since 0.6
- */
- public FileNameFilter(String start, String end) {
- this(start,end,SWING);
- }
-
- /**
- * 判断指定的文件是否可以被接受。
- * @param file 需要判断的文件
- * @return 在任何情况都返回true。
- * @since 0.6
- */
- protected boolean acceptFile(File file) {
- String filename = file.getName();
- if (filename.startsWith(start) && filename.endsWith(end)) {
- return true;
- }
- return false;
- }
-
- /**
- * 返回过滤器的描述字符串。
- * @return 过滤器的描述字符串
- * @since 0.6
- */
- public String getDescription() {
- return "Start with:" + start + " and end with:" + end;
- }
-
- }