org.springframework.expression.spel.ast.ConstructorReference Java Examples

The following examples show how to use org.springframework.expression.spel.ast.ConstructorReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InternalSpelExpressionParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private boolean maybeEatConstructorReference() {
	if (peekIdentifierToken("new")) {
		Token newToken = takeToken();
		// It looks like a constructor reference but is NEW being used as a map key?
		if (peekToken(TokenKind.RSQUARE)) {
			// looks like 'NEW]' (so NEW used as map key)
			push(new PropertyOrFieldReference(false, newToken.stringValue(), newToken.startPos, newToken.endPos));
			return true;
		}
		SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
		List<SpelNodeImpl> nodes = new ArrayList<>();
		nodes.add(possiblyQualifiedConstructorName);
		if (peekToken(TokenKind.LSQUARE)) {
			// array initializer
			List<SpelNodeImpl> dimensions = new ArrayList<>();
			while (peekToken(TokenKind.LSQUARE, true)) {
				if (!peekToken(TokenKind.RSQUARE)) {
					dimensions.add(eatExpression());
				}
				else {
					dimensions.add(null);
				}
				eatToken(TokenKind.RSQUARE);
			}
			if (maybeEatInlineListOrMap()) {
				nodes.add(pop());
			}
			push(new ConstructorReference(newToken.startPos, newToken.endPos,
					dimensions.toArray(new SpelNodeImpl[0]), nodes.toArray(new SpelNodeImpl[0])));
		}
		else {
			// regular constructor invocation
			eatConstructorArgs(nodes);
			// TODO correct end position?
			push(new ConstructorReference(newToken.startPos, newToken.endPos, nodes.toArray(new SpelNodeImpl[0])));
		}
		return true;
	}
	return false;
}
 
Example #2
Source File: InternalSpelExpressionParser.java    From java-technology-stack with MIT License 5 votes vote down vote up
private boolean maybeEatConstructorReference() {
	if (peekIdentifierToken("new")) {
		Token newToken = takeToken();
		// It looks like a constructor reference but is NEW being used as a map key?
		if (peekToken(TokenKind.RSQUARE)) {
			// looks like 'NEW]' (so NEW used as map key)
			push(new PropertyOrFieldReference(false, newToken.stringValue(), toPos(newToken)));
			return true;
		}
		SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
		List<SpelNodeImpl> nodes = new ArrayList<>();
		nodes.add(possiblyQualifiedConstructorName);
		if (peekToken(TokenKind.LSQUARE)) {
			// array initializer
			List<SpelNodeImpl> dimensions = new ArrayList<>();
			while (peekToken(TokenKind.LSQUARE, true)) {
				if (!peekToken(TokenKind.RSQUARE)) {
					dimensions.add(eatExpression());
				}
				else {
					dimensions.add(null);
				}
				eatToken(TokenKind.RSQUARE);
			}
			if (maybeEatInlineListOrMap()) {
				nodes.add(pop());
			}
			push(new ConstructorReference(toPos(newToken),
					dimensions.toArray(new SpelNodeImpl[0]), nodes.toArray(new SpelNodeImpl[0])));
		}
		else {
			// regular constructor invocation
			eatConstructorArgs(nodes);
			// TODO correct end position?
			push(new ConstructorReference(toPos(newToken), nodes.toArray(new SpelNodeImpl[0])));
		}
		return true;
	}
	return false;
}
 
Example #3
Source File: InternalSpelExpressionParser.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private boolean maybeEatConstructorReference() {
	if (peekIdentifierToken("new")) {
		Token newToken = nextToken();
		// It looks like a constructor reference but is NEW being used as a map key?
		if (peekToken(TokenKind.RSQUARE)) {
			// looks like 'NEW]' (so NEW used as map key)
			push(new PropertyOrFieldReference(false, newToken.data, toPos(newToken)));
			return true;
		}
		SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
		List<SpelNodeImpl> nodes = new ArrayList<SpelNodeImpl>();
		nodes.add(possiblyQualifiedConstructorName);
		if (peekToken(TokenKind.LSQUARE)) {
			// array initializer
			List<SpelNodeImpl> dimensions = new ArrayList<SpelNodeImpl>();
			while (peekToken(TokenKind.LSQUARE, true)) {
				if (!peekToken(TokenKind.RSQUARE)) {
					dimensions.add(eatExpression());
				}
				else {
					dimensions.add(null);
				}
				eatToken(TokenKind.RSQUARE);
			}
			if (maybeEatInlineListOrMap()) {
				nodes.add(pop());
			}
			push(new ConstructorReference(toPos(newToken),
					dimensions.toArray(new SpelNodeImpl[dimensions.size()]),
					nodes.toArray(new SpelNodeImpl[nodes.size()])));
		}
		else {
			// regular constructor invocation
			eatConstructorArgs(nodes);
			// TODO correct end position?
			push(new ConstructorReference(toPos(newToken),
					nodes.toArray(new SpelNodeImpl[nodes.size()])));
		}
		return true;
	}
	return false;
}
 
Example #4
Source File: InternalSpelExpressionParser.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private boolean maybeEatConstructorReference() {
	if (peekIdentifierToken("new")) {
		Token newToken = nextToken();
		// It looks like a constructor reference but is NEW being used as a map key?
		if (peekToken(TokenKind.RSQUARE)) {
			// looks like 'NEW]' (so NEW used as map key)
			push(new PropertyOrFieldReference(false,newToken.data,toPos(newToken)));
			return true;
		}
		SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
		List<SpelNodeImpl> nodes = new ArrayList<SpelNodeImpl>();
		nodes.add(possiblyQualifiedConstructorName);
		if (peekToken(TokenKind.LSQUARE)) {
			// array initializer
			List<SpelNodeImpl> dimensions = new ArrayList<SpelNodeImpl>();
			while (peekToken(TokenKind.LSQUARE,true)) {
				if (!peekToken(TokenKind.RSQUARE)) {
					dimensions.add(eatExpression());
				}
				else {
					dimensions.add(null);
				}
				eatToken(TokenKind.RSQUARE);
			}
			if (maybeEatInlineListOrMap()) {
				nodes.add(pop());
			}
			push(new ConstructorReference(toPos(newToken), dimensions.toArray(new SpelNodeImpl[dimensions.size()]),
					nodes.toArray(new SpelNodeImpl[nodes.size()])));
		}
		else {
			// regular constructor invocation
			eatConstructorArgs(nodes);
			// TODO correct end position?
			push(new ConstructorReference(toPos(newToken),
					nodes.toArray(new SpelNodeImpl[nodes.size()])));
		}
		return true;
	}
	return false;
}