KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > convert > ConverterFactory


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.convert;
14
15 import java.io.IOException JavaDoc;
16 import java.net.URL JavaDoc;
17
18 import org.apache.log4j.Logger;
19 import org.xml.sax.SAXException JavaDoc;
20
21 import com.tonbeller.wcf.format.Formatter;
22 import com.tonbeller.wcf.utils.ObjectFactory;
23 import com.tonbeller.wcf.utils.SoftException;
24
25 /**
26  * Created on 05.11.2002
27  *
28  * @author av
29  */

30 public class ConverterFactory {
31   private ConverterFactory() {
32   }
33   private static Logger logger = Logger.getLogger(ConverterFactory.class);
34
35   /**
36    * returns a new instance w/o caching
37    */

38   public static Converter instance(Formatter formatter) {
39     URL JavaDoc configXml = ConverterFactory.class.getResource("config.xml");
40     return instance(formatter, configXml);
41   }
42
43   public static Converter instance(Formatter formatter, URL JavaDoc configXml) {
44     try {
45       URL JavaDoc rulesXml = ConverterFactory.class.getResource("rules.xml");
46       Converter conv = (Converter) ObjectFactory.instance(rulesXml, configXml);
47       conv.setFormatter(formatter);
48       return conv;
49     } catch (SAXException JavaDoc e) {
50       logger.error("?", e);
51       throw new SoftException(e);
52     } catch (IOException JavaDoc e) {
53       logger.error("?", e);
54       throw new SoftException(e);
55     }
56   }
57
58 }
59
Popular Tags