@ -78,7 +78,7 @@ The following code introduces the SpEL API to evaluate the literal string expres
@@ -78,7 +78,7 @@ The following code introduces the SpEL API to evaluate the literal string expres
[subs="verbatim,quotes"]
----
ExpressionParser parser = new SpelExpressionParser();
@ -91,25 +91,25 @@ The interface `ExpressionParser` is responsible for parsing an expression string
@@ -91,25 +91,25 @@ The interface `ExpressionParser` is responsible for parsing an expression string
this example the expression string is a string literal denoted by the surrounding single
quotes. The interface `Expression` is responsible for evaluating the previously defined
expression string. There are two exceptions that can be thrown, `ParseException` and
`EvaluationException` when calling '`parser.parseExpression`' and '`exp.getValue`'
`EvaluationException` when calling `parser.parseExpression` and `exp.getValue`
respectively.
SpEL supports a wide range of features, such as calling methods, accessing properties,
and calling constructors.
As an example of method invocation, we call the 'concat' method on the string literal.
As an example of method invocation, we call the `concat` method on the string literal.
[source,java,indent=0]
[subs="verbatim,quotes"]
----
ExpressionParser parser = new SpelExpressionParser();
@ -143,7 +143,7 @@ The String's constructor can be called instead of using a string literal.
@@ -143,7 +143,7 @@ The String's constructor can be called instead of using a string literal.
[subs="verbatim,quotes"]
----
ExpressionParser parser = new SpelExpressionParser();
@ -175,7 +175,7 @@ example we retrieve the `name` property from an instance of the Inventor class.
@@ -175,7 +175,7 @@ example we retrieve the `name` property from an instance of the Inventor class.
String name = (String) exp.getValue(context);
----
In the last line, the value of the string variable 'name' will be set to "Nikola Tesla".
In the last line, the value of the string variable `name` will be set to "Nikola Tesla".
The class StandardEvaluationContext is where you can specify which object the "name"
property will be evaluated against. This is the mechanism to use if the root object is
unlikely to change, it can simply be set once in the evaluation context. If the root
@ -226,7 +226,7 @@ Inventor object in the previous example.
@@ -226,7 +226,7 @@ Inventor object in the previous example.
boolean result = exp.getValue(context, Boolean.class); // evaluates to true
----
@ -237,8 +237,8 @@ Inventor object in the previous example.
@@ -237,8 +237,8 @@ Inventor object in the previous example.
The interface `EvaluationContext` is used when evaluating an expression to resolve
properties, methods, fields, and to help perform type conversion. The out-of-the-box
implementation, `StandardEvaluationContext`, uses reflection to manipulate the object,
caching `java.lang.reflect`'s `Method`, `Field`, and `Constructor` instances for
increased performance.
caching `java.lang.reflect.Method`, `java.lang.reflect.Field`, and
`java.lang.reflect.Constructor` instances for increased performance.
The `StandardEvaluationContext` is where you may specify the root object to evaluate
against via the method `setRootObject()` or passing the root object into the
@ -291,7 +291,7 @@ being placed in it. A simple example:
@@ -291,7 +291,7 @@ being placed in it. A simple example:
=== Parser configuration
It is possible to configure the SpEL expression parser using a parser configuration object
(`org.springframework.expression.spel.SpelParserConfiguration`). The configuration
object controls the behaviour of some of the expression components. For example, if
object controls the behavior of some of the expression components. For example, if
indexing into an array or collection and the element at the specified index is `null`
it is possible to automatically create the element. This is useful when using expressions made up of a
chain of property references. If indexing into an array or list
@ -412,7 +412,7 @@ The second way to configure the compiler is for use when SpEL is embedded inside
@@ -412,7 +412,7 @@ The second way to configure the compiler is for use when SpEL is embedded inside
component and it may not be possible to configure via a configuration object.
In these cases it is possible to use a system property. The property
`spring.expression.compiler.mode` can be set to one of the `SpelCompilerMode`
enum values (`off`, `immediate` or `mixed`).
enum values (`off`, `immediate`, or `mixed`).
[[expressions-compiler-limitations]]
==== Compiler limitations
@ -564,7 +564,7 @@ Autowired methods and constructors can also use the `@Value` annotation.
@@ -564,7 +564,7 @@ Autowired methods and constructors can also use the `@Value` annotation.
@Autowired
public MovieRecommender(CustomerPreferenceDao customerPreferenceDao,
@ -691,7 +691,7 @@ Lists can be expressed directly in an expression using `{}` notation.
@@ -691,7 +691,7 @@ Lists can be expressed directly in an expression using `{}` notation.
// evaluates to a Java list containing the four numbers
List numbers = (List) parser.parseExpression("{1,2,3,4}").getValue(context);
List listOfLists = (List) parser.parseExpression("{{''a'',''b''},{''x'',''y''}}").getValue(context);
List listOfLists = (List) parser.parseExpression("{{'a','b'},{'x','y'}}").getValue(context);
----
`{}` by itself means an empty list. For performance reasons, if the list is itself
@ -706,9 +706,9 @@ Maps can also be expressed directly in an expression using `{key:value}` notatio
@@ -706,9 +706,9 @@ Maps can also be expressed directly in an expression using `{key:value}` notatio
[subs="verbatim,quotes"]
----
// evaluates to a Java map containing the two entries
@ -774,7 +774,7 @@ and greater than or equal are supported using standard operator notation.
@@ -774,7 +774,7 @@ and greater than or equal are supported using standard operator notation.
int four = parser.parseExpression("1 - -3").getValue(Integer.class); // 4
@ -898,7 +898,7 @@ done within a call to `setValue` but can also be done inside a call to `getValue
@@ -898,7 +898,7 @@ done within a call to `setValue` but can also be done inside a call to `getValue
@ -1113,7 +1113,7 @@ Instead you can use the Elvis operator, named for the resemblance to Elvis' hair
@@ -1113,7 +1113,7 @@ Instead you can use the Elvis operator, named for the resemblance to Elvis' hair
----
ExpressionParser parser = new SpelExpressionParser();
String name = parser.parseExpression("null?:''Unknown''").getValue(String.class);
String name = parser.parseExpression("null?:'Unknown'").getValue(String.class);
System.out.println(name); // 'Unknown'
----
@ -1128,13 +1128,13 @@ Here is a more complex example.
@@ -1128,13 +1128,13 @@ Here is a more complex example.
Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
StandardEvaluationContext context = new StandardEvaluationContext(tesla);
String name = parser.parseExpression("Name?:''Elvis Presley''").getValue(context, String.class);
String name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, String.class);
System.out.println(name); // Nikola Tesla
tesla.setName(null);
name = parser.parseExpression("Name?:''Elvis Presley''").getValue(context, String.class);
name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, String.class);
System.out.println(name); // Elvis Presley
----
@ -1177,7 +1177,7 @@ The Elvis operator can be used to apply default values in expressions, e.g. in a
@@ -1177,7 +1177,7 @@ The Elvis operator can be used to apply default values in expressions, e.g. in a
This will inject a system property `pop3.port` if it is defined or 25 if not.
@ -1198,7 +1198,7 @@ selection would allow us to easily get a list of Serbian inventors:
@@ -1198,7 +1198,7 @@ selection would allow us to easily get a list of Serbian inventors:
[subs="verbatim,quotes"]
----
List<Inventor> list = (List<Inventor>) parser.parseExpression(