Package io.vertigo.commons.impl.script
Class ScriptManagerImpl
- java.lang.Object
-
- io.vertigo.commons.impl.script.ScriptManagerImpl
-
- All Implemented Interfaces:
ScriptManager,io.vertigo.core.node.component.Component,io.vertigo.core.node.component.CoreComponent,io.vertigo.core.node.component.Manager
public final class ScriptManagerImpl extends Object implements ScriptManager
This manager allows you to script a text. Some expressions can be used inside the text. These expressions will be parsed and evaluated.- Author:
- pchretien
-
-
Constructor Summary
Constructors Constructor Description ScriptManagerImpl(ExpressionEvaluatorPlugin expressionEvaluatorPlugin)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <J> JevaluateExpression(String expression, List<ExpressionParameter> parameters, Class<J> type)Evaluates an expression.StringevaluateScript(String script, SeparatorType separatorType, List<ExpressionParameter> parameters)Evaluates the script, transforms a script into a text.voidparse(String script, ScriptParserHandler scriptHandler, ScriptSeparator separator)Parses the script with a specific handler.
-
-
-
Constructor Detail
-
ScriptManagerImpl
@Inject public ScriptManagerImpl(ExpressionEvaluatorPlugin expressionEvaluatorPlugin)
Constructor.- Parameters:
expressionEvaluatorPlugin- the plugin used to evaluate an expression
-
-
Method Detail
-
parse
public void parse(String script, ScriptParserHandler scriptHandler, ScriptSeparator separator)
Parses the script with a specific handler. the grammar is defined by simple tags balises (separators).- Specified by:
parsein interfaceScriptManager- Parameters:
script- the script to analysescriptHandler- the handerseparator- the allowed separators in the grammar.
-
evaluateScript
public String evaluateScript(String script, SeparatorType separatorType, List<ExpressionParameter> parameters)
Evaluates the script, transforms a script into a text.- Specified by:
evaluateScriptin interfaceScriptManager- Parameters:
script- the scriptseparatorType- the type of separatorparameters- the parameters- Returns:
- the evaluated script as a simplet text
-
evaluateExpression
public <J> J evaluateExpression(String expression, List<ExpressionParameter> parameters, Class<J> type)
Evaluates an expression. Examples of expressions written in java - name - birthDate - age>20 - salary>5000 && age <30 - name + surName- Specified by:
evaluateExpressionin interfaceScriptManager- Parameters:
expression- the expressionparameters- the parameterstype- the returned type- Returns:
- the evaluated expression
-
-