Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
33a7bbb4
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
33a7bbb4
编写于
12月 06, 2009
作者:
A
Andy Clement
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-6525: avoid need to use #root for method parameter references
上级
e01c2eaf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
4 deletion
+33
-4
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
.../springframework/expression/spel/ast/MethodReference.java
+8
-1
org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
.../org/springframework/expression/spel/EvaluationTests.java
+20
-0
spring-framework-reference/src/expressions.xml
spring-framework-reference/src/expressions.xml
+5
-3
未找到文件。
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
浏览文件 @
33a7bbb4
...
...
@@ -52,7 +52,14 @@ public class MethodReference extends SpelNodeImpl {
TypedValue
currentContext
=
state
.
getActiveContextObject
();
Object
[]
arguments
=
new
Object
[
getChildCount
()];
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
{
arguments
[
i
]
=
children
[
i
].
getValueInternal
(
state
).
getValue
();
// Make the root object the active context again for evaluating the parameter
// expressions
try
{
state
.
pushActiveContextObject
(
state
.
getRootContextObject
());
arguments
[
i
]
=
children
[
i
].
getValueInternal
(
state
).
getValue
();
}
finally
{
state
.
popActiveContextObject
();
}
}
if
(
currentContext
.
getValue
()
==
null
)
{
if
(
nullSafe
)
{
...
...
org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
浏览文件 @
33a7bbb4
...
...
@@ -367,7 +367,27 @@ public class EvaluationTests extends ExpressionTestCase {
public
void
testTernaryOperatorWithNullValue
()
{
parser
.
parseExpression
(
"null ? 0 : 1"
).
getValue
();
}
@Test
public
void
methodCallWithRootReferenceThroughParameter
()
{
evaluate
(
"placeOfBirth.doubleIt(inventions.length)"
,
18
,
Integer
.
class
);
}
@Test
public
void
ctorCallWithRootReferenceThroughParameter
()
{
evaluate
(
"new org.springframework.expression.spel.testresources.PlaceOfBirth(inventions[0].toString()).city"
,
"Telephone repeater"
,
String
.
class
);
}
@Test
public
void
fnCallWithRootReferenceThroughParameter
()
{
evaluate
(
"#reverseInt(inventions.length, inventions.length, inventions.length)"
,
"int[3]{9,9,9}"
,
int
[].
class
);
}
@Test
public
void
methodCallWithRootReferenceThroughParameterThatIsAFunctionCall
()
{
evaluate
(
"placeOfBirth.doubleIt(#reverseInt(inventions.length,2,3)[2])"
,
18
,
Integer
.
class
);
}
@Test
public
void
testIndexer03
()
{
evaluate
(
"'christian'[8]"
,
"n"
,
String
.
class
);
...
...
spring-framework-reference/src/expressions.xml
浏览文件 @
33a7bbb4
...
...
@@ -776,11 +776,13 @@ parser.parseExpression("Name = #newName").getValue(context);
System.out.println(tesla.getName()) // "Mike Tesla"
</programlisting>
<section>
<title>
The #this
variable
</title>
<title>
The #this
and #root variables
</title>
<para>
The variable #this is always defined and refers to the current
evaluation object (the object against which unqualified references
will be resolved).
</para>
evaluation object (against which unqualified references are resolved).
The variable #root is always defined and refers to the root
context object. Although #this may vary as components of an expression
are evaluated, #root always refers to the root.
</para>
<programlisting
language=
"java"
>
// create an array of integers
List
<
Integer
>
primes = new ArrayList
<
Integer
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录