Improve Javadoc for core SpEL APIs

This commit is contained in:
Sam Brannen 2024-10-22 13:04:29 +02:00
parent c98f314665
commit fb0a108254
3 changed files with 26 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,8 @@ package org.springframework.expression;
/** /**
* Parses expression strings into compiled expressions that can be evaluated. * Parses expression strings into compiled expressions that can be evaluated.
* Supports parsing templates as well as standard expression strings. *
* <p>Supports parsing template expressions as well as standard expression strings.
* *
* @author Keith Donald * @author Keith Donald
* @author Andy Clement * @author Andy Clement
@ -27,29 +28,31 @@ package org.springframework.expression;
public interface ExpressionParser { public interface ExpressionParser {
/** /**
* Parse the expression string and return an Expression object you can use for repeated evaluation. * Parse the expression string and return an {@link Expression} object that
* <p>Some examples: * can be used for repeated evaluation.
* <p>Examples:
* <pre class="code"> * <pre class="code">
* 3 + 4 * 3 + 4
* name.firstName * name.firstName
* </pre> * </pre>
* @param expressionString the raw expression string to parse * @param expressionString the raw expression string to parse
* @return an evaluator for the parsed expression * @return an {@code Expression} for the parsed expression
* @throws ParseException an exception occurred during parsing * @throws ParseException if an exception occurred during parsing
*/ */
Expression parseExpression(String expressionString) throws ParseException; Expression parseExpression(String expressionString) throws ParseException;
/** /**
* Parse the expression string and return an Expression object you can use for repeated evaluation. * Parse the expression string and return an {@link Expression} object that
* <p>Some examples: * can be used for repeated evaluation.
* <p>Examples:
* <pre class="code"> * <pre class="code">
* 3 + 4 * 3 + 4
* name.firstName * name.firstName
* </pre> * </pre>
* @param expressionString the raw expression string to parse * @param expressionString the raw expression string to parse
* @param context a context for influencing this expression parsing routine (optional) * @param context a context for influencing the expression parsing routine
* @return an evaluator for the parsed expression * @return an {@code Expression} for the parsed expression
* @throws ParseException an exception occurred during parsing * @throws ParseException if an exception occurred during parsing
*/ */
Expression parseExpression(String expressionString, ParserContext context) throws ParseException; Expression parseExpression(String expressionString, ParserContext context) throws ParseException;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ public interface ParserContext {
String getExpressionPrefix(); String getExpressionPrefix();
/** /**
* For template expressions, return the prefix that identifies the end of an * For template expressions, returns the prefix that identifies the end of an
* expression block within a string. For example: "}" * expression block within a string. For example: "}"
* @return the suffix that identifies the end of an expression * @return the suffix that identifies the end of an expression
*/ */
@ -55,8 +55,9 @@ public interface ParserContext {
/** /**
* The default ParserContext implementation that enables template expression * The default {@link ParserContext} implementation that enables template
* parsing mode. The expression prefix is "#{" and the expression suffix is "}". * expression parsing.
* <p>The expression prefix is "#{", and the expression suffix is "}".
* @see #isTemplate() * @see #isTemplate()
*/ */
ParserContext TEMPLATE_EXPRESSION = new ParserContext() { ParserContext TEMPLATE_EXPRESSION = new ParserContext() {

View File

@ -29,8 +29,11 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* An expression parser that understands templates. It can be subclassed by expression * Abstract base class for {@linkplain ExpressionParser expression parsers} that
* parsers that do not offer first class support for templating. * support templates.
*
* <p>Can be subclassed by expression parsers that offer first class support for
* templating.
* *
* @author Keith Donald * @author Keith Donald
* @author Juergen Hoeller * @author Juergen Hoeller
@ -88,7 +91,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
* single quote '. * single quote '.
* @param expressionString the expression string * @param expressionString the expression string
* @return the parsed expressions * @return the parsed expressions
* @throws ParseException when the expressions cannot be parsed * @throws ParseException if the expressions cannot be parsed
*/ */
private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException { private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException {
List<Expression> expressions = new ArrayList<>(); List<Expression> expressions = new ArrayList<>();
@ -229,7 +232,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
* @param expressionString the raw expression string to parse * @param expressionString the raw expression string to parse
* @param context a context for influencing this expression parsing routine (optional) * @param context a context for influencing this expression parsing routine (optional)
* @return an evaluator for the parsed expression * @return an evaluator for the parsed expression
* @throws ParseException an exception occurred during parsing * @throws ParseException if an exception occurred during parsing
*/ */
protected abstract Expression doParseExpression(String expressionString, @Nullable ParserContext context) protected abstract Expression doParseExpression(String expressionString, @Nullable ParserContext context)
throws ParseException; throws ParseException;