Class JRAbstractCompiler

    • Field Detail

      • EXCEPTION_MESSAGE_KEY_CROSSTAB_ID_NOT_FOUND

        public static final String EXCEPTION_MESSAGE_KEY_CROSSTAB_ID_NOT_FOUND
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_DESIGN_COMPILE_ERROR

        public static final String EXCEPTION_MESSAGE_KEY_DESIGN_COMPILE_ERROR
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_LANGUAGE_NOT_SUPPORTED

        public static final String EXCEPTION_MESSAGE_KEY_LANGUAGE_NOT_SUPPORTED
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_REPORT_EXPRESSIONS_COMPILE_ERROR

        public static final String EXCEPTION_MESSAGE_KEY_REPORT_EXPRESSIONS_COMPILE_ERROR
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_TEMP_DIR_NOT_FOUND

        public static final String EXCEPTION_MESSAGE_KEY_TEMP_DIR_NOT_FOUND
        See Also:
        Constant Field Values
    • Constructor Detail

      • JRAbstractCompiler

        protected JRAbstractCompiler​(JasperReportsContext jasperReportsContext,
                                     boolean needsSourceFiles)
        Constructor.
        Parameters:
        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.

    • Method Detail

      • getUnitName

        public static String getUnitName​(JasperReport report,
                                         JRDataset dataset)
        Returns the name of the expression evaluator unit for a dataset of a report.
        Parameters:
        report - the report
        dataset - the dataset
        Returns:
        the generated expression evaluator unit name
      • getUnitName

        public static String getUnitName​(JasperReport report,
                                         JRCrosstab crosstab)
        Returns the name of the expression evaluator unit for a crosstab of a report.
        Parameters:
        report - the report
        crosstab - the crosstab
        Returns:
        the generated expression evaluator unit name
      • getUnitName

        protected static String getUnitName​(JRReport report,
                                            int crosstabId,
                                            String nameSuffix)
      • compileReport

        public final JasperReport compileReport​(JasperDesign jasperDesign)
                                         throws JRException
        Description copied from interface: JRCompiler
        Compiles a report design.

        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.

        Specified by:
        compileReport in interface JRCompiler
        Parameters:
        jasperDesign - the report design
        Returns:
        the compiled report
        Throws:
        JRException
      • getCompilerClass

        protected String getCompilerClass()
      • loadEvaluator

        protected abstract JREvaluator loadEvaluator​(Serializable compileData,
                                                     String unitName)
                                              throws JRException
        Creates an expression evaluator instance from data saved when the report was compiled.
        Parameters:
        compileData - the data saved when the report was compiled
        unitName - the evaluator unit name
        Returns:
        an expression evaluator instance
        Throws:
        JRException
      • checkLanguage

        protected abstract void checkLanguage​(String language)
                                       throws JRException
        Checks that the report language is supported by the compiler.
        Parameters:
        language - the report language
        Throws:
        JRException
      • compileUnits

        protected abstract String compileUnits​(JRCompilationUnit[] units,
                                               String classpath,
                                               File tempDirFile)
                                        throws JRException
        Compiles several expression evaluator units.

        The result of the compilation should be set by calling setCompileData on all compile units.

        Parameters:
        units - the compilation units
        classpath - the compilation classpath
        tempDirFile - temporary directory
        Returns:
        a string containing compilation errors, or null if the compilation was successfull
        Throws:
        JRException
      • getSourceFileName

        protected abstract String getSourceFileName​(String unitName)
        Returns the name of the source file where generated source code for an unit is saved.

        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.

        Parameters:
        unitName - the unit name
        Returns:
        the source file name