use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class FormatterFactory method getInstance.
/**
* Supported formats are CSV, WKT, HTML, KML, Shapefile, GDB, JSON
*
* @param fmt format name
* @return Implentation of ResultsFormatter
* @throws ProcessingException if Java class for formatter is not found
*/
public static ResultsFormatter getInstance(String fmt) throws ProcessingException {
String formatterClass = OUTPUT_FORMATS_LOOKUP.get(fmt.toLowerCase());
if (formatterClass == null) {
throw new ProcessingException("Unsupported Formatter: " + fmt);
}
formatterClass = PKG + "." + formatterClass + "Formatter";
try {
return (ResultsFormatter) (Class.forName(formatterClass)).newInstance();
} catch (ClassNotFoundException e) {
throw new ProcessingException("Formatter not found for " + fmt, e);
} catch (InstantiationException e) {
throw new ProcessingException("Formatter could not start for " + fmt, e);
} catch (IllegalAccessException e) {
throw new ProcessingException("Formatter could not start for " + fmt, e);
}
}
Aggregations