summaryrefslogtreecommitdiffstats
path: root/Bachelor/ERGO/TierheimVerw/thv/ThvFilter.java
blob: 9810478508674cb8de8f55650c71eb24f8922375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.io.File;
import javax.swing.filechooser.*;

/**
 * @author Andreas Spirka, Sven Eisenhauer
 * Filter Klasse f�r JFileChooser
 * filter .thv
 */
public class ThvFilter extends FileFilter {

	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
	 */
	public boolean accept(File f) {
		if (f.isDirectory()) {
			return true;
		}
		String fileName = f.getName();
		String extension = null;
		int pos = fileName.lastIndexOf('.');
		if (pos > 0 &&  pos < fileName.length() - 1) {
			extension = fileName.substring(pos+1).toLowerCase();
		}
		if (extension != null) {
			if (extension.equals("thv") || extension.equals("THV"))
			{
				return true;
			} else {
				return false;
			}
		}
		return false;
	}

	//The description of this filter
	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#getDescription()
	 */
	public String getDescription() {
		return "THV Dateien";
	}
}