Package net.sf.jasperreports.compilers
Class JavaScriptClassCompiler
- java.lang.Object
-
- net.sf.jasperreports.engine.design.JRAbstractCompiler
-
- net.sf.jasperreports.compilers.JavaScriptCompilerBase
-
- net.sf.jasperreports.compilers.JavaScriptClassCompiler
-
- All Implemented Interfaces:
JRCompiler
public class JavaScriptClassCompiler extends JavaScriptCompilerBase
Compiler for reports that use JavaScript as expression language. This implementation produces Java bytecode for the expressions.- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
- See Also:
JavaScriptCompiledData,JavaScriptCompiledEvaluator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJavaScriptClassCompiler.CompileSources-
Nested classes/interfaces inherited from class net.sf.jasperreports.compilers.JavaScriptCompilerBase
JavaScriptCompilerBase.Errors, JavaScriptCompilerBase.ScriptExpressionVisitor
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASS_NAMEstatic StringEXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASSES_LENGTHstatic StringPROPERTY_EXPRESSIONS_PER_SCRIPTProperty that determines the maximum number of report expressions that will be included in a single generated Java class.static StringPROPERTY_OPTIMIZATION_LEVELProperty that determines the optimization level to use when compiling expressions into Java bytecode.static StringPROPERTY_SCRIPT_MAX_SIZEProperty that determines the maximum size of a script that will be compiled into a single Java class.-
Fields inherited from class net.sf.jasperreports.compilers.JavaScriptCompilerBase
EXCEPTION_MESSAGE_KEY_INVALID_COMPILE_DATA_TYPE
-
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 JavaScriptClassCompiler(JasperReportsContext jasperReportsContext)Creates a JavaScript compiler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcompileScripts(JRCompilationUnit unit, org.mozilla.javascript.CompilerEnvirons compilerEnv, JavaScriptClassCompiler.CompileSources compileSources, JavaScriptCompiledData compiledData)protected StringcompileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile)Compiles several expression evaluator units.-
Methods inherited from class net.sf.jasperreports.compilers.JavaScriptCompilerBase
checkLanguage, defaultExpressionCreator, estimatedExpressionCreator, generateSourceCode, getFieldVar, getParameterVar, getSourceFileName, getVariableVar, loadEvaluator, oldExpressionCreator
-
Methods inherited from class net.sf.jasperreports.engine.design.JRAbstractCompiler
compileReport, createCompileData, createEvaluator, directValueFilter, effectiveDirectValueFilter, getCompilerClass, getSourceFile, getUnitName, getUnitName, getUnitName, getUnitName, getUnitName, loadEvaluator, loadEvaluator, loadEvaluator
-
-
-
-
Field Detail
-
PROPERTY_OPTIMIZATION_LEVEL
public static final String PROPERTY_OPTIMIZATION_LEVEL
Property that determines the optimization level to use when compiling expressions into Java bytecode. See- See Also:
- Constant Field Values
-
PROPERTY_EXPRESSIONS_PER_SCRIPT
public static final String PROPERTY_EXPRESSIONS_PER_SCRIPT
Property that determines the maximum number of report expressions that will be included in a single generated Java class.- See Also:
- Constant Field Values
-
PROPERTY_SCRIPT_MAX_SIZE
public static final String PROPERTY_SCRIPT_MAX_SIZE
Property that determines the maximum size of a script that will be compiled into a single Java class.- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASS_NAME
public static final String EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASS_NAME
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASSES_LENGTH
public static final String EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASSES_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaScriptClassCompiler
public JavaScriptClassCompiler(JasperReportsContext jasperReportsContext)
Creates a JavaScript compiler.
-
-
Method Detail
-
compileUnits
protected String compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile) throws JRException
Description copied from class:JRAbstractCompilerCompiles several expression evaluator units.The result of the compilation should be set by calling
setCompileDataon all compile units.- Specified by:
compileUnitsin 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
-
compileScripts
protected void compileScripts(JRCompilationUnit unit, org.mozilla.javascript.CompilerEnvirons compilerEnv, JavaScriptClassCompiler.CompileSources compileSources, JavaScriptCompiledData compiledData)
-
-