fixed TemplateParserContext documentation (SPR-7059)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3216 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2010-04-01 10:59:58 +00:00
parent dc426b06e3
commit 5d87fe71fa
2 changed files with 10 additions and 9 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,8 +31,9 @@ public class TemplateParserContext implements ParserContext {
private final String expressionSuffix; 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() { public TemplateParserContext() {
this("#{", "}"); this("#{", "}");

View File

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