类 TemplateAwareExpressionParser
java.lang.Object
cn.taketoday.expression.common.TemplateAwareExpressionParser
- 所有已实现的接口:
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
-
嵌套类概要
嵌套类修饰符和类型类说明private static classThis captures a type of bracket and the position in which it occurs in the expression. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected abstract ExpressiondoParseExpression(String expressionString, ParserContext context) Actually parse the expression string and return an Expression object.private booleanisSuffixHere(String expressionString, int pos, String suffix) Return true if the specified suffix can be found at the supplied position in the supplied expression string.parseExpression(String expressionString) Parse the expression string and return an Expression object you can use for repeated evaluation.parseExpression(String expressionString, ParserContext context) Parse the expression string and return an Expression object you can use for repeated evaluation.private List<Expression>parseExpressions(String expressionString, ParserContext context) Helper that parses given expression string using the configured parser.private ExpressionparseTemplate(String expressionString, ParserContext context) private intskipToCorrectEndSuffix(String suffix, String expressionString, int afterPrefixIndex) Copes with nesting, for example '${...${...}}' where the correct end for the first ${ is the final }.
-
构造器详细资料
-
TemplateAwareExpressionParser
public TemplateAwareExpressionParser()
-
-
方法详细资料
-
parseExpression
从接口复制的说明:ExpressionParserParse 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 从接口复制的说明:ExpressionParserParse 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 parsecontext- 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
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 suffixpos- the start position at which to check for the suffixsuffix- 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 suffixexpressionString- the expression stringafterPrefixIndex- 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 parsecontext- a context for influencing this expression parsing routine (optional)- 返回:
- an evaluator for the parsed expression
- 抛出:
ParseException- an exception occurred during parsing
-