public abstract class JRAbstractCompiler extends Object implements JRCompiler
Modifier and Type | Field and Description |
---|---|
static String |
EXCEPTION_MESSAGE_KEY_CROSSTAB_ID_NOT_FOUND |
static String |
EXCEPTION_MESSAGE_KEY_DESIGN_COMPILE_ERROR |
static String |
EXCEPTION_MESSAGE_KEY_LANGUAGE_NOT_SUPPORTED |
static String |
EXCEPTION_MESSAGE_KEY_REPORT_EXPRESSIONS_COMPILE_ERROR |
static String |
EXCEPTION_MESSAGE_KEY_TEMP_DIR_NOT_FOUND |
protected JasperReportsContext |
jasperReportsContext |
COMPILER_CLASS, COMPILER_CLASSPATH, COMPILER_KEEP_JAVA_FILE, COMPILER_PREFIX, COMPILER_TEMP_DIR
Modifier | Constructor and Description |
---|---|
protected |
JRAbstractCompiler(JasperReportsContext jasperReportsContext,
boolean needsSourceFiles)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkLanguage(String language)
Checks that the report language is supported by the compiler.
|
JasperReport |
compileReport(JasperDesign jasperDesign)
Compiles a report design.
|
protected abstract String |
compileUnits(JRCompilationUnit[] units,
String classpath,
File tempDirFile)
Compiles several expression evaluator units.
|
protected abstract JRCompilationSourceCode |
generateSourceCode(JRSourceCompileTask sourceTask)
Generates expression evaluator code.
|
protected String |
getCompilerClass() |
protected File |
getSourceFile(File saveSourceDir,
String unitName,
JRCompilationSourceCode sourceCode) |
protected abstract String |
getSourceFileName(String unitName)
Returns the name of the source file where generated source code for an unit is saved.
|
static String |
getUnitName(JasperReport report,
JRCrosstab crosstab)
Returns the name of the expression evaluator unit for a crosstab of a report.
|
static String |
getUnitName(JasperReport report,
JRDataset dataset)
Returns the name of the expression evaluator unit for a dataset of a report.
|
protected static String |
getUnitName(JRReport report,
int crosstabId,
String nameSuffix) |
protected static String |
getUnitName(JRReport report,
JRCrosstab crosstab,
JRExpressionCollector expressionCollector,
String nameSuffix) |
protected static String |
getUnitName(JRReport report,
JRDataset dataset,
String nameSuffix) |
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.
|
protected abstract JREvaluator |
loadEvaluator(Serializable compileData,
String unitName)
Creates an expression evaluator instance from data saved when the report was compiled.
|
public static final String EXCEPTION_MESSAGE_KEY_CROSSTAB_ID_NOT_FOUND
public static final String EXCEPTION_MESSAGE_KEY_DESIGN_COMPILE_ERROR
public static final String EXCEPTION_MESSAGE_KEY_LANGUAGE_NOT_SUPPORTED
public static final String EXCEPTION_MESSAGE_KEY_REPORT_EXPRESSIONS_COMPILE_ERROR
public static final String EXCEPTION_MESSAGE_KEY_TEMP_DIR_NOT_FOUND
protected final JasperReportsContext jasperReportsContext
protected JRAbstractCompiler(JasperReportsContext jasperReportsContext, boolean needsSourceFiles)
needsSourceFiles
- whether the compiler needs source files or is able to do in memory compilation
If true, the generated code is saved in source files to be used by the compiler.
public static String getUnitName(JasperReport report, JRDataset dataset)
report
- the reportdataset
- the datasetprotected static String getUnitName(JRReport report, JRDataset dataset, String nameSuffix)
public static String getUnitName(JasperReport report, JRCrosstab crosstab)
report
- the reportcrosstab
- the crosstabprotected static String getUnitName(JRReport report, JRCrosstab crosstab, JRExpressionCollector expressionCollector, String nameSuffix)
public final JasperReport compileReport(JasperDesign jasperDesign) throws JRException
JRCompiler
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
.
compileReport
in interface JRCompiler
jasperDesign
- the report designJRException
protected String getCompilerClass()
protected File getSourceFile(File saveSourceDir, String unitName, JRCompilationSourceCode sourceCode)
public JREvaluator loadEvaluator(JasperReport jasperReport) throws JRException
JRCompiler
loadEvaluator
in interface JRCompiler
jasperReport
- the reportJRException
public JREvaluator loadEvaluator(JasperReport jasperReport, JRDataset dataset) throws JRException
JRCompiler
loadEvaluator
in interface JRCompiler
jasperReport
- the reportdataset
- the datasetJRException
public JREvaluator loadEvaluator(JasperReport jasperReport, JRCrosstab crosstab) throws JRException
JRCompiler
loadEvaluator
in interface JRCompiler
jasperReport
- the reportcrosstab
- the crosstabJRException
protected abstract JREvaluator loadEvaluator(Serializable compileData, String unitName) throws JRException
compileData
- the data saved when the report was compiledunitName
- the evaluator unit nameJRException
protected abstract void checkLanguage(String language) throws JRException
language
- the report languageJRException
protected abstract JRCompilationSourceCode generateSourceCode(JRSourceCompileTask sourceTask) throws JRException
sourceTask
- the source code generation informationJRException
protected abstract String compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile) throws JRException
The result of the compilation should be set by calling
setCompileData
on all compile units.
units
- the compilation unitsclasspath
- the compilation classpathtempDirFile
- temporary directoryJRException
protected abstract String getSourceFileName(String unitName)
If the compiler needs source files for compilation
or COMPILER_KEEP_JAVA_FILE
is set, the generated source
will be saved in a file having the name returned by this method.
unitName
- the unit nameCopyright © 2017. All rights reserved.