@@ -222,29 +222,38 @@ Kotlin::
222
222
[[expressions-evaluation-context]]
223
223
== Understanding `EvaluationContext`
224
224
225
- The `EvaluationContext` interface is used when evaluating an expression to resolve
226
- properties, methods, or fields and to help perform type conversion. Spring provides two
225
+ The `EvaluationContext` API is used when evaluating an expression to resolve properties,
226
+ methods, or fields and to help perform type conversion. Spring provides two
227
227
implementations.
228
228
229
- * `SimpleEvaluationContext`: Exposes a subset of essential SpEL language features and
230
- configuration options, for categories of expressions that do not require the full extent
231
- of the SpEL language syntax and should be meaningfully restricted. Examples include but
232
- are not limited to data binding expressions and property-based filters.
229
+ `SimpleEvaluationContext`::
230
+ Exposes a subset of essential SpEL language features and configuration options, for
231
+ categories of expressions that do not require the full extent of the SpEL language
232
+ syntax and should be meaningfully restricted. Examples include but are not limited to
233
+ data binding expressions and property-based filters.
233
234
234
- * `StandardEvaluationContext`: Exposes the full set of SpEL language features and
235
- configuration options. You can use it to specify a default root object and to configure
236
- every available evaluation-related strategy.
235
+ `StandardEvaluationContext`::
236
+ Exposes the full set of SpEL language features and configuration options. You can use
237
+ it to specify a default root object and to configure every available evaluation-related
238
+ strategy.
237
239
238
- `SimpleEvaluationContext` is designed to support only a subset of the SpEL language syntax.
239
- It excludes Java type references, constructors, and bean references. It also requires
240
- you to explicitly choose the level of support for properties and methods in expressions.
241
- By default, the `create()` static factory method enables only read access to properties.
242
- You can also obtain a builder to configure the exact level of support needed, targeting
243
- one or some combination of the following.
240
+ `SimpleEvaluationContext` is designed to support only a subset of the SpEL language
241
+ syntax. For example, it excludes Java type references, constructors, and bean references.
242
+ It also requires you to explicitly choose the level of support for properties and methods
243
+ in expressions. When creating a `SimpleEvaluationContext` you need to choose the level of
244
+ support that you need for data binding in SpEL expressions:
244
245
245
- * Custom `PropertyAccessor` only (no reflection)
246
- * Data binding properties for read-only access
247
- * Data binding properties for read and write
246
+ * Data binding for read-only access
247
+ * Data binding for read and write access
248
+ * A custom `PropertyAccessor` (typically not reflection-based), potentially combined with
249
+ a `DataBindingPropertyAccessor`
250
+
251
+ Conveniently, `SimpleEvaluationContext.forReadOnlyDataBinding()` enables read-only access
252
+ to properties via `DataBindingPropertyAccessor`. Similarly,
253
+ `SimpleEvaluationContext.forReadWriteDataBinding()` enables read and write access to
254
+ properties. Alternatively, configure custom accessors via
255
+ `SimpleEvaluationContext.forPropertyAccessors(...)`, potentially disable assignment, and
256
+ optionally activate method resolution and/or a type converter through the builder.
248
257
249
258
250
259
[[expressions-type-conversion]]
@@ -314,17 +323,17 @@ Kotlin::
314
323
It is possible to configure the SpEL expression parser by using a parser configuration
315
324
object (`org.springframework.expression.spel.SpelParserConfiguration`). The configuration
316
325
object controls the behavior of some of the expression components. For example, if you
317
- index into an array or collection and the element at the specified index is `null`, SpEL
318
- can automatically create the element. This is useful when using expressions made up of a
319
- chain of property references. If you index into an array or list and specify an index
320
- that is beyond the end of the current size of the array or list , SpEL can automatically
321
- grow the array or list to accommodate that index. In order to add an element at the
326
+ index into a collection and the element at the specified index is `null`, SpEL can
327
+ automatically create the element. This is useful when using expressions made up of a
328
+ chain of property references. Similarly, if you index into a collection and specify an
329
+ index that is greater than the current size of the collection , SpEL can automatically
330
+ grow the collection to accommodate that index. In order to add an element at the
322
331
specified index, SpEL will try to create the element using the element type's default
323
332
constructor before setting the specified value. If the element type does not have a
324
- default constructor, `null` will be added to the array or list . If there is no built-in
325
- or custom converter that knows how to set the value, `null` will remain in the array or
326
- list at the specified index. The following example demonstrates how to automatically grow
327
- the list .
333
+ default constructor, `null` will be added to the collection . If there is no built-in
334
+ converter or custom converter that knows how to set the value, `null` will remain in the
335
+ collection at the specified index. The following example demonstrates how to
336
+ automatically grow a `List` .
328
337
329
338
[tabs]
330
339
======
0 commit comments