Package net.sf.jasperreports.groovy
Class JRGroovyCompiler
- java.lang.Object
-
- net.sf.jasperreports.engine.design.JRAbstractCompiler
-
- net.sf.jasperreports.engine.design.JRAbstractJavaCompiler
-
- net.sf.jasperreports.groovy.JRGroovyCompiler
-
- All Implemented Interfaces:
JRCompiler
public class JRGroovyCompiler extends JRAbstractJavaCompiler
Calculator compiler that uses groovy to compile expressions.- Author:
- Teodor Danciu (teodord@users.sourceforge.net), Peter Severin (peter_p_s@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_COMPILING_EXPRESSIONS_CLASS_FILE
static String
EXCEPTION_MESSAGE_KEY_REPORT_NOT_COMPILED_FOR_CLASS_FILTERING
static String
EXCEPTION_MESSAGE_KEY_TOO_FEW_CLASSES_GENERATED
static String
EXCEPTION_MESSAGE_KEY_TOO_MANY_CLASSES_GENERATED
-
Fields inherited from class net.sf.jasperreports.engine.design.JRAbstractJavaCompiler
EXCEPTION_MESSAGE_KEY_EXPECTED_JAVA_LANGUAGE, EXCEPTION_MESSAGE_KEY_EXPRESSION_CLASS_NOT_LOADED, PROPERTY_EVALUATOR_CLASS_REFERENCE_FIX_ENABLED
-
Fields inherited from class net.sf.jasperreports.engine.design.JRAbstractCompiler
EXCEPTION_MESSAGE_KEY_CROSSTAB_ID_NOT_FOUND, EXCEPTION_MESSAGE_KEY_DESIGN_COMPILE_ERROR, EXCEPTION_MESSAGE_KEY_LANGUAGE_NOT_SUPPORTED, EXCEPTION_MESSAGE_KEY_REPORT_EXPRESSIONS_COMPILE_ERROR, EXCEPTION_MESSAGE_KEY_TEMP_DIR_NOT_FOUND, jasperReportsContext, reportClassFilter
-
Fields inherited from interface net.sf.jasperreports.engine.design.JRCompiler
COMPILER_CLASS, COMPILER_CLASSPATH, COMPILER_KEEP_JAVA_FILE, COMPILER_PREFIX, COMPILER_TEMP_DIR
-
-
Constructor Summary
Constructors Constructor Description JRGroovyCompiler(JasperReportsContext jasperReportsContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkLanguage(String language)
Checks that the report language is supported by the compiler.protected String
compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile)
Compiles several expression evaluator units.protected DirectExpressionValueFilter
directValueFilter()
protected JRCompilationSourceCode
generateSourceCode(JRSourceCompileTask sourceTask)
Generates expression evaluator code.protected String
getSourceFileName(String unitName)
Returns the name of the source file where generated source code for an unit is saved.protected Class<?>
loadClass(String className, byte[] compileData)
protected Class<?>
loadClass(String className, CompiledClasses classes)
protected JREvaluator
loadEvaluator(Serializable compileData, String className)
Creates an expression evaluator instance from data saved when the report was compiled.-
Methods inherited from class net.sf.jasperreports.engine.design.JRAbstractJavaCompiler
classCacheKey, getClassFromCache, putClassInCache, toCompiledClasses
-
Methods inherited from class net.sf.jasperreports.engine.design.JRAbstractCompiler
compileReport, createCompileData, createEvaluator, effectiveDirectValueFilter, getCompilerClass, getSourceFile, getUnitName, getUnitName, getUnitName, getUnitName, getUnitName, loadEvaluator, loadEvaluator, loadEvaluator
-
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_COMPILING_EXPRESSIONS_CLASS_FILE
public static final String EXCEPTION_MESSAGE_KEY_COMPILING_EXPRESSIONS_CLASS_FILE
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_TOO_FEW_CLASSES_GENERATED
public static final String EXCEPTION_MESSAGE_KEY_TOO_FEW_CLASSES_GENERATED
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_TOO_MANY_CLASSES_GENERATED
public static final String EXCEPTION_MESSAGE_KEY_TOO_MANY_CLASSES_GENERATED
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_REPORT_NOT_COMPILED_FOR_CLASS_FILTERING
public static final String EXCEPTION_MESSAGE_KEY_REPORT_NOT_COMPILED_FOR_CLASS_FILTERING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JRGroovyCompiler
public JRGroovyCompiler(JasperReportsContext jasperReportsContext)
-
-
Method Detail
-
directValueFilter
protected DirectExpressionValueFilter directValueFilter()
- Overrides:
directValueFilter
in classJRAbstractJavaCompiler
-
compileUnits
protected String compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile) throws JRException
Description copied from class:JRAbstractCompiler
Compiles several expression evaluator units.The result of the compilation should be set by calling
setCompileData
on all compile units.- Specified by:
compileUnits
in classJRAbstractCompiler
- Parameters:
units
- the compilation unitsclasspath
- the compilation classpathtempDirFile
- temporary directory- Returns:
- a string containing compilation errors, or null if the compilation was successfull
- Throws:
JRException
-
checkLanguage
protected void checkLanguage(String language) throws JRException
Description copied from class:JRAbstractCompiler
Checks that the report language is supported by the compiler.- Specified by:
checkLanguage
in classJRAbstractCompiler
- Parameters:
language
- the report language- Throws:
JRException
-
generateSourceCode
protected JRCompilationSourceCode generateSourceCode(JRSourceCompileTask sourceTask) throws JRException
Description copied from class:JRAbstractCompiler
Generates expression evaluator code.- Specified by:
generateSourceCode
in classJRAbstractCompiler
- Parameters:
sourceTask
- the source code generation information- Returns:
- generated expression evaluator code
- Throws:
JRException
-
getSourceFileName
protected String getSourceFileName(String unitName)
Description copied from class:JRAbstractCompiler
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.- Specified by:
getSourceFileName
in classJRAbstractCompiler
- Parameters:
unitName
- the unit name- Returns:
- the source file name
-
loadClass
protected Class<?> loadClass(String className, byte[] compileData)
- Overrides:
loadClass
in classJRAbstractJavaCompiler
-
loadClass
protected Class<?> loadClass(String className, CompiledClasses classes)
- Overrides:
loadClass
in classJRAbstractJavaCompiler
-
loadEvaluator
protected JREvaluator loadEvaluator(Serializable compileData, String className) throws JRException
Description copied from class:JRAbstractCompiler
Creates an expression evaluator instance from data saved when the report was compiled.- Overrides:
loadEvaluator
in classJRAbstractJavaCompiler
- Parameters:
compileData
- the data saved when the report was compiledclassName
- the evaluator unit name- Returns:
- an expression evaluator instance
- Throws:
JRException
-
-