1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.efaps.update;
22
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Map;
26 import java.util.Set;
27
28 import org.efaps.update.schema.program.BPMUpdate;
29 import org.efaps.update.schema.program.CSSUpdate;
30 import org.efaps.update.schema.program.JasperReportUpdate;
31 import org.efaps.update.schema.program.JavaScriptUpdate;
32 import org.efaps.update.schema.program.JavaUpdate;
33 import org.efaps.update.schema.program.WikiUpdate;
34 import org.efaps.update.schema.program.XSLUpdate;
35
36
37
38
39
40
41
42 public enum FileType {
43
44
45 BPM("bpmn", "bpmn2"),
46
47 JAVA("source-java", "java"),
48
49 JS("source-js", "js"),
50
51 JRXML("jasperreport", "jrxml"),
52
53 CSS("source-css", "css"),
54
55 WIKI("source-wiki", "wiki"),
56
57 XML("install-xml", "xml"),
58
59 XSL("source-xsl", "xsl", "xslt");
60
61
62
63
64 private static final class Mapper
65 {
66
67
68
69 private static final Map<String, FileType> EXT2FILETYPE = new HashMap<String, FileType>();
70
71
72
73
74 private static final Map<String, FileType> TYPE2FILETYPE = new HashMap<String, FileType>();
75
76
77
78
79 private Mapper()
80 {
81 }
82 }
83
84
85
86
87 private final String type;
88
89
90
91
92
93 private final Set<String> extensions = new HashSet<String>();
94
95
96
97
98 private final Set<Class<? extends AbstractUpdate>> clazzes = new HashSet<Class<? extends AbstractUpdate>>();
99
100
101
102
103
104
105
106
107 private FileType(final String _type,
108 final String... _extensions)
109 {
110 this.type = _type;
111 for (final String extension : _extensions) {
112 this.extensions.add(extension);
113 FileType.Mapper.EXT2FILETYPE.put(extension, this);
114 }
115 FileType.Mapper.TYPE2FILETYPE.put(_type, this);
116 if ("source-java".equals(_type)) {
117 this.clazzes.add(JavaUpdate.class);
118 } else if ("source-js".equals(_type)) {
119 this.clazzes.add(JavaScriptUpdate.class);
120 } else if ("source-css".equals(_type)) {
121 this.clazzes.add(CSSUpdate.class);
122 } else if ("source-xsl".equals(_type)) {
123 this.clazzes.add(XSLUpdate.class);
124 } else if ("jasperreport".equals(_type)) {
125 this.clazzes.add(JasperReportUpdate.class);
126 } else if ("source-wiki".equals(_type)) {
127 this.clazzes.add(WikiUpdate.class);
128 } else if ("bpmn".equals(_type)) {
129 this.clazzes.add(BPMUpdate.class);
130 }
131
132 }
133
134
135
136
137
138
139 public String getType()
140 {
141 return this.type;
142 }
143
144
145
146
147
148
149 public Set<Class<? extends AbstractUpdate>> getClazzes()
150 {
151 return this.clazzes;
152 }
153
154
155
156
157
158
159
160 public static FileType getFileTypeByExensione(final String _extension)
161 {
162 return FileType.Mapper.EXT2FILETYPE.get(_extension);
163 }
164
165
166
167
168
169
170
171 public static FileType getFileTypeByType(final String _type)
172 {
173 return FileType.Mapper.TYPE2FILETYPE.get(_type);
174 }
175 }