Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package pt.webdetails.cda.exporter;
 
 import  org.apache.commons.logging.Log;
 import  org.apache.commons.logging.LogFactory;
Main engine class that will answer to calls

Created by IntelliJ IDEA. User: pedro Date: Feb 2, 2010 Time: 2:24:16 PM

public class ExporterEngine
  private static final Log logger = LogFactory.getLog(ExporterEngine.class);
  private static ExporterEngine _instance;
  
  public enum OutputType{
  	
  	JSON("json"),
  	XML("xml"),
  	CSV("csv"),
  	XLS("xls");
  	
  	private String type;
  	OutputType(String type){this. = type;}
  	public String toString(){ return ;}
  }
  public ExporterEngine()
  {
    .info("Initializing CdaEngine");
    init();
  }
  public Exporter getExporter(final String outputTypethrows UnsupportedExporterException
  {
    return getExporter(outputTypenull);
  }
  public Exporter getExporter(final String outputTypefinal HashMap<StringStringextraSettingsthrows UnsupportedExporterException
  {
    try
    {
      final String className = "pt.webdetails.cda.exporter."
              + outputType.substring(0, 1).toUpperCase() + outputType.substring(1, outputType.length()) + "Exporter";
      final Class clazz = Class.forName(className);
      final Class[] params =
      {
        HashMap.class
      };
      final Exporter exporter = (Exporterclazz.getConstructor(params).newInstance(new Object[]
              {
                extraSettings
              });
      return exporter;
    }
    catch (Exception e)
    {
      throw new UnsupportedExporterException("Error initializing expoert class: " + Util.getExceptionDescription(e), e);
    }
  }
  private void init()
  {
  }
  public static synchronized ExporterEngine getInstance()
  {
    if ( == null)
    {
       = new ExporterEngine();
    }
    return ;
  }
New to GrepCode? Check out our FAQ X