Package net.sf.jasperreports.engine
Class JasperFillManager
java.lang.Object
net.sf.jasperreports.engine.JasperFillManager
Facade class for filling compiled report designs with data from report data sources, 
 in order to produce page-oriented documents, ready-to-print.
 
It exposes a variety of methods that receive a report template in the form of an object, file, or input stream, and also produces a document in various output forms (object, file, or output stream).
All methods receive a Map object that should contain the values for the report parameters. These values are retrieved by the engine using the corresponding report parameter name as the key.
There are two types of method signatures with regards to the data source provided for filling the report:
- Methods that receive an instance of the JRDataSourceinterface and use it directly for retrieving report data;
- Methods that receive an instance of the java.sql.Connectioninterface and retrieve the report data by executing the report internal SQL query through this JDBC connection and wrapping the returnedjava.sql.ResultSetobject inside aJRResultSetDataSourceinstance.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.The property should only be set when upgrading from a version older than 6.6.0 with a repository that relied on the fact that paths were relative to the master report.
- 
Method SummaryModifier and TypeMethodDescriptionfill(InputStream inputStream, Map<String, Object> parameters) Fills the compiled report design loaded from the supplied input stream and returns the generated report object.fill(InputStream inputStream, Map<String, Object> parameters, Connection connection) Fills the compiled report design loaded from the supplied input stream and returns the generated report object.fill(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) Fills the compiled report design loaded from the supplied input stream and returns the generated report object.Fills the compiled report design loaded from the specified file and returns the generated report object.Fills the compiled report design loaded from the specified file and returns the generated report object.Fills the compiled report design loaded from the specified file and returns the generated report object.fill(JasperReport jasperReport, Map<String, Object> parameters) Fills the compiled report design supplied as the first parameter and returns the generated report object.fill(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) Fills the compiled report design supplied as the first parameter and returns the generated report object.fill(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) Fills the compiled report design supplied as the first parameter and returns the generated report object.fillFromRepo(String reportLocation, Map<String, Object> params) Fills the compiled report design loaded from the specified file and returns the generated report object.fillFromRepo(String reportLocation, Map<String, Object> params, Connection connection) Fills the compiled report design loaded from the specified file and returns the generated report object.fillFromRepo(String reportLocation, Map<String, Object> params, JRDataSource dataSource) Fills the compiled report design loaded from the specified file and returns the generated report object.static JasperPrintfillReport(InputStream inputStream, Map<String, Object> parameters) static JasperPrintfillReport(InputStream inputStream, Map<String, Object> parameters, Connection connection) static JasperPrintfillReport(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) static JasperPrintfillReport(String sourceFileName, Map<String, Object> params) static JasperPrintfillReport(String sourceFileName, Map<String, Object> params, Connection connection) static JasperPrintfillReport(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) static JasperPrintfillReport(JasperReport jasperReport, Map<String, Object> parameters) static JasperPrintfillReport(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) static JasperPrintfillReport(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) static voidstatic voidfillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) static voidfillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) static StringfillReportToFile(String sourceFileName, Map<String, Object> params) static StringfillReportToFile(String sourceFileName, Map<String, Object> params, Connection connection) static StringfillReportToFile(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) static voidfillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) static voidfillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) static voidfillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) static voidfillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) static voidfillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) static voidfillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) static voidfillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) static voidfillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) static voidfillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) voidFills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.voidfillToFile(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) Fills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.voidfillToFile(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) Fills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.fillToFile(String sourceFileName, Map<String, Object> params) Fills the compiled report design loaded from the specified file.fillToFile(String sourceFileName, Map<String, Object> params, Connection connection) Fills the compiled report design loaded from the specified file.fillToFile(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) Fills the compiled report design loaded from the specified file.voidfillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) Fills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.voidfillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) Fills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.voidfillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) Fills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.voidfillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) Fills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.voidfillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) Fills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.voidfillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) Fills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.voidfillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) Fills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.voidfillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) Fills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.voidfillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) Fills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.static JasperFillManagergetInstance(JasperReportsContext jasperReportsContext) protected JasperReportSourcegetReportSource(File reportFile) protected JasperReportSourcegetReportSource(File reportFile, JasperReport jasperReport) protected JasperReportSourcegetReportSource(String location) protected static JasperReportSourcegetReportSource(JasperReportsContext jasperReportsContext, File reportFile) 
- 
Field Details- 
PROPERTY_LEGACY_RELATIVE_PATH_ENABLEDDeprecated.The property should only be set when upgrading from a version older than 6.6.0 with a repository that relied on the fact that paths were relative to the master report. The property might be removed at some point in the future.Property that determines whether resource paths in subreports, style templates and data adapters should be interpreted as relative to the master report location.
 Starting with version 6.6.0, relative paths in subreports, style templates and data adapters are resolved as relative to the resource that contains them. Prior to version 6.6.0, relative paths in subreports, style templates and data adapters were resolved as relative to the master report resource. This property can be set totrueto restore the pre 6.6.0 functionality.
 The default value of the property isfalse.- See Also:
 
 
