Search in sources :

Example 1 with QualifiedIdentifier

use of org.springframework.expression.spel.ast.QualifiedIdentifier in project spring-framework by spring-projects.

the class InternalSpelExpressionParser method 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)
	 */
private SpelNodeImpl eatPossiblyQualifiedId() {
    LinkedList<SpelNodeImpl> qualifiedIdPieces = new LinkedList<>();
    Token node = peekToken();
    while (isValidQualifiedId(node)) {
        nextToken();
        if (node.kind != TokenKind.DOT) {
            qualifiedIdPieces.add(new Identifier(node.stringValue(), toPos(node)));
        }
        node = peekToken();
    }
    if (qualifiedIdPieces.isEmpty()) {
        if (node == null) {
            raiseInternalException(this.expressionString.length(), SpelMessage.OOD);
        }
        raiseInternalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN, "qualified ID", node.getKind().toString().toLowerCase());
    }
    int pos = toPos(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition());
    return new QualifiedIdentifier(pos, qualifiedIdPieces.toArray(new SpelNodeImpl[qualifiedIdPieces.size()]));
}
Also used : SpelNodeImpl(org.springframework.expression.spel.ast.SpelNodeImpl) Identifier(org.springframework.expression.spel.ast.Identifier) QualifiedIdentifier(org.springframework.expression.spel.ast.QualifiedIdentifier) QualifiedIdentifier(org.springframework.expression.spel.ast.QualifiedIdentifier) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 Identifier (org.springframework.expression.spel.ast.Identifier)1 QualifiedIdentifier (org.springframework.expression.spel.ast.QualifiedIdentifier)1 SpelNodeImpl (org.springframework.expression.spel.ast.SpelNodeImpl)1