1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.ediknight;
21
22 import java.util.Properties;
23
24
25 /***
26 * @author Holger Joest
27 */
28 public abstract class ConverterFactory {
29
30 private static ConverterFactory instance;
31
32
33 /***
34 * No instantiation.
35 */
36 protected ConverterFactory() {
37 }
38
39
40 /***
41 * Creates a new converter instance.
42 *
43 * @param name the converter configuration name
44 * @return the converter
45 */
46 public abstract Converter createConverter(String name);
47
48
49 public static void setInstance(ConverterFactory factory) {
50 instance = factory;
51 }
52
53
54 /***
55 * Returns a new instance of a <code>ConvertFactory</code>.
56 *
57 * @return the converter factory
58 * @throws ConfigurationException if there's a serious configuration problem
59 */
60 public static ConverterFactory newInstance()
61 throws ConfigurationException {
62 if (instance != null) {
63 return instance;
64 }
65 return newInstance(null);
66 }
67
68
69 /***
70 * Returns a new instance of a <code>ConvertFactory</code>.
71 *
72 * @param properties properties used instead of the system properties
73 * @return the converter factory
74 * @throws ConfigurationException if there's a serious configuration problem
75 */
76 public static ConverterFactory newInstance(Properties properties)
77 throws ConfigurationException {
78 return (ConverterFactory)
79 FactoryFinder.find("net.sf.ediknight.ConverterFactory",
80 "net.sf.ediknight.common.ConverterFactoryImpl",
81 properties);
82 }
83
84 }
85