diff --git a/spring-framework-reference/src/expressions.xml b/spring-framework-reference/src/expressions.xml index faacbd465ce..69d57fc2bc2 100644 --- a/spring-framework-reference/src/expressions.xml +++ b/spring-framework-reference/src/expressions.xml @@ -95,6 +95,10 @@ User defined functions + + List projections + + Templated expressions @@ -564,7 +568,7 @@ boolean falseValue = parser.parseExpression(expression).getValue(societyContext, supported are modulus (%) and exponential power (^). Standard operator precedence is enforced. These operators are demonstrated below - // Addition + // Addition int two = parser.parseExpression("1 + 1").getValue(Integer.class); // 2 String testString = parser.parseExpression("'test' + ' ' + 'string'").getValue(String.class); // 'test string' @@ -605,7 +609,7 @@ int minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(Integer.class); This would typically be done within a call to SetValue but can also be done inside a call to GetValue - Inventor inventor = new Inventor(); + Inventor inventor = new Inventor(); StandardEvaluationContext inventorContext = new StandardEvaluationContext(); inventorContext.setRootObject(inventor); @@ -627,7 +631,7 @@ String aleks = parser.parseExpression("Name = 'Alexandar Seovic'").getValue(inve java.lang.Class (the 'type'). Static methods are invoked using this operator as well - Class dateClass = parser.parseExpression("T(java.util.Date)").getValue(Class.class); + Class dateClass = parser.parseExpression("T(java.util.Date)").getValue(Class.class); boolean isEqual = parser.parseExpression("T(java.math.RoundingMode).CEILING < T(java.math.RoundingMode).FLOOR").getValue(Boolean.class); @@ -641,7 +645,7 @@ boolean isEqual = parser.parseExpression("T(java.math.RoundingMode).CEILING < qualified classname should be used for all but the primitive type and String (where int, float, etc, can be used). - Inventor einstein = + Inventor einstein = parser.parseExpression("new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')").getValue(Inventor.class); //create new inventor instance within add method of List @@ -656,7 +660,7 @@ parser.parseExpression("Members.add(new org.spring.samples.spel.inventor.Invento #variableName. Variables are set using the method setVariable on the StandardEvaluationContext. - Inventor tesla = new Inventor("Nikola Tesla", "Serbian"); + Inventor tesla = new Inventor("Nikola Tesla", "Serbian"); StandardEvaluationContext context = new StandardEvaluationContext(); context.setVariable("newName", "Mike Tesla"); context.setRootObject(tesla); @@ -689,13 +693,14 @@ System.out.println(tesla.getName()) // "Mike Tesla" In this case, the boolean false results in returning the string value 'falseExp'. A less artificial example is shown below. - parser.parseExpression("Name").setValue(societyContext, "IEEE"); + parser.parseExpression("Name").setValue(societyContext, "IEEE"); societyContext.setVariable("queryName", "Nikola Tesla"); expression = "isMember(#queryName)? #queryName + ' is a member of the ' " + "+ Name + ' Society' : #queryName + ' is not a member of the ' + Name + ' Society'"; -String queryResultString = parser.parseExpression(expression).getValue(societyContext, String.class); +String queryResultString = parser.parseExpression(expression).getValue(societyContext, String.class); +// queryResultString = "Nikola Tesla is a member of the IEEE Society"
@@ -711,7 +716,7 @@ String queryResultString = parser.parseExpression(expression).getValue(societyCo original element list. For example, selection would allow us to easily get a list of Serbian inventors: - List<Inventor> list = (List<Inventor>) parser.parseExpression("Members.?{Nationality == 'Serbian'}").getValue(societyContext); + List<Inventor> list = (List<Inventor>) parser.parseExpression("Members.?{Nationality == 'Serbian'}").getValue(societyContext);