01: package com.quantum.flatfiles.converter;
02:
03: import java.util.Collections;
04: import java.util.HashMap;
05: import java.util.Map;
06: import java.util.Set;
07:
08: /**
09: * @author BC Holmes
10: */
11: public class ConverterFactory {
12:
13: public static final String EXCEL_SPREADSHEET = "excel";
14: public static final String COMMA_SEPARATED_VALUES = "csv";
15: public static final String CUSTOM_FILTERED_TEXT = "filtered";
16:
17: private static final Map converterMap;
18:
19: static {
20: Map map = new HashMap();
21: map.put(EXCEL_SPREADSHEET,
22: new ResultSetToSpreadSheetConverter());
23: map.put(COMMA_SEPARATED_VALUES, new ResultSetToCSVConverter());
24: //map.put(CUSTOM_FILTERED_TEXT, new ResultSetToFilteredConverter());
25: converterMap = Collections.unmodifiableMap(map);
26: }
27:
28: public static String[] getConverterTypes() {
29: Set set = ConverterFactory.converterMap.keySet();
30: return (String[]) set.toArray(new String[set.size()]);
31: }
32:
33: public static Converter getConverter(String type) {
34: return (Converter) ConverterFactory.converterMap.get(type);
35: }
36: }
|