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
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
ConstructorsConstructorDescriptionScriptManagerImpl(ExpressionEvaluatorPlugin expressionEvaluatorPlugin) Constructor. -
Method Summary
Modifier and TypeMethodDescription<J> JevaluateExpression(String expression, List<ExpressionParameter> parameters, Class<J> type) Evaluates an expression.evaluateScript(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 Details
-
ScriptManagerImpl
Constructor.- Parameters:
expressionEvaluatorPlugin- the plugin used to evaluate an expression
-
-
Method Details
-
parse
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 invalid input: '&'invalid input: '&' age invalid input: '<'30 - name + surName- Specified by:
evaluateExpressionin interfaceScriptManager- Parameters:
expression- the expressionparameters- the parameterstype- the returned type- Returns:
- the evaluated expression
-