Skip to content

Commit 9c11887

Browse files
quaffsbrannen
authored andcommitted
Use lowercase property names in SpEL examples
Closes gh-25538
1 parent 4503260 commit 9c11887

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

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

+31-31
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,12 @@ shows:
835835
// Members List
836836
837837
// evaluates to "Nikola Tesla"
838-
String name = parser.parseExpression("Members[0].Name").getValue(
838+
String name = parser.parseExpression("members[0].name").getValue(
839839
context, ieee, String.class);
840840
841841
// List and Array navigation
842842
// evaluates to "Wireless communication"
843-
String invention = parser.parseExpression("Members[0].Inventions[6]").getValue(
843+
String invention = parser.parseExpression("members[0].inventions[6]").getValue(
844844
context, ieee, String.class);
845845
----
846846
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -858,49 +858,49 @@ shows:
858858
// Members List
859859
860860
// evaluates to "Nikola Tesla"
861-
val name = parser.parseExpression("Members[0].Name").getValue(
861+
val name = parser.parseExpression("members[0].name").getValue(
862862
context, ieee, String::class.java)
863863
864864
// List and Array navigation
865865
// evaluates to "Wireless communication"
866-
val invention = parser.parseExpression("Members[0].Inventions[6]").getValue(
866+
val invention = parser.parseExpression("members[0].inventions[6]").getValue(
867867
context, ieee, String::class.java)
868868
----
869869

870870
The contents of maps are obtained by specifying the literal key value within the
871-
brackets. In the following example, because keys for the `Officers` map are strings, we can specify
871+
brackets. In the following example, because keys for the `officers` map are strings, we can specify
872872
string literals:
873873

874874
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
875875
.Java
876876
----
877877
// Officer's Dictionary
878878
879-
Inventor pupin = parser.parseExpression("Officers['president']").getValue(
879+
Inventor pupin = parser.parseExpression("officers['president']").getValue(
880880
societyContext, Inventor.class);
881881
882882
// evaluates to "Idvor"
883-
String city = parser.parseExpression("Officers['president'].PlaceOfBirth.City").getValue(
883+
String city = parser.parseExpression("officers['president'].placeOfBirth.city").getValue(
884884
societyContext, String.class);
885885
886886
// setting values
887-
parser.parseExpression("Officers['advisors'][0].PlaceOfBirth.Country").setValue(
887+
parser.parseExpression("officers['advisors'][0].placeOfBirth.country").setValue(
888888
societyContext, "Croatia");
889889
----
890890
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
891891
.Kotlin
892892
----
893893
// Officer's Dictionary
894894
895-
val pupin = parser.parseExpression("Officers['president']").getValue(
895+
val pupin = parser.parseExpression("officers['president']").getValue(
896896
societyContext, Inventor::class.java)
897897
898898
// evaluates to "Idvor"
899-
val city = parser.parseExpression("Officers['president'].PlaceOfBirth.City").getValue(
899+
val city = parser.parseExpression("officers['president'].placeOfBirth.city").getValue(
900900
societyContext, String::class.java)
901901
902902
// setting values
903-
parser.parseExpression("Officers['advisors'][0].PlaceOfBirth.Country").setValue(
903+
parser.parseExpression("officers['advisors'][0].placeOfBirth.country").setValue(
904904
societyContext, "Croatia")
905905
----
906906

@@ -1296,23 +1296,23 @@ following listing shows both ways to use the assignment operator:
12961296
Inventor inventor = new Inventor();
12971297
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build();
12981298
1299-
parser.parseExpression("Name").setValue(context, inventor, "Aleksandar Seovic");
1299+
parser.parseExpression("name").setValue(context, inventor, "Aleksandar Seovic");
13001300
13011301
// alternatively
13021302
String aleks = parser.parseExpression(
1303-
"Name = 'Aleksandar Seovic'").getValue(context, inventor, String.class);
1303+
"name = 'Aleksandar Seovic'").getValue(context, inventor, String.class);
13041304
----
13051305
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
13061306
.Kotlin
13071307
----
13081308
val inventor = Inventor()
13091309
val context = SimpleEvaluationContext.forReadWriteDataBinding().build()
13101310
1311-
parser.parseExpression("Name").setValue(context, inventor, "Aleksandar Seovic")
1311+
parser.parseExpression("name").setValue(context, inventor, "Aleksandar Seovic")
13121312
13131313
// alternatively
13141314
val aleks = parser.parseExpression(
1315-
"Name = 'Aleksandar Seovic'").getValue(context, inventor, String::class.java)
1315+
"name = 'Aleksandar Seovic'").getValue(context, inventor, String::class.java)
13161316
----
13171317

13181318

@@ -1413,7 +1413,7 @@ The following example shows how to use variables.
14131413
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build();
14141414
context.setVariable("newName", "Mike Tesla");
14151415
1416-
parser.parseExpression("Name = #newName").getValue(context, tesla);
1416+
parser.parseExpression("name = #newName").getValue(context, tesla);
14171417
System.out.println(tesla.getName()) // "Mike Tesla"
14181418
----
14191419
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1424,7 +1424,7 @@ The following example shows how to use variables.
14241424
val context = SimpleEvaluationContext.forReadWriteDataBinding().build()
14251425
context.setVariable("newName", "Mike Tesla")
14261426
1427-
parser.parseExpression("Name = #newName").getValue(context, tesla)
1427+
parser.parseExpression("name = #newName").getValue(context, tesla)
14281428
println(tesla.name) // "Mike Tesla"
14291429
----
14301430

@@ -1633,7 +1633,7 @@ realistic example follows:
16331633
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
16341634
.Java
16351635
----
1636-
parser.parseExpression("Name").setValue(societyContext, "IEEE");
1636+
parser.parseExpression("name").setValue(societyContext, "IEEE");
16371637
societyContext.setVariable("queryName", "Nikola Tesla");
16381638
16391639
expression = "isMember(#queryName)? #queryName + ' is a member of the ' " +
@@ -1646,7 +1646,7 @@ realistic example follows:
16461646
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
16471647
.Kotlin
16481648
----
1649-
parser.parseExpression("Name").setValue(societyContext, "IEEE")
1649+
parser.parseExpression("name").setValue(societyContext, "IEEE")
16501650
societyContext.setVariable("queryName", "Nikola Tesla")
16511651
16521652
expression = "isMember(#queryName)? #queryName + ' is a member of the ' " + "+ Name + ' Society' : #queryName + ' is not a member of the ' + Name + ' Society'"
@@ -1704,11 +1704,11 @@ The following listing shows a more complex example:
17041704
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
17051705
17061706
Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
1707-
String name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, tesla, String.class);
1707+
String name = parser.parseExpression("name?:'Elvis Presley'").getValue(context, tesla, String.class);
17081708
System.out.println(name); // Nikola Tesla
17091709
17101710
tesla.setName(null);
1711-
name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, tesla, String.class);
1711+
name = parser.parseExpression("name?:'Elvis Presley'").getValue(context, tesla, String.class);
17121712
System.out.println(name); // Elvis Presley
17131713
----
17141714
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1718,11 +1718,11 @@ The following listing shows a more complex example:
17181718
val context = SimpleEvaluationContext.forReadOnlyDataBinding().build()
17191719
17201720
val tesla = Inventor("Nikola Tesla", "Serbian")
1721-
var name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, tesla, String::class.java)
1721+
var name = parser.parseExpression("name?:'Elvis Presley'").getValue(context, tesla, String::class.java)
17221722
println(name) // Nikola Tesla
17231723
17241724
tesla.setName(null)
1725-
name = parser.parseExpression("Name?:'Elvis Presley'").getValue(context, tesla, String::class.java)
1725+
name = parser.parseExpression("name?:'Elvis Presley'").getValue(context, tesla, String::class.java)
17261726
println(name) // Elvis Presley
17271727
----
17281728

@@ -1759,11 +1759,11 @@ example shows how to use the safe navigation operator:
17591759
Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
17601760
tesla.setPlaceOfBirth(new PlaceOfBirth("Smiljan"));
17611761
1762-
String city = parser.parseExpression("PlaceOfBirth?.City").getValue(context, tesla, String.class);
1762+
String city = parser.parseExpression("placeOfBirth?.city").getValue(context, tesla, String.class);
17631763
System.out.println(city); // Smiljan
17641764
17651765
tesla.setPlaceOfBirth(null);
1766-
city = parser.parseExpression("PlaceOfBirth?.City").getValue(context, tesla, String.class);
1766+
city = parser.parseExpression("placeOfBirth?.city").getValue(context, tesla, String.class);
17671767
System.out.println(city); // null - does not throw NullPointerException!!!
17681768
----
17691769
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1775,11 +1775,11 @@ example shows how to use the safe navigation operator:
17751775
val tesla = Inventor("Nikola Tesla", "Serbian")
17761776
tesla.setPlaceOfBirth(PlaceOfBirth("Smiljan"))
17771777
1778-
var city = parser.parseExpression("PlaceOfBirth?.City").getValue(context, tesla, String::class.java)
1778+
var city = parser.parseExpression("placeOfBirth?.city").getValue(context, tesla, String::class.java)
17791779
println(city) // Smiljan
17801780
17811781
tesla.setPlaceOfBirth(null)
1782-
city = parser.parseExpression("PlaceOfBirth?.City").getValue(context, tesla, String::class.java)
1782+
city = parser.parseExpression("placeOfBirth?.city").getValue(context, tesla, String::class.java)
17831783
println(city) // null - does not throw NullPointerException!!!
17841784
----
17851785

@@ -1799,13 +1799,13 @@ selection lets us easily get a list of Serbian inventors, as the following examp
17991799
.Java
18001800
----
18011801
List<Inventor> list = (List<Inventor>) parser.parseExpression(
1802-
"Members.?[Nationality == 'Serbian']").getValue(societyContext);
1802+
"members.?[nationality == 'Serbian']").getValue(societyContext);
18031803
----
18041804
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
18051805
.Kotlin
18061806
----
18071807
val list = parser.parseExpression(
1808-
"Members.?[Nationality == 'Serbian']").getValue(societyContext) as List<Inventor>
1808+
"members.?[nationality == 'Serbian']").getValue(societyContext) as List<Inventor>
18091809
----
18101810

18111811
Selection is possible upon both lists and maps. For a list, the selection
@@ -1849,13 +1849,13 @@ every entry in the inventor list. The following example uses projection to do so
18491849
.Java
18501850
----
18511851
// returns ['Smiljan', 'Idvor' ]
1852-
List placesOfBirth = (List)parser.parseExpression("Members.![placeOfBirth.city]");
1852+
List placesOfBirth = (List)parser.parseExpression("members.![placeOfBirth.city]");
18531853
----
18541854
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
18551855
.Kotlin
18561856
----
18571857
// returns ['Smiljan', 'Idvor' ]
1858-
val placesOfBirth = parser.parseExpression("Members.![placeOfBirth.city]") as List<*>
1858+
val placesOfBirth = parser.parseExpression("members.![placeOfBirth.city]") as List<*>
18591859
----
18601860

18611861
You can also use a map to drive projection and, in this case, the projection expression is

0 commit comments

Comments
 (0)