Class JasperReportsWrapper

  • All Implemented Interfaces:
    Serializable, ReportWrapper<net.sf.jasperreports.engine.JasperPrint,​net.sf.jasperreports.engine.JRDataSource>

    public final class JasperReportsWrapper
    extends Object
    implements ReportWrapper<net.sf.jasperreports.engine.JasperPrint,​net.sf.jasperreports.engine.JRDataSource>, Serializable
    A Jasper Reports wrapper.
    See Also:
    Serialized Form
    • Field Detail

      • CACHE_REPORTS

        public static final PropertyValue<Boolean> CACHE_REPORTS
        Specifies whether or not reports are cached when loaded from disk/network,
        this prevents "hot deploy" of reports.
        Value type: Boolean
        Default value: true
    • Constructor Detail

      • JasperReportsWrapper

        public JasperReportsWrapper​(String reportPath)
                             throws ReportException
        Parameters:
        reportPath - the report path
        Throws:
        ReportException - in case of an exception while loading the report
      • JasperReportsWrapper

        public JasperReportsWrapper​(String reportPath,
                                    Map<String,​Object> reportParameters)
                             throws ReportException
        Parameters:
        reportPath - the report path
        reportParameters - the report parameters
        Throws:
        ReportException - in case of an exception while loading the report
      • JasperReportsWrapper

        public JasperReportsWrapper​(net.sf.jasperreports.engine.JasperReport report,
                                    Map<String,​Object> reportParameters)
        Parameters:
        report - the report
        reportParameters - the report parameters
    • Method Detail

      • getReportName

        public String getReportName()
        Specified by:
        getReportName in interface ReportWrapper<net.sf.jasperreports.engine.JasperPrint,​net.sf.jasperreports.engine.JRDataSource>
        Returns:
        the name of the report
      • fillReport

        public ReportResult<net.sf.jasperreports.engine.JasperPrint> fillReport​(Connection connection)
                                                                         throws ReportException
        Fills the report using the given database connection
        Specified by:
        fillReport in interface ReportWrapper<net.sf.jasperreports.engine.JasperPrint,​net.sf.jasperreports.engine.JRDataSource>
        Parameters:
        connection - the connection to use for the report generation
        Returns:
        a filled report ready for display
        Throws:
        ReportException - in case of an exception
      • fillReport

        public ReportResult<net.sf.jasperreports.engine.JasperPrint> fillReport​(ReportDataWrapper<net.sf.jasperreports.engine.JRDataSource> dataWrapper)
                                                                         throws ReportException
        Fills the report using the data source wrapped by the given data wrapper
        Specified by:
        fillReport in interface ReportWrapper<net.sf.jasperreports.engine.JasperPrint,​net.sf.jasperreports.engine.JRDataSource>
        Parameters:
        dataWrapper - the data provider to use for the report generation
        Returns:
        a filled report ready for display
        Throws:
        ReportException - in case of an exception
      • loadJasperReport

        public static net.sf.jasperreports.engine.JasperReport loadJasperReport​(String reportPath)
                                                                         throws net.sf.jasperreports.engine.JRException,
                                                                                MalformedURLException
        Loads a JasperReport file from the path given, it can be a URL a file or classpath resource.
        Parameters:
        reportPath - the path to the report file to load
        Returns:
        a loaded JasperReport file
        Throws:
        net.sf.jasperreports.engine.JRException - in case loading the report fails
        MalformedURLException - in case the report path is a malformed URL
        IllegalArgumentException - in case the report path is not specified