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 Details

    • ScriptManagerImpl

      @Inject public ScriptManagerImpl(ExpressionEvaluatorPlugin expressionEvaluatorPlugin)
      Constructor.
      Parameters:
      expressionEvaluatorPlugin - the plugin used to evaluate an expression
  • Method Details

    • 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:
      parse in interface ScriptManager
      Parameters:
      script - the script to analyse
      scriptHandler - the hander
      separator - 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:
      evaluateScript in interface ScriptManager
      Parameters:
      script - the script
      separatorType - the type of separator
      parameters - 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:
      evaluateExpression in interface ScriptManager
      Parameters:
      expression - the expression
      parameters - the parameters
      type - the returned type
      Returns:
      the evaluated expression