Top Description Fields Constructors Methods
org.springframework.expression.spel.standard

pack-priv Class InternalSpelExpressionParser

extends TemplateAwareExpressionParser
Class Inheritance
Imports
java.util.ArrayDeque, .ArrayList, .Collections, .Deque, .List, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.regex.Pattern, org.springframework.expression.ParseException, .ParserContext, org.springframework.expression.common.TemplateAwareExpressionParser, org.springframework.expression.spel.InternalParseException, .SpelEvaluationException, .SpelMessage, .SpelParseException, .SpelParserConfiguration, org.springframework.expression.spel.ast.Assign, .BeanReference, .BooleanLiteral, .CompoundExpression, .ConstructorReference, .Elvis, .FunctionReference, .Identifier, .Indexer, .InlineList, .InlineMap, .Literal, .MethodReference, .NullLiteral, .OpAnd, .OpDec, .OpDivide, .OpEQ, .OpGE, .OpGT, .OpInc, .OpLE, .OpLT, .OpMinus, .OpModulus, .OpMultiply, .OpNE, .OpOr, .OpPlus, .OperatorBetween, .OperatorInstanceof, .OperatorMatches, .OperatorNot, .OperatorPower, .Projection, .PropertyOrFieldReference, .QualifiedIdentifier, .Selection, .SpelNodeImpl, .StringLiteral, .Ternary, .TypeReference, .VariableReference, org.springframework.lang.Nullable, org.springframework.util.StringUtils

Handwritten SpEL parser. Instances are reusable but are not thread-safe.
Authors
Andy Clement, Juergen Hoeller, Phillip Webb, Sam Brannen
Since
3.0

Field Summary

Modifier and TypeField and Description
private final SpelParserConfiguration
private final Deque<SpelNodeImpl>
private String
private final ConcurrentMap<String, Pattern>
private List<Token>
private int
private int
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
InternalSpelExpressionParser(SpelParserConfiguration
custom configuration options
configuration
)

Create a parser with some configured behavior.

Method Summary

Modifier and TypeMethod and Description
private void
private void
checkLeftOperand(Token token, SpelNodeImpl operandExpression)

private void
private void
checkRightOperand(Token token, SpelNodeImpl operandExpression)

private void
consumeArguments(List<SpelNodeImpl> accumulatedArguments)

Used for consuming arguments for either a method or a constructor call.

protected SpelExpression
doParseExpression(String
the raw expression string to parse
expressionString
,
ParserContext
a context for influencing this expression parsing routine (optional)
context
)

Implements abstract org.springframework.expression.common.TemplateAwareExpressionParser.doParseExpression.

Actually parse the expression string and return an Expression object.
private void
eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments)

private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
eatPossiblyQualifiedId()

Eat an identifier, possibly qualified (meaning that it is dotted).

private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private SpelNodeImpl
private Token
eatToken(TokenKind expectedKind)

private SpelNodeImpl
private InternalParseException
internalException(int startPos, SpelMessage message, Object... inserts)

private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private SpelNodeImpl[]
private boolean
maybeEatMethodOrProperty(boolean nullSafeNavigation)

private boolean
private boolean
private boolean
maybeEatProjection(boolean nullSafeNavigation)

private Token
private boolean
maybeEatSelection(boolean nullSafeNavigation)

private boolean
private Token
private boolean
peekIdentifierToken(String identifierString)

private boolean
private boolean
peekToken(TokenKind desiredTokenKind)

private boolean
peekToken(TokenKind desiredTokenKind, boolean consumeIfMatched)

private boolean
peekToken(TokenKind possible1, TokenKind possible2)

private boolean
peekToken(TokenKind possible1, TokenKind possible2, TokenKind possible3)

private Token
private SpelNodeImpl
pop()

private int
private void
push(SpelNodeImpl newNode)

private Token
public String
Inherited from org.springframework.expression.common.TemplateAwareExpressionParser:
parseExpressionparseExpression

Field Detail

configurationback to summary
private final SpelParserConfiguration configuration
constructedNodesback to summary
private final Deque<SpelNodeImpl> constructedNodes
expressionStringback to summary
private String expressionString
patternCacheback to summary
private final ConcurrentMap<String, Pattern> patternCache
tokenStreamback to summary
private List<Token> tokenStream
tokenStreamLengthback to summary
private int tokenStreamLength
tokenStreamPointerback to summary
private int tokenStreamPointer
VALID_QUALIFIED_ID_PATTERNback to summary
private static final Pattern VALID_QUALIFIED_ID_PATTERN

Constructor Detail

InternalSpelExpressionParserback to summary
public InternalSpelExpressionParser(SpelParserConfiguration configuration)

Create a parser with some configured behavior.

Parameters
configuration:SpelParserConfiguration

custom configuration options

Method Detail

checkExpressionLengthback to summary
private void checkExpressionLength(String string)
checkLeftOperandback to summary
private void checkLeftOperand(Token token, SpelNodeImpl operandExpression)
checkOperandsback to summary
private void checkOperands(Token token, SpelNodeImpl left, SpelNodeImpl right)
checkRightOperandback to summary
private void checkRightOperand(Token token, SpelNodeImpl operandExpression)
consumeArgumentsback to summary
private void consumeArguments(List<SpelNodeImpl> accumulatedArguments)

