Normand Briere
2019-04-22 a9e12f6c508810604c8c91ee15451776b08ce1a1
timeflow/format/field/FieldFormatCatalog.java
....@@ -6,49 +6,56 @@
66 import java.net.URL;
77 import java.util.*;
88
9
-public class FieldFormatCatalog {
9
+public class FieldFormatCatalog
10
+{
11
+ private static Map<String, FieldFormat> formatTable = new HashMap<String, FieldFormat>();
12
+ private static Map<Class, FieldFormat> classTable = new HashMap<Class, FieldFormat>();
1013
11
- private static Map<String, FieldFormat> formatTable=new HashMap<String, FieldFormat>();
12
- private static Map<Class, FieldFormat> classTable=new HashMap<Class, FieldFormat>();
14
+ static
15
+ {
16
+ for (FieldFormat f : listFormats())
17
+ {
18
+ formatTable.put(f.getHumanName(), f);
19
+ classTable.put(f.getType(), f);
20
+ }
21
+ }
1322
14
- static
15
- {
16
- for (FieldFormat f: listFormats())
17
- {
18
- formatTable.put(f.getHumanName(), f);
19
- classTable.put(f.getType(), f);
20
- }
21
- }
22
-
23
- static FieldFormat[] listFormats()
24
- {
25
- return new FieldFormat[] {new FormatDateTime(), new FormatString(),
26
- new FormatStringArray(), new FormatDouble(), new FormatURL()};
27
- }
28
-
29
- public static Iterable<String> classNames()
30
- {
31
- return formatTable.keySet();
32
- }
33
-
34
- public static String humanName(Class c){
35
- return getFormat(c).getHumanName();
36
- }
37
-
23
+ static FieldFormat[] listFormats()
24
+ {
25
+ return new FieldFormat[]
26
+ {
27
+ new FormatDateTime(), new FormatString(),
28
+ new FormatStringArray(), new FormatDouble(), new FormatURL()
29
+ };
30
+ }
3831
39
- public static FieldFormat getFormat(Class c) {
40
- FieldFormat f= classTable.get(c);
41
- if (f==null)
42
- System.out.println("Warning: no FieldFormat for "+c);
43
- return f;
44
- }
32
+ public static Iterable<String> classNames()
33
+ {
34
+ return formatTable.keySet();
35
+ }
4536
46
-
47
- public static Class javaClass(String humanName)
48
- {
49
- Class c=formatTable.get(humanName).getType();
50
- if (c==null)
51
- System.out.println("Warning: no class for "+humanName);
52
- return c;
53
- }
37
+ public static String humanName(Class c)
38
+ {
39
+ return getFormat(c).getHumanName();
40
+ }
41
+
42
+ public static FieldFormat getFormat(Class c)
43
+ {
44
+ FieldFormat f = classTable.get(c);
45
+ if (f == null)
46
+ {
47
+ System.out.println("Warning: no FieldFormat for " + c);
48
+ }
49
+ return f;
50
+ }
51
+
52
+ public static Class javaClass(String humanName)
53
+ {
54
+ Class c = formatTable.get(humanName).getType();
55
+ if (c == null)
56
+ {
57
+ System.out.println("Warning: no class for " + humanName);
58
+ }
59
+ return c;
60
+ }
5461 }