@@ -835,12 +835,12 @@ shows:
835
835
// Members List
836
836
837
837
// evaluates to "Nikola Tesla"
838
- String name = parser.parseExpression("Members [0].Name ").getValue(
838
+ String name = parser.parseExpression("members [0].name ").getValue(
839
839
context, ieee, String.class);
840
840
841
841
// List and Array navigation
842
842
// evaluates to "Wireless communication"
843
- String invention = parser.parseExpression("Members [0].Inventions [6]").getValue(
843
+ String invention = parser.parseExpression("members [0].inventions [6]").getValue(
844
844
context, ieee, String.class);
845
845
----
846
846
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -858,49 +858,49 @@ shows:
858
858
// Members List
859
859
860
860
// evaluates to "Nikola Tesla"
861
- val name = parser.parseExpression("Members [0].Name ").getValue(
861
+ val name = parser.parseExpression("members [0].name ").getValue(
862
862
context, ieee, String::class.java)
863
863
864
864
// List and Array navigation
865
865
// evaluates to "Wireless communication"
866
- val invention = parser.parseExpression("Members [0].Inventions [6]").getValue(
866
+ val invention = parser.parseExpression("members [0].inventions [6]").getValue(
867
867
context, ieee, String::class.java)
868
868
----
869
869
870
870
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
872
872
string literals:
873
873
874
874
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
875
875
.Java
876
876
----
877
877
// Officer's Dictionary
878
878
879
- Inventor pupin = parser.parseExpression("Officers ['president']").getValue(
879
+ Inventor pupin = parser.parseExpression("officers ['president']").getValue(
880
880
societyContext, Inventor.class);
881
881
882
882
// evaluates to "Idvor"
883
- String city = parser.parseExpression("Officers ['president'].PlaceOfBirth.City ").getValue(
883
+ String city = parser.parseExpression("officers ['president'].placeOfBirth.city ").getValue(
884
884
societyContext, String.class);
885
885
886
886
// setting values
887
- parser.parseExpression("Officers ['advisors'][0].PlaceOfBirth.Country ").setValue(
887
+ parser.parseExpression("officers ['advisors'][0].placeOfBirth.country ").setValue(
888
888
societyContext, "Croatia");
889
889
----
890
890
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
891
891
.Kotlin
892
892
----
893
893
// Officer's Dictionary
894
894
895
- val pupin = parser.parseExpression("Officers ['president']").getValue(
895
+ val pupin = parser.parseExpression("officers ['president']").getValue(
896
896
societyContext, Inventor::class.java)
897
897
898
898
// evaluates to "Idvor"
899
- val city = parser.parseExpression("Officers ['president'].PlaceOfBirth.City ").getValue(
899
+ val city = parser.parseExpression("officers ['president'].placeOfBirth.city ").getValue(
900
900
societyContext, String::class.java)
901
901
902
902
// setting values
903
- parser.parseExpression("Officers ['advisors'][0].PlaceOfBirth.Country ").setValue(
903
+ parser.parseExpression("officers ['advisors'][0].placeOfBirth.country ").setValue(
904
904
societyContext, "Croatia")
905
905
----
906
906
@@ -1296,23 +1296,23 @@ following listing shows both ways to use the assignment operator:
1296
1296
Inventor inventor = new Inventor();
1297
1297
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build();
1298
1298
1299
- parser.parseExpression("Name ").setValue(context, inventor, "Aleksandar Seovic");
1299
+ parser.parseExpression("name ").setValue(context, inventor, "Aleksandar Seovic");
1300
1300
1301
1301
// alternatively
1302
1302
String aleks = parser.parseExpression(
1303
- "Name = 'Aleksandar Seovic'").getValue(context, inventor, String.class);
1303
+ "name = 'Aleksandar Seovic'").getValue(context, inventor, String.class);
1304
1304
----
1305
1305
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1306
1306
.Kotlin
1307
1307
----
1308
1308
val inventor = Inventor()
1309
1309
val context = SimpleEvaluationContext.forReadWriteDataBinding().build()
1310
1310
1311
- parser.parseExpression("Name ").setValue(context, inventor, "Aleksandar Seovic")
1311
+ parser.parseExpression("name ").setValue(context, inventor, "Aleksandar Seovic")
1312
1312
1313
1313
// alternatively
1314
1314
val aleks = parser.parseExpression(
1315
- "Name = 'Aleksandar Seovic'").getValue(context, inventor, String::class.java)
1315
+ "name = 'Aleksandar Seovic'").getValue(context, inventor, String::class.java)
1316
1316
----
1317
1317
1318
1318
@@ -1413,7 +1413,7 @@ The following example shows how to use variables.
1413
1413
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build();
1414
1414
context.setVariable("newName", "Mike Tesla");
1415
1415
1416
- parser.parseExpression("Name = #newName").getValue(context, tesla);
1416
+ parser.parseExpression("name = #newName").getValue(context, tesla);
1417
1417
System.out.println(tesla.getName()) // "Mike Tesla"
1418
1418
----
1419
1419
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1424,7 +1424,7 @@ The following example shows how to use variables.
1424
1424
val context = SimpleEvaluationContext.forReadWriteDataBinding().build()
1425
1425
context.setVariable("newName", "Mike Tesla")
1426
1426
1427
- parser.parseExpression("Name = #newName").getValue(context, tesla)
1427
+ parser.parseExpression("name = #newName").getValue(context, tesla)
1428
1428
println(tesla.name) // "Mike Tesla"
1429
1429
----
1430
1430
@@ -1633,7 +1633,7 @@ realistic example follows:
1633
1633
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
1634
1634
.Java
1635
1635
----
1636
- parser.parseExpression("Name ").setValue(societyContext, "IEEE");
1636
+ parser.parseExpression("name ").setValue(societyContext, "IEEE");
1637
1637
societyContext.setVariable("queryName", "Nikola Tesla");
1638
1638
1639
1639
expression = "isMember(#queryName)? #queryName + ' is a member of the ' " +
@@ -1646,7 +1646,7 @@ realistic example follows:
1646
1646
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1647
1647
.Kotlin
1648
1648
----
1649
- parser.parseExpression("Name ").setValue(societyContext, "IEEE")
1649
+ parser.parseExpression("name ").setValue(societyContext, "IEEE")
1650
1650
societyContext.setVariable("queryName", "Nikola Tesla")
1651
1651
1652
1652
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:
1704
1704
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
1705
1705
1706
1706
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);
1708
1708
System.out.println(name); // Nikola Tesla
1709
1709
1710
1710
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);
1712
1712
System.out.println(name); // Elvis Presley
1713
1713
----
1714
1714
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1718,11 +1718,11 @@ The following listing shows a more complex example:
1718
1718
val context = SimpleEvaluationContext.forReadOnlyDataBinding().build()
1719
1719
1720
1720
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)
1722
1722
println(name) // Nikola Tesla
1723
1723
1724
1724
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)
1726
1726
println(name) // Elvis Presley
1727
1727
----
1728
1728
@@ -1759,11 +1759,11 @@ example shows how to use the safe navigation operator:
1759
1759
Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
1760
1760
tesla.setPlaceOfBirth(new PlaceOfBirth("Smiljan"));
1761
1761
1762
- String city = parser.parseExpression("PlaceOfBirth?.City ").getValue(context, tesla, String.class);
1762
+ String city = parser.parseExpression("placeOfBirth?.city ").getValue(context, tesla, String.class);
1763
1763
System.out.println(city); // Smiljan
1764
1764
1765
1765
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);
1767
1767
System.out.println(city); // null - does not throw NullPointerException!!!
1768
1768
----
1769
1769
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1775,11 +1775,11 @@ example shows how to use the safe navigation operator:
1775
1775
val tesla = Inventor("Nikola Tesla", "Serbian")
1776
1776
tesla.setPlaceOfBirth(PlaceOfBirth("Smiljan"))
1777
1777
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)
1779
1779
println(city) // Smiljan
1780
1780
1781
1781
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)
1783
1783
println(city) // null - does not throw NullPointerException!!!
1784
1784
----
1785
1785
@@ -1799,13 +1799,13 @@ selection lets us easily get a list of Serbian inventors, as the following examp
1799
1799
.Java
1800
1800
----
1801
1801
List<Inventor> list = (List<Inventor>) parser.parseExpression(
1802
- "Members .?[Nationality == 'Serbian']").getValue(societyContext);
1802
+ "members .?[nationality == 'Serbian']").getValue(societyContext);
1803
1803
----
1804
1804
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1805
1805
.Kotlin
1806
1806
----
1807
1807
val list = parser.parseExpression(
1808
- "Members .?[Nationality == 'Serbian']").getValue(societyContext) as List<Inventor>
1808
+ "members .?[nationality == 'Serbian']").getValue(societyContext) as List<Inventor>
1809
1809
----
1810
1810
1811
1811
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
1849
1849
.Java
1850
1850
----
1851
1851
// returns ['Smiljan', 'Idvor' ]
1852
- List placesOfBirth = (List)parser.parseExpression("Members .![placeOfBirth.city]");
1852
+ List placesOfBirth = (List)parser.parseExpression("members .![placeOfBirth.city]");
1853
1853
----
1854
1854
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1855
1855
.Kotlin
1856
1856
----
1857
1857
// returns ['Smiljan', 'Idvor' ]
1858
- val placesOfBirth = parser.parseExpression("Members .![placeOfBirth.city]") as List<*>
1858
+ val placesOfBirth = parser.parseExpression("members .![placeOfBirth.city]") as List<*>
1859
1859
----
1860
1860
1861
1861
You can also use a map to drive projection and, in this case, the projection expression is
0 commit comments