Skip to content

Commit 01e50fb

Browse files
committed
Polish SpEL chapter
1 parent 6c3a0a9 commit 01e50fb

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

src/docs/asciidoc/core/core-expressions.adoc

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ kinds of expression cannot be compiled at the moment:
517517
* Expressions using custom resolvers or accessors
518518
* Expressions using selection or projection
519519

520-
More types of expression will be compilable in the future.
520+
More types of expressions will be compilable in the future.
521521

522522

523523

@@ -589,7 +589,7 @@ You can also refer to other bean properties by name, as the following example sh
589589
To specify a default value, you can place the `@Value` annotation on fields, methods,
590590
and method or constructor parameters.
591591

592-
The following example sets the default value of a field variable:
592+
The following example sets the default value of a field:
593593

594594
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
595595
.Java
@@ -788,18 +788,18 @@ using a literal on one side of a logical comparison operator.
788788
----
789789

790790
Numbers support the use of the negative sign, exponential notation, and decimal points.
791-
By default, real numbers are parsed by using Double.parseDouble().
791+
By default, real numbers are parsed by using `Double.parseDouble()`.
792792

793793

794794

795795
[[expressions-properties-arrays]]
796796
=== Properties, Arrays, Lists, Maps, and Indexers
797797

798798
Navigating with property references is easy. To do so, use a period to indicate a nested
799-
property value. The instances of the `Inventor` class, `pupin` and `tesla`, were populated with
800-
data listed in the <<expressions-example-classes, Classes used in the examples>> section.
801-
To navigate "`down`" and get Tesla's year of birth and Pupin's city of birth, we use the following
802-
expressions:
799+
property value. The instances of the `Inventor` class, `pupin` and `tesla`, were
800+
populated with data listed in the <<expressions-example-classes, Classes used in the
801+
examples>> section. To navigate "down" the object graph and get Tesla's year of birth and
802+
Pupin's city of birth, we use the following expressions:
803803

804804
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
805805
.Java
@@ -939,7 +939,7 @@ You can directly express lists in an expression by using `{}` notation.
939939
----
940940

941941
`{}` by itself means an empty list. For performance reasons, if the list is itself
942-
entirely composed of fixed literals, a constant list is created to represent the
942+
entirely composed of fixed literals, a constant list is created to represent the
943943
expression (rather than building a new list on each evaluation).
944944

945945

@@ -967,10 +967,11 @@ following example shows how to do so:
967967
val mapOfMaps = parser.parseExpression("{name:{first:'Nikola',last:'Tesla'},dob:{day:10,month:'July',year:1856}}").getValue(context) as Map<*, *>
968968
----
969969

970-
`{:}` by itself means an empty map. For performance reasons, if the map is itself composed
971-
of fixed literals or other nested constant structures (lists or maps), a constant map is created
972-
to represent the expression (rather than building a new map on each evaluation). Quoting of the map keys
973-
is optional. The examples above do not use quoted keys.
970+
`{:}` by itself means an empty map. For performance reasons, if the map is itself
971+
composed of fixed literals or other nested constant structures (lists or maps), a
972+
constant map is created to represent the expression (rather than building a new map on
973+
each evaluation). Quoting of the map keys is optional (unless the key contains a period
974+
(`.`)). The examples above do not use quoted keys.
974975

975976

976977

@@ -1003,8 +1004,7 @@ to have the array populated at construction time. The following example shows ho
10031004
val numbers3 = parser.parseExpression("new int[4][5]").getValue(context) as Array<IntArray>
10041005
----
10051006

1006-
You cannot currently supply an initializer when you construct
1007-
multi-dimensional array.
1007+
You cannot currently supply an initializer when you construct a multi-dimensional array.
10081008

10091009

10101010

