1 package org.ximtec.igesture.tool.util;
2
3 import java.io.File;
4
5 public enum FileType {
6
7 compressedWorkbench("igz", "iGesture Workspace Compressed"),
8 xstreamWorkbench("igx", "iGesture Workspace XStream"),
9 db4oWorkbench("igd", "iGesture Workspace db4o"),
10 gestureSet("igs", "iGesture Gesture Set"),
11 testSet("igt", "iGesture Test Set"),
12 algorithmConfiguration("igc", "iGesture Recogniser Configuration"),
13 pdf ("pdf", "Portable Document Format"),
14 igb("igb", "iGesture Batch Configuration"),
15 deviceConfiguration("igdc","iGesture Device Configuration");
16
17 private String extension;
18 private String description;
19 private ExtensionFileFilter filter;
20
21
22
23
24
25
26 private FileType(String extension, String description){
27 this.extension = extension;
28 this.description = description;
29 this.filter = new ExtensionFileFilter(this.extension, this.description);
30 }
31
32
33
34
35
36 public String getExtension(){
37 return this.extension;
38 }
39
40
41
42
43
44 public String getDescription(){
45 return this.description;
46 }
47
48
49
50
51
52 public ExtensionFileFilter getFilter(){
53 return this.filter;
54 }
55
56
57
58
59
60
61 public File addExtension(File file){
62 if(file != null && !file.getName().endsWith(this.extension) ){
63 File parent = file.getParentFile();
64 return new File(parent, String.format("%s.%s", file.getName(), extension));
65 }
66
67 return file;
68 }
69 }