net.sf.jasperreports.compilers
Class JavaScriptEvaluator

java.lang.Object
  extended by net.sf.jasperreports.engine.fill.JREvaluator
      extended by net.sf.jasperreports.compilers.JavaScriptEvaluator
All Implemented Interfaces:
DatasetExpressionEvaluator

public class JavaScriptEvaluator
extends JREvaluator

JavaScript expression evaluator.

Version:
$Id: JavaScriptEvaluator.java 3717 2010-04-09 10:01:33Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
static class JavaScriptEvaluator.JSField
          Field class used in JavaScript expressions.
static class JavaScriptEvaluator.JSParameter
          Parameter class used in JavaScript expressions.
static class JavaScriptEvaluator.JSValue
          Base JavaScript value class.
static class JavaScriptEvaluator.JSVariable
          Variable class used in JavaScript expressions.
 
Constructor Summary
JavaScriptEvaluator(JavaScriptCompileData compileData)
          Create a JavaScript expression evaluator.
 
Method Summary
protected static JavaScriptCompileData.Expression createJSExpression(JRExpression expression)
           
protected  void customizedInit(java.util.Map parametersMap, java.util.Map fieldsMap, java.util.Map variablesMap)
          Initializes the parameters, fields and variables of the evaluator.
protected  java.lang.Object evaluate(int id)
          Evaluates an expression using current fields and variables values.
protected  java.lang.Object evaluateEstimated(int id)
          Evaluates an expression using estimated variables values.
protected  java.lang.Object evaluateExpression(java.lang.String type, java.lang.String expression)
           
protected  java.lang.Object evaluateOld(int id)
          Evaluates an expression using old fields and variables values.
protected  org.mozilla.javascript.Script getCompiledExpression(java.lang.String expression)
           
protected  JavaScriptCompileData.Expression getExpression(int id)
           
protected static java.lang.String getFieldVar(java.lang.String name)
           
protected static java.lang.String getParameterVar(java.lang.String name)
           
protected  java.lang.Class getTypeClass(java.lang.String type)
           
protected static java.lang.String getVariableVar(java.lang.String name)
           
 
Methods inherited from class net.sf.jasperreports.engine.fill.JREvaluator
evaluate, evaluateEstimated, evaluateOld, handleMissingResource, init, msg, msg, msg, msg, str
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptEvaluator

public JavaScriptEvaluator(JavaScriptCompileData compileData)
Create a JavaScript expression evaluator.

Parameters:
compileData - the report compile data
Method Detail

createJSExpression

protected static JavaScriptCompileData.Expression createJSExpression(JRExpression expression)

getParameterVar

protected static java.lang.String getParameterVar(java.lang.String name)

getVariableVar

protected static java.lang.String getVariableVar(java.lang.String name)

getFieldVar

protected static java.lang.String getFieldVar(java.lang.String name)

customizedInit

protected void customizedInit(java.util.Map parametersMap,
                              java.util.Map fieldsMap,
                              java.util.Map variablesMap)
                       throws JRException
Description copied from class: JREvaluator
Initializes the parameters, fields and variables of the evaluator.

Specified by:
customizedInit in class JREvaluator
Parameters:
parametersMap - the parameters indexed by name
fieldsMap - the fields indexed by name
variablesMap - the variables indexed by name
Throws:
JRException

evaluate

protected java.lang.Object evaluate(int id)
                             throws java.lang.Throwable
Description copied from class: JREvaluator
Evaluates an expression using current fields and variables values.

Specified by:
evaluate in class JREvaluator
Parameters:
id - the expression id
Returns:
the result of the evaluation
Throws:
java.lang.Throwable
See Also:
JRExpression.EVALUATION_DEFAULT, JRFillVariable.getValue(), JRFillField.getValue()

evaluateEstimated

protected java.lang.Object evaluateEstimated(int id)
                                      throws java.lang.Throwable
Description copied from class: JREvaluator
Evaluates an expression using estimated variables values.

Specified by:
evaluateEstimated in class JREvaluator
Parameters:
id - the expression id
Returns:
the result of the evaluation
Throws:
java.lang.Throwable
See Also:
JRExpression.EVALUATION_ESTIMATED, JRFillVariable.getEstimatedValue()

evaluateOld

protected java.lang.Object evaluateOld(int id)
                                throws java.lang.Throwable
Description copied from class: JREvaluator
Evaluates an expression using old fields and variables values.

Specified by:
evaluateOld in class JREvaluator
Parameters:
id - the expression id
Returns:
the result of the evaluation
Throws:
java.lang.Throwable
See Also:
JRExpression.EVALUATION_OLD, JRFillVariable.getOldValue(), JRFillField.getOldValue()

getExpression

protected JavaScriptCompileData.Expression getExpression(int id)

evaluateExpression

protected java.lang.Object evaluateExpression(java.lang.String type,
                                              java.lang.String expression)

getCompiledExpression

protected org.mozilla.javascript.Script getCompiledExpression(java.lang.String expression)

getTypeClass

protected java.lang.Class getTypeClass(java.lang.String type)


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com