001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.dynamicdatalists.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    
019    import java.util.HashMap;
020    import java.util.Map;
021    
022    /**
023     * @author Marcellus Tavares
024     */
025    public class DDLExporterFactory {
026    
027            public static DDLExporter getDDLExporter(DDLExportFormat exportFormat)
028                    throws PortalException {
029    
030                    DDLExporter exporter = _exporters.get(exportFormat);
031    
032                    if (exporter == null) {
033                            throw new PortalException("Invalid format type " + exportFormat);
034                    }
035    
036                    return exporter;
037            }
038    
039            public void setDDLExporters(Map<String, DDLExporter> exporters) {
040                    _exporters = new HashMap<DDLExportFormat, DDLExporter>();
041    
042                    for (Map.Entry<String, DDLExporter> entry : exporters.entrySet()) {
043                            DDLExportFormat exportFormat = DDLExportFormat.parse(
044                                    entry.getKey());
045    
046                            _exporters.put(exportFormat, entry.getValue());
047                    }
048            }
049    
050            public static Map<DDLExportFormat, DDLExporter> _exporters;
051    
052    }