- 
- 
Method Details- 
getInstance
- 
fillToFilepublic String fillToFile(String sourceFileName, Map<String, Object> params, Connection connection) throws JRExceptionFills the compiled report design loaded from the specified file. The result of this operation is another file that will contain the serializedJasperPrintobject representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprintextension, located in the same directory as the source file.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Throws:
- JRException
 
- 
fillToFileFills the compiled report design loaded from the specified file. The result of this operation is another file that will contain the serializedJasperPrintobject representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprintextension, located in the same directory as the source file.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- Throws:
- JRException
- See Also:
 
- 
fillToFilepublic void fillToFile(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) throws JRExceptionFills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- sourceFileName- source file containing the compiled report design
- destFileName- file name to place the generated report into
- params- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Throws:
- JRException
 
- 
fillToFilepublic void fillToFile(String sourceFileName, String destFileName, Map<String, Object> params) throws JRExceptionFills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- sourceFileName- source file containing the compiled report design
- destFileName- file name to place the generated report into
- params- report parameters map
- Throws:
- JRException
- See Also:
 
- 
fillToFilepublic void fillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) throws JRExceptionFills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- destFileName- file name to place the generated report into
- parameters- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Throws:
- JRException
 
- 
fillToFilepublic void fillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) throws JRExceptionFills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- destFileName- file name to place the generated report into
- parameters- report parameters map
- Throws:
- JRException
- See Also:
 
- 
fillpublic JasperPrint fill(String sourceFileName, Map<String, Object> params, Connection connection) throws JRExceptionFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillFromRepopublic JasperPrint fillFromRepo(String reportLocation, Map<String, Object> params, Connection connection) throws JRExceptionFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- reportLocation- the repository location of the compiled report
- params- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- Returns:
- generated report object
- Throws:
- JRException
- See Also:
 
- 
fillFromRepopublic JasperPrint fillFromRepo(String reportLocation, Map<String, Object> params) throws JRExceptionFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- reportLocation- the repository location of the compiled report
- params- report parameters map
- Returns:
- generated report object
- Throws:
- JRException
- See Also:
 
- 
fillToStreampublic void fillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRExceptionFills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- inputStream- input stream to read the compiled report design object from
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Throws:
- JRException
 
- 
fillToStreampublic void fillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) throws JRExceptionFills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- inputStream- input stream to read the compiled report design object from
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- Throws:
- JRException
- See Also:
 
- 
fillToStreampublic void fillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRExceptionFills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Throws:
- JRException
 
- 
fillToStreampublic void fillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) throws JRExceptionFills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- Throws:
- JRException
- See Also:
 
