类 TemplateAwareExpressionParser

java.lang.Object
cn.taketoday.expression.common.TemplateAwareExpressionParser
所有已实现的接口:
ExpressionParser
直接已知子类:
InternalSpelExpressionParser, SpelExpressionParser

public abstract class TemplateAwareExpressionParser extends Object implements ExpressionParser
An expression parser that understands templates. It can be subclassed by expression parsers that do not offer first class support for templating.
从以下版本开始:
4.0
作者:
Keith Donald, Juergen Hoeller, Andy Clement
  • 构造器详细资料

    • TemplateAwareExpressionParser

      public TemplateAwareExpressionParser()
  • 方法详细资料

    • parseExpression

      public Expression parseExpression(String expressionString) throws ParseException
      从接口复制的说明: ExpressionParser
      Parse the expression string and return an Expression object you can use for repeated evaluation.

      Some examples:

           3 + 4
           name.firstName
       
      指定者:
      parseExpression 在接口中 ExpressionParser
      参数:
      expressionString - the raw expression string to parse
      返回:
      an evaluator for the parsed expression
      抛出:
      ParseException - an exception occurred during parsing
    • parseExpression

      public Expression parseExpression(String expressionString, @Nullable ParserContext context) throws ParseException
      从接口复制的说明: ExpressionParser
      Parse the expression string and return an Expression object you can use for repeated evaluation.

      Some examples:

           3 + 4
           name.firstName
       
      指定者:
      parseExpression 在接口中 ExpressionParser
      参数:
      expressionString - the raw expression string to parse
      context - a context for influencing this expression parsing routine (optional)
      返回:
      an evaluator for the parsed expression
      抛出:
      ParseException - an exception occurred during parsing
    • parseTemplate

      private Expression parseTemplate(String expressionString, ParserContext context) throws ParseException
      抛出:
      ParseException
    • parseExpressions

      private List<Expression> parseExpressions(String expressionString, ParserContext context) throws ParseException
      Helper that parses given expression string using the configured parser. The expression string can contain any number of expressions all contained in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static pieces of text will also be returned as Expressions that just return that static piece of text. As a result, evaluating all returned expressions and concatenating the results produces the complete evaluated string. Unwrapping is only done of the outermost delimiters found, so the string 'hello ${foo${abc}}' would break into the pieces 'hello ' and 'foo${abc}'. This means that expression languages that used ${..} as part of their functionality are supported without any problem. The parsing is aware of the structure of an embedded expression. It assumes that parentheses '(', square brackets '[' and curly brackets '}' must be in pairs within the expression unless they are within a string literal and a string literal starts and terminates with a single quote '.
      参数:
      expressionString - the expression string
      返回:
      the parsed expressions
      抛出:
      ParseException - when the expressions cannot be parsed
    • isSuffixHere

      private boolean isSuffixHere(String expressionString, int pos, String suffix)
      Return true if the specified suffix can be found at the supplied position in the supplied expression string.
      参数:
      expressionString - the expression string which may contain the suffix
      pos - the start position at which to check for the suffix
      suffix - the suffix string
    • skipToCorrectEndSuffix

      private int skipToCorrectEndSuffix(String suffix, String expressionString, int afterPrefixIndex) throws ParseException
      Copes with nesting, for example '${...${...}}' where the correct end for the first ${ is the final }.
      参数:
      suffix - the suffix
      expressionString - the expression string
      afterPrefixIndex - the most recently found prefix location for which the matching end suffix is being sought
      返回:
      the position of the correct matching nextSuffix or -1 if none can be found
      抛出:
      ParseException
    • doParseExpression

      protected abstract Expression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException
      Actually parse the expression string and return an Expression object.
      参数:
      expressionString - the raw expression string to parse
      context - a context for influencing this expression parsing routine (optional)
      返回:
      an evaluator for the parsed expression
      抛出:
      ParseException - an exception occurred during parsing