Browse Source

fixed TemplateParserContext documentation (SPR-7059)

pull/23217/head
Juergen Hoeller 16 years ago
parent
commit
52179d8bfb
  1. 5
      org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateParserContext.java
  2. 14
      spring-framework-reference/src/expressions.xml

5
org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateParserContext.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,8 +31,9 @@ public class TemplateParserContext implements ParserContext { @@ -31,8 +31,9 @@ public class TemplateParserContext implements ParserContext {
private final String expressionSuffix;
/**
* Creates a new TemplateParserContext with the default #{ prefix and } suffix.
* Create a new TemplateParserContext with the default "#{" prefix and "}" suffix.
*/
public TemplateParserContext() {
this("#{", "}");

14
spring-framework-reference/src/expressions.xml

@ -1015,28 +1015,28 @@ List placesOfBirth = (List)parser.parseExpression("Members.![placeOfBirth.city]" @@ -1015,28 +1015,28 @@ List placesOfBirth = (List)parser.parseExpression("Members.![placeOfBirth.city]"
<para>Expression templates allow a mixing of literal text with one or
more evaluation blocks. Each evaluation block is delimited with prefix
and suffix characters that you can define, a common choice is to use
<literal>${} </literal>as the delimiters. For example,</para>
<literal>#{ }</literal> as the delimiters. For example,</para>
<programlisting language="java">String randomPhrase =
parser.parseExpression("random number is ${T(java.lang.Math).random()}",
new TemplatedParserContext()).getValue(String.class);
parser.parseExpression("random number is #{T(java.lang.Math).random()}",
new TemplateParserContext()).getValue(String.class);
// evaluates to "random number is 0.7038186818312008"</programlisting>
<para>The string is evaluated by concatenating the literal text 'random
number is ' with the result of evaluating the expression inside the ${}
number is ' with the result of evaluating the expression inside the #{ }
delimiter, in this case the result of calling that random() method. The
second argument to the method <literal>parseExpression()</literal> is of
the type <interfacename>ParserContext</interfacename>. The
<interfacename>ParserContext</interfacename> interface is used to
influence how the expression is parsed in order to support the
expression templating functionality. The definition of
<classname>TemplatedParserContext</classname> is shown below.</para>
<classname>TemplateParserContext</classname> is shown below.</para>
<programlisting language="java">public class TemplatedParserContext implements ParserContext {
<programlisting language="java">public class TemplateParserContext implements ParserContext {
public String getExpressionPrefix() {
return "${";
return "#{";
}
public String getExpressionSuffix() {

Loading…
Cancel
Save