Used for consuming arguments for either a method or a constructor call.

doParseExpressionback to summary
protected SpelExpression doParseExpression(String expressionString, ParserContext context) throws ParseException

Implements abstract org.springframework.expression.common.TemplateAwareExpressionParser.doParseExpression.

Doc from org.springframework.expression.common.TemplateAwareExpressionParser.doParseExpression.

Actually parse the expression string and return an Expression object.

Parameters
expressionString:String

the raw expression string to parse

context:ParserContext

a context for influencing this expression parsing routine (optional)

Returns:SpelExpression

an evaluator for the parsed expression

Annotations
@Override
Exceptions
ParseException:
an exception occurred during parsing
eatConstructorArgsback to summary
private void eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments)
eatDottedNodeback to summary
private SpelNodeImpl eatDottedNode()
eatExpressionback to summary
private SpelNodeImpl eatExpression()
Annotations
@Nullable
eatLogicalAndExpressionback to summary
private SpelNodeImpl eatLogicalAndExpression()
Annotations
@Nullable
eatLogicalOrExpressionback to summary
private SpelNodeImpl eatLogicalOrExpression()
Annotations
@Nullable
eatNodeback to summary
private SpelNodeImpl eatNode()
Annotations
@Nullable
eatNonDottedNodeback to summary
private SpelNodeImpl eatNonDottedNode()
Annotations
@Nullable
eatPossiblyQualifiedIdback to summary
private SpelNodeImpl eatPossiblyQualifiedId()

Eat an identifier, possibly qualified (meaning that it is dotted). TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c)

eatPowerIncDecExpressionback to summary
private SpelNodeImpl eatPowerIncDecExpression()
Annotations
@Nullable
eatPrimaryExpressionback to summary
private SpelNodeImpl eatPrimaryExpression()
Annotations
@Nullable
eatProductExpressionback to summary
private SpelNodeImpl eatProductExpression()
Annotations
@Nullable
eatRelationalExpressionback to summary
private SpelNodeImpl eatRelationalExpression()
Annotations
@Nullable
eatStartNodeback to summary
private SpelNodeImpl eatStartNode()
Annotations
@Nullable
eatSumExpressionback to summary
private SpelNodeImpl eatSumExpression()
Annotations
@Nullable
eatTokenback to summary
private Token eatToken(TokenKind expectedKind)
eatUnaryExpressionback to summary
private SpelNodeImpl eatUnaryExpression()
Annotations
@Nullable
internalExceptionback to summary
private InternalParseException internalException(int startPos, SpelMessage message, Object... inserts)
isValidQualifiedIdback to summary
private boolean isValidQualifiedId(Token node)
maybeEatBeanReferenceback to summary
private boolean maybeEatBeanReference()
maybeEatConstructorReferenceback to summary
private boolean maybeEatConstructorReference()
maybeEatFunctionOrVarback to summary
private boolean maybeEatFunctionOrVar()
maybeEatIndexerback to summary
private boolean maybeEatIndexer()
maybeEatInlineListOrMapback to summary
private boolean maybeEatInlineListOrMap()
maybeEatLiteralback to summary
private boolean maybeEatLiteral()
maybeEatMethodArgsback to summary
private SpelNodeImpl[] maybeEatMethodArgs()
Annotations
@Nullable
maybeEatMethodOrPropertyback to summary
private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation)
maybeEatNullReferenceback to summary
private boolean maybeEatNullReference()
maybeEatParenExpressionback to summary
private boolean maybeEatParenExpression()
maybeEatProjectionback to summary
private boolean maybeEatProjection(boolean nullSafeNavigation)
maybeEatRelationalOperatorback to summary
private Token maybeEatRelationalOperator()
Annotations
@Nullable
maybeEatSelectionback to summary
private boolean maybeEatSelection(boolean nullSafeNavigation)
maybeEatTypeReferenceback to summary
private boolean maybeEatTypeReference()
nextTokenback to summary
private Token nextToken()
Annotations
@Nullable
peekIdentifierTokenback to summary
private boolean peekIdentifierToken(String identifierString)
peekSelectTokenback to summary
private boolean peekSelectToken()
peekTokenback to summary
private boolean peekToken(TokenKind desiredTokenKind)
peekTokenback to summary
private boolean peekToken(TokenKind desiredTokenKind, boolean consumeIfMatched)
peekTokenback to summary
private boolean peekToken(TokenKind possible1, TokenKind possible2)
peekTokenback to summary
private boolean peekToken(TokenKind possible1, TokenKind possible2, TokenKind possible3)
peekTokenback to summary
private Token peekToken()
Annotations
@Nullable
popback to summary
private SpelNodeImpl pop()
positionOfback to summary
private int positionOf(Token t)
pushback to summary
private void push(SpelNodeImpl newNode)
takeTokenback to summary
private Token takeToken()
toStringback to summary
public String toString(Token t)