/** * Reads the report from the specified template file. * * @param templateURL the template location. * @return a report. * @throws ParseException if the report could not be parsed. */ private MasterReport parseReport(final URL templateURL) throws ParseException { final ReportGenerator generator = ReportGenerator.getInstance(); try { return generator.parseReport(templateURL); } catch (Exception e) { throw new ParseException("Failed to parse the report", e); } }
/** * The starting point for the application. * * @param args ignored. */ public static void main(final String[] args) { ClassicEngineBoot.getInstance().start(); final ReportGenerator gen = ReportGenerator.getInstance(); final URL reportURL = ObjectUtilities.getResourceRelative(REFERENCE_REPORT, StyleKeyReferenceGenerator.class); if (reportURL == null) { System.err.println("The report was not found in the classpath"); // $NON-NLS-1$ System.err.println("File: " + REFERENCE_REPORT); // $NON-NLS-1$ System.exit(1); return; } final MasterReport report; try { report = gen.parseReport(reportURL); } catch (Exception e) { System.err.println("The report could not be parsed."); // $NON-NLS-1$ System.err.println("File: " + REFERENCE_REPORT); // $NON-NLS-1$ e.printStackTrace(System.err); System.exit(1); return; } report.setDataFactory(new TableDataFactory("default", createData())); // $NON-NLS-1$ try { HtmlReportUtil.createStreamHTML( report, System.getProperty("user.home") // $NON-NLS-1$ + "/stylekey-reference.html"); //$NON-NLS-1$ PdfReportUtil.createPDF( report, System.getProperty("user.home") // $NON-NLS-1$ + "/stylekey-reference.pdf"); //$NON-NLS-1$ } catch (Exception e) { System.err.println("The report processing failed."); // $NON-NLS-1$ System.err.println("File: " + REFERENCE_REPORT); // $NON-NLS-1$ e.printStackTrace(System.err); System.exit(1); } }
public static MasterReport createReport(final InputStream inputStream, final URL url) throws IOException, ResourceException { final ReportGenerator generator = ReportGenerator.createInstance(); final InputSource repDefInputSource = new InputSource(inputStream); return generator.parseReport(repDefInputSource, url); }