Class JasperReports


  • public final class JasperReports
    extends Object
    Factory for Report based on JasperReports.
    • Method Detail

      • reportType

        public static JRReportType reportType​(String name)
        Parameters:
        name - the report name
        Returns:
        a JRReport
      • classPathReport

        public static JRReport classPathReport​(Class<?> resourceClass,
                                               String reportPath)
        Instantiates a JRReport for a classpath based report. Note that classpath reports are always cached.
        Parameters:
        resourceClass - the class owning the report resource
        reportPath - the report path, relative to the resource class
        Returns:
        a report wrapper
      • fileReport

        public static JRReport fileReport​(String reportPath)
        Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.
        Parameters:
        reportPath - the report path, relative to the central report path Report.REPORT_PATH
        Returns:
        a report wrapper
      • fileReport

        public static JRReport fileReport​(String reportPath,
                                          boolean cacheReport)
        Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.
        Parameters:
        reportPath - the report path, relative to the central report path Report.REPORT_PATH
        cacheReport - if true the report is only loaded once and cached
        Returns:
        a report wrapper
      • fillReport

        public static net.sf.jasperreports.engine.JasperPrint fillReport​(Report<net.sf.jasperreports.engine.JasperReport,​net.sf.jasperreports.engine.JasperPrint,​Map<String,​Object>> report,
                                                                         net.sf.jasperreports.engine.JRDataSource dataSource)
                                                                  throws ReportException
        Fills the report using the data source wrapped by the given data wrapper
        Parameters:
        report - the report
        dataSource - the data provider to use for the report generation
        Returns:
        a filled report ready for display
        Throws:
        ReportException - in case of an exception
      • fillReport

        public static net.sf.jasperreports.engine.JasperPrint fillReport​(Report<net.sf.jasperreports.engine.JasperReport,​net.sf.jasperreports.engine.JasperPrint,​Map<String,​Object>> report,
                                                                         net.sf.jasperreports.engine.JRDataSource dataSource,
                                                                         Map<String,​Object> reportParameters)
                                                                  throws ReportException
        Fills the report using the given data.
        Parameters:
        report - the report
        dataSource - the data provider to use for the report generation
        reportParameters - the report parameters
        Returns:
        a filled report ready for display
        Throws:
        ReportException - in case of an exception