@@ -1105,7 +1105,7 @@ expression-based `matches` operator. The following listing shows examples of bot
11051105
boolean trueValue = parser.parseExpression(
11061106
"'5.00' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
11071107
1108-
//evaluates to false
1108+
// evaluates to false
11091109
boolean falseValue = parser.parseExpression(
11101110
"'5.0067' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
11111111
----
@@ -1120,14 +1120,14 @@ expression-based `matches` operator. The following listing shows examples of bot
11201120
val trueValue = parser.parseExpression(
11211121
"'5.00' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean::class.java)
11221122
1123-
//evaluates to false
1123+
// evaluates to false
11241124
val falseValue = parser.parseExpression(
11251125
"'5.0067' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean::class.java)
11261126
----
11271127

1128-
CAUTION: Be careful with primitive types, as they are immediately boxed up to the wrapper type,
1129-
so `1 instanceof T(int)` evaluates to `false` while `1 instanceof T(Integer)`
1130-
evaluates to `true`, as expected.
1128+
CAUTION: Be careful with primitive types, as they are immediately boxed up to their
1129+
wrapper types. For example, `1 instanceof T(int)` evaluates to `false`, while
1130+
`1 instanceof T(Integer)` evaluates to `true`, as expected.
11311131

11321132
Each symbolic operator can also be specified as a purely alphabetic equivalent. This
11331133
avoids problems where the symbols used have special meaning for the document type in
@@ -1155,7 +1155,7 @@ SpEL supports the following logical operators:
11551155
* `or` (`||`)
11561156
* `not` (`!`)
11571157

1158-
The following example shows how to use the logical operators
1158+
The following example shows how to use the logical operators:
11591159

11601160
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
11611161
.Java
@@ -1222,10 +1222,11 @@ The following example shows how to use the logical operators
12221222
[[expressions-operators-mathematical]]
12231223
==== Mathematical Operators
12241224

1225-
You can use the addition operator on both numbers and strings. You can use the subtraction, multiplication,
1226-
and division operators only on numbers. You can also use
1227-
the modulus (%) and exponential power (^) operators. Standard operator precedence is enforced. The
1228-
following example shows the mathematical operators in use:
1225+
You can use the addition operator (`+`) on both numbers and strings. You can use the
1226+
subtraction (`-`), multiplication (`*`), and division (`/`) operators only on numbers.
1227+
You can also use the modulus (`%`) and exponential power (`^`) operators on numbers.
1228+
Standard operator precedence is enforced. The following example shows the mathematical
1229+
operators in use:
12291230

12301231
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
12311232
.Java
@@ -1296,9 +1297,9 @@ following example shows the mathematical operators in use:
12961297
[[expressions-assignment]]
12971298
==== The Assignment Operator
12981299

1299-
To setting a property, use the assignment operator (`=`). This is typically
1300-
done within a call to `setValue` but can also be done inside a call to `getValue`. The
1301-
following listing shows both ways to use the assignment operator:
1300+
To set a property, use the assignment operator (`=`). This is typically done within a
1301+
call to `setValue` but can also be done inside a call to `getValue`. The following
1302+
listing shows both ways to use the assignment operator:
13021303

13031304
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
13041305
.Java
@@ -1333,9 +1334,9 @@ You can use the special `T` operator to specify an instance of `java.lang.Class`
13331334
type). Static methods are invoked by using this operator as well. The
13341335
`StandardEvaluationContext` uses a `TypeLocator` to find types, and the
13351336
`StandardTypeLocator` (which can be replaced) is built with an understanding of the
1336-
`java.lang` package. This means that `T()` references to types within `java.lang` do not need to be
1337-
fully qualified, but all other type references must be. The following example shows how
1338-
to use the `T` operator:
1337+
`java.lang` package. This means that `T()` references to types within the `java.lang`
1338+
package do not need to be fully qualified, but all other type references must be. The
1339+
following example shows how to use the `T` operator:
13391340

13401341
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
13411342
.Java
@@ -1365,9 +1366,10 @@ to use the `T` operator:
13651366
[[expressions-constructors]]
13661367
=== Constructors
13671368

1368-
You can invoke constructors by using the `new` operator. You should use the fully qualified class name
1369-
for all but the types located in the core package `java.lang`. The following
1370-
example shows how to use the `new` operator to invoke constructors:
1369+
You can invoke constructors by using the `new` operator. You should use the fully
1370+
qualified class name for all types except those located in the `java.lang` package
1371+
(`Integer`, `Float`, `String`, and so on). The following example shows how to use the
1372+
`new` operator to invoke constructors:
13711373

13721374
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
13731375
.Java
@@ -1376,7 +1378,7 @@ example shows how to use the `new` operator to invoke constructors:
13761378
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
13771379
.getValue(Inventor.class);
13781380
1379-
//create new inventor instance within add method of List
1381+
// create new Inventor instance within the add() method of List
13801382
p.parseExpression(
13811383
"Members.add(new org.spring.samples.spel.inventor.Inventor(
13821384
'Albert Einstein', 'German'))").getValue(societyContext);
@@ -1388,7 +1390,7 @@ example shows how to use the `new` operator to invoke constructors:
13881390
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
13891391
.getValue(Inventor::class.java)
13901392
1391-
//create new inventor instance within add method of List
1393+
// create new Inventor instance within the add() method of List
13921394
p.parseExpression(
13931395
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
13941396
.getValue(societyContext)

0 commit comments

Comments
 (0)