- 
fillpublic JasperPrint fill(InputStream inputStream, Map<String, Object> parameters, Connection connection) throws JRExceptionFills the compiled report design loaded from the supplied input stream and returns the generated report object.- Parameters:
- inputStream- input stream to read the compiled report design object from
- parameters- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillFills the compiled report design loaded from the supplied input stream and returns the generated report object.- Parameters:
- inputStream- input stream to read the compiled report design object from
- parameters- report parameters map
- Returns:
- generated report object
- Throws:
- JRException
- See Also:
 
- 
fillpublic JasperPrint fill(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) throws JRExceptionFills the compiled report design supplied as the first parameter and returns the generated report object.- Parameters:
- jasperReport- compiled report design object to use for filling
- parameters- report parameters map
- connection- JDBC connection object to use for executing the report internal SQL query
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillpublic JasperPrint fill(JasperReport jasperReport, Map<String, Object> parameters) throws JRExceptionFills the compiled report design supplied as the first parameter and returns the generated report object.- Parameters:
- jasperReport- compiled report design object to use for filling
- parameters- report parameters map
- Returns:
- generated report object
- Throws:
- JRException
- See Also:
 
- 
fillToFilepublic String fillToFile(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the specified file. The result of this operation is another file that will contain the serializedJasperPrintobject representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprintextension, located in the same directory as the source file.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- dataSource- data source object
- Throws:
- JRException
 
- 
fillToFilepublic void fillToFile(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the file received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- sourceFileName- source file containing the compiled report design
- destFileName- file name to place the generated report into
- params- report parameters map
- dataSource- data source object
- Throws:
- JRException
 
- 
fillToFilepublic void fillToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) throws JRExceptionFills the compiled report design received as the first parameter and places the result in the file specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- destFileName- file name to place the generated report into
- parameters- report parameters map
- dataSource- data source object
- Throws:
- JRException
 
- 
fillpublic JasperPrint fill(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- sourceFileName- source file containing the compiled report design
- params- report parameters map
- dataSource- data source object
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillFromRepopublic JasperPrint fillFromRepo(String reportLocation, Map<String, Object> params, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
- reportLocation- the repository location of the compiled report
- params- report parameters map
- dataSource- data source object
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillToStreampublic void fillToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the supplied input stream and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- inputStream- input stream to read the compiled report design object from
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- dataSource- data source object
- Throws:
- JRException
 
- 
fillToStreampublic void fillToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRExceptionFills the compiled report design supplied as the first parameter and writes the generated report object to the output stream specified by the second parameter.- Parameters:
- jasperReport- compiled report design object to use for filling
- outputStream- output stream to write the generated report object to
- parameters- report parameters map
- dataSource- data source object
- Throws:
- JRException
 
- 
fillpublic JasperPrint fill(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRExceptionFills the compiled report design loaded from the supplied input stream and returns the generated report object.- Parameters:
- inputStream- input stream to read the compiled report design object from
- parameters- report parameters map
- dataSource- data source object
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillpublic JasperPrint fill(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) throws JRExceptionFills the compiled report design supplied as the first parameter and returns the generated report object.- Parameters:
- jasperReport- compiled report design object to use for filling
- parameters- report parameters map
- dataSource- data source object
- Returns:
- generated report object
- Throws:
- JRException
 
- 
fillReportToFilepublic static String fillReportToFile(String sourceFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static String fillReportToFile(String sourceFileName, Map<String, Object> params) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(String sourceFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(String sourceFileName, Map<String, Object> params) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static String fillReportToFile(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToFilepublic static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportToStreampublic static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
fillReportpublic static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
- JRException
- See Also:
 
- 
getReportSourceprotected static JasperReportSource getReportSource(JasperReportsContext jasperReportsContext, File reportFile) throws JRException - Throws:
- JRException
 
- 
getReportSource- Throws:
- JRException
 
- 
getReportSource
- 
getReportSource- Throws:
- JRException
 
 
-