View Javadoc

1   /*
2    * EDI-Knight Integration and Transformation Platform
3    * Copyright (C) 2006-2007 Holger Joest <hjoest@users.sourceforge.net>
4    *
5    * This program is free software; you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation; either version 2 of the License, or
8    * (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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