public interface JRCompiler
Source report templates, created either by using the API or by parsing JRXML files, are subject to the report compilation process before they are filled with data. This is necessary to make various consistency validations and to incorporate into these report templates data used to evaluate all report expressions at runtime.
The compilation process transforms
JasperDesign
objects into
JasperReport
objects. Both classes are
implementations of the same basic JRReport
interface. However, JasperReport
objects
cannot be modified once they are produced,
while JasperDesign
objects can.
This is because some modifications made on the
report template would probably require re-validation, or if a report expression is
modified, the compiler-associated data stored inside the report template would have to be
updated.
JasperDesign
objects are produced when parsing JRXML files using the
JRXmlLoader
or created directly by the parent
application if dynamic report templates are required. The GUI tools for editing
JasperReports templates also work with this class to make in-memory modifications to
the report templates before storing them on disk.
A JasperDesign
object must be
subject to the report compilation process to produce a
JasperReport
object.
Central to this process is this JRCompiler
interface, which defines few methods, one being the following:
public JasperReport compileReport(JasperDesign design) throws JRException;
There are several implementations for this compiler interface depending on the language used for the report expressions or the mechanism used for their runtime evaluation.
JasperReports currently ships report compiler implementations for the Groovy scripting language (http://groovy.codehaus.org) and JavaScript (http://www.mozilla.org/rhino).
The related compiler implementation classes are:
Since the most common scenario is to use the Java language for writing report
expressions, default implementations of the report compiler interface are shipped with
the library and are ready to use. They generate a Java class from the report expressions
and store bytecode in the generated JasperReport
object for use at report-filling time.
JasperReport
,
JasperDesign
,
JRXmlLoader
Modifier and Type | Field and Description |
---|---|
static String |
COMPILER_CLASS
Deprecated.
Replaced by
COMPILER_PREFIX . |
static String |
COMPILER_CLASSPATH
The classpath used by the report compiler.
|
static String |
COMPILER_KEEP_JAVA_FILE
Whether to keep the java file generated when the report is compiled.
|
static String |
COMPILER_PREFIX
Prefix for properties that map report compilers to expression languages.
|
static String |
COMPILER_TEMP_DIR
The temporary directory used by the report compiler.
|
Modifier and Type | Method and Description |
---|---|
JasperReport |
compileReport(JasperDesign jasperDesign)
Compiles a report design.
|
JREvaluator |
loadEvaluator(JasperReport jasperReport)
Loads the evaluator for a report's main dataset.
|
JREvaluator |
loadEvaluator(JasperReport jasperReport,
JRCrosstab crosstab)
Loads a expression evaluator class for a crosstab of a report.
|
JREvaluator |
loadEvaluator(JasperReport jasperReport,
JRDataset dataset)
Loads a expression evaluator class for a dataset of a report.
|
static final String COMPILER_CLASS
COMPILER_PREFIX
.No default value.
static final String COMPILER_PREFIX
static final String COMPILER_KEEP_JAVA_FILE
Defaults to false
.
static final String COMPILER_TEMP_DIR
Defaults to System.getProperty("user.dir")
.
static final String COMPILER_CLASSPATH
Defaults to System.getProperty("java.class.path")
.
JasperReport compileReport(JasperDesign jasperDesign) throws JRException
The compilation consists of verification of the design, generation of expression evaluators and construction of a serializable read-only version of the report.
A report compiler should usually extend JRAbstractCompiler
.
jasperDesign
- the report designJRException
JREvaluator loadEvaluator(JasperReport jasperReport) throws JRException
jasperReport
- the reportJRException
JREvaluator loadEvaluator(JasperReport jasperReport, JRDataset dataset) throws JRException
jasperReport
- the reportdataset
- the datasetJRException
JREvaluator loadEvaluator(JasperReport jasperReport, JRCrosstab crosstab) throws JRException
jasperReport
- the reportcrosstab
- the crosstabJRException
Copyright © 2021 TIBCO Software Inc.. All rights reserved.