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
JRDataSource
interface and use it directly for retrieving report data; - Methods that receive an instance of the
java.sql.Connection
interface and retrieve the report data by executing the report internal SQL query through this JDBC connection and wrapping the returnedjava.sql.ResultSet
object inside aJRResultSetDataSource
instance.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated.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 Summary
Modifier 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 JasperPrint
fillReport
(InputStream inputStream, Map<String, Object> parameters) static JasperPrint
fillReport
(InputStream inputStream, Map<String, Object> parameters, Connection connection) static JasperPrint
fillReport
(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) static JasperPrint
fillReport
(String sourceFileName, Map<String, Object> params) static JasperPrint
fillReport
(String sourceFileName, Map<String, Object> params, Connection connection) static JasperPrint
fillReport
(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) static JasperPrint
fillReport
(JasperReport jasperReport, Map<String, Object> parameters) static JasperPrint
fillReport
(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) static JasperPrint
fillReport
(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) static void
static void
fillReportToFile
(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) static void
fillReportToFile
(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) static String
fillReportToFile
(String sourceFileName, Map<String, Object> params) static String
fillReportToFile
(String sourceFileName, Map<String, Object> params, Connection connection) static String
fillReportToFile
(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) static void
fillReportToFile
(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) static void
fillReportToFile
(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) static void
fillReportToFile
(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) static void
fillReportToStream
(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) static void
fillReportToStream
(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) static void
fillReportToStream
(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) static void
fillReportToStream
(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) static void
fillReportToStream
(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) static void
fillReportToStream
(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) void
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.void
fillToFile
(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.void
fillToFile
(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.void
fillToFile
(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.void
fillToFile
(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.void
fillToFile
(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.void
fillToStream
(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.void
fillToStream
(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.void
fillToStream
(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.void
fillToStream
(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.void
fillToStream
(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.void
fillToStream
(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 JasperFillManager
getInstance
(JasperReportsContext jasperReportsContext) protected JasperReportSource
getReportSource
(File reportFile) protected JasperReportSource
getReportSource
(File reportFile, JasperReport jasperReport) protected JasperReportSource
getReportSource
(String location) protected static JasperReportSource
getReportSource
(JasperReportsContext jasperReportsContext, File reportFile)
-
Field Details
-
PROPERTY_LEGACY_RELATIVE_PATH_ENABLED
Deprecated.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 totrue
to restore the pre 6.6.0 functionality.
The default value of the property isfalse
.- See Also:
-
-
Method Details
-
getInstance
-
fillToFile
public 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 serializedJasperPrint
object representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprint
extension, located in the same directory as the source file.- Parameters:
sourceFileName
- source file containing the compiled report designparams
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Throws:
JRException
-
fillToFile
Fills the compiled report design loaded from the specified file. The result of this operation is another file that will contain the serializedJasperPrint
object representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprint
extension, located in the same directory as the source file.- Parameters:
sourceFileName
- source file containing the compiled report designparams
- report parameters map- Throws:
JRException
- See Also:
-
fillToFile
public 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 designdestFileName
- file name to place the generated report intoparams
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Throws:
JRException
-
fillToFile
public 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 designdestFileName
- file name to place the generated report intoparams
- report parameters map- Throws:
JRException
- See Also:
-
fillToFile
public 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 fillingdestFileName
- file name to place the generated report intoparameters
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Throws:
JRException
-
fillToFile
public 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 fillingdestFileName
- file name to place the generated report intoparameters
- report parameters map- Throws:
JRException
- See Also:
-
fill
public 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 designparams
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Returns:
- generated report object
- Throws:
JRException
-
fillFromRepo
public 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 reportparams
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Returns:
- generated report object
- Throws:
JRException
-
fill
Fills the compiled report design loaded from the specified file and returns the generated report object.- Parameters:
sourceFileName
- source file containing the compiled report designparams
- report parameters map- Returns:
- generated report object
- Throws:
JRException
- See Also:
-
fillFromRepo
public 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 reportparams
- report parameters map- Returns:
- generated report object
- Throws:
JRException
- See Also:
-
fillToStream
public 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 fromoutputStream
- output stream to write the generated report object toparameters
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Throws:
JRException
-
fillToStream
public 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 fromoutputStream
- output stream to write the generated report object toparameters
- report parameters map- Throws:
JRException
- See Also:
-
fillToStream
public 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 fillingoutputStream
- output stream to write the generated report object toparameters
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Throws:
JRException
-
fillToStream
public 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 fillingoutputStream
- output stream to write the generated report object toparameters
- report parameters map- Throws:
JRException
- See Also:
-
fill
public 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 fromparameters
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Returns:
- generated report object
- Throws:
JRException
-
fill
Fills 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 fromparameters
- report parameters map- Returns:
- generated report object
- Throws:
JRException
- See Also:
-
fill
public 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 fillingparameters
- report parameters mapconnection
- JDBC connection object to use for executing the report internal SQL query- Returns:
- generated report object
- Throws:
JRException
-
fill
public 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 fillingparameters
- report parameters map- Returns:
- generated report object
- Throws:
JRException
- See Also:
-
fillToFile
public 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 serializedJasperPrint
object representing the generated document, having the same name as the report design as declared in the source file, plus the*.jrprint
extension, located in the same directory as the source file.- Parameters:
sourceFileName
- source file containing the compiled report designparams
- report parameters mapdataSource
- data source object- Throws:
JRException
-
fillToFile
public 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 designdestFileName
- file name to place the generated report intoparams
- report parameters mapdataSource
- data source object- Throws:
JRException
-
fillToFile
public 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 fillingdestFileName
- file name to place the generated report intoparameters
- report parameters mapdataSource
- data source object- Throws:
JRException
-
fill
public 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 designparams
- report parameters mapdataSource
- data source object- Returns:
- generated report object
- Throws:
JRException
-
fillFromRepo
public 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 reportparams
- report parameters mapdataSource
- data source object- Returns:
- generated report object
- Throws:
JRException
-
fillToStream
public 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 fromoutputStream
- output stream to write the generated report object toparameters
- report parameters mapdataSource
- data source object- Throws:
JRException
-
fillToStream
public 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 fillingoutputStream
- output stream to write the generated report object toparameters
- report parameters mapdataSource
- data source object- Throws:
JRException
-
fill
public 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 fromparameters
- report parameters mapdataSource
- data source object- Returns:
- generated report object
- Throws:
JRException
-
fill
public 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 fillingparameters
- report parameters mapdataSource
- data source object- Returns:
- generated report object
- Throws:
JRException
-
fillReportToFile
public static String fillReportToFile(String sourceFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static String fillReportToFile(String sourceFileName, Map<String, Object> params) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(String sourceFileName, Map<String, Object> params, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(String sourceFileName, Map<String, Object> params) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters, Connection connection) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static String fillReportToFile(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(String sourceFileName, String destFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReportToFile
public static void fillReportToFile(JasperReport jasperReport, String destFileName, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(String sourceFileName, Map<String, Object> params, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(InputStream inputStream, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReportToStream
public static void fillReportToStream(JasperReport jasperReport, OutputStream outputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(InputStream inputStream, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
fillReport
public static JasperPrint fillReport(JasperReport jasperReport, Map<String, Object> parameters, JRDataSource dataSource) throws JRException- Throws:
JRException
- See Also:
-
getReportSource
protected static JasperReportSource getReportSource(JasperReportsContext jasperReportsContext, File reportFile) throws JRException - Throws:
JRException
-
getReportSource
- Throws:
JRException
-
getReportSource
-
getReportSource
- Throws:
JRException
-