01: package org.dbbrowser.ui.helper.exporthelper;
02:
03: import infrastructure.logging.Log;
04: import java.util.HashMap;
05: import java.util.Map;
06:
07: public class ExportHelperFactory {
08: private static Map mapOfExportTypeToExportHelper = new HashMap();
09:
10: static {
11: mapOfExportTypeToExportHelper.put("pdf",
12: new ExporterForPDFFile());
13: mapOfExportTypeToExportHelper.put("csv",
14: new ExporterForCSVFile());
15: mapOfExportTypeToExportHelper.put("xls",
16: new ExporterForXLSFile());
17: mapOfExportTypeToExportHelper.put("sql",
18: new ExporterForSQLFile());
19: Log.getInstance().debugMessage(
20: "ExportHelperFactory initialized",
21: ExportHelperFactory.class.getName());
22: }
23:
24: /**
25: * Return an export heler for the export type
26: * @param exportType
27: * @return
28: * @throws ExportHelperException
29: */
30: public static ExportHelper getExportHelper(String exportType)
31: throws ExportHelperException {
32: Object o = mapOfExportTypeToExportHelper.get(exportType);
33: if (o == null) {
34: Log.getInstance().fatalMessage(
35: "Invalid exportType in ExportHelperFactory.getExportHelper: "
36: + exportType,
37: ExportHelperFactory.class.getName());
38: throw new ExportHelperException(
39: "Invalid exportType in ExportHelperFactory.getExportHelper: "
40: + exportType);
41: }
42:
43: return (ExportHelper) o;
44: }
45: }
|