Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
cc29db4c
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,体验更适合开发者的 AI 搜索 >>
提交
cc29db4c
编写于
9月 18, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
90b93ffe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
13 deletion
+23
-13
spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
...amework/expression/spel/ast/PropertyOrFieldReference.java
+23
-13
未找到文件。
spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
浏览文件 @
cc29db4c
...
...
@@ -78,7 +78,8 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
@Override
public
TypedValue
getValueInternal
(
ExpressionState
state
)
throws
EvaluationException
{
TypedValue
tv
=
getValueInternal
(
state
.
getActiveContextObject
(),
state
.
getEvaluationContext
(),
state
.
getConfiguration
().
isAutoGrowNullReferences
());
TypedValue
tv
=
getValueInternal
(
state
.
getActiveContextObject
(),
state
.
getEvaluationContext
(),
state
.
getConfiguration
().
isAutoGrowNullReferences
());
if
(
this
.
cachedReadAccessor
instanceof
CompilablePropertyAccessor
)
{
CompilablePropertyAccessor
accessor
=
(
CompilablePropertyAccessor
)
this
.
cachedReadAccessor
;
this
.
exitTypeDescriptor
=
CodeFlow
.
toDescriptor
(
accessor
.
getPropertyType
());
...
...
@@ -100,7 +101,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
// Create a new collection or map ready for the indexer
if
(
resultDescriptor
.
getType
().
equals
(
List
.
class
))
{
try
{
if
(
isWritableProperty
(
this
.
name
,
contextObject
,
eContext
))
{
if
(
isWritableProperty
(
this
.
name
,
contextObject
,
eContext
))
{
List
<?>
newList
=
ArrayList
.
class
.
newInstance
();
writeProperty
(
contextObject
,
eContext
,
this
.
name
,
newList
);
result
=
readProperty
(
contextObject
,
eContext
,
this
.
name
);
...
...
@@ -156,12 +157,12 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
@Override
public
void
setValue
(
ExpressionState
state
,
Object
newValue
)
throws
Spel
EvaluationException
{
public
void
setValue
(
ExpressionState
state
,
Object
newValue
)
throws
EvaluationException
{
writeProperty
(
state
.
getActiveContextObject
(),
state
.
getEvaluationContext
(),
this
.
name
,
newValue
);
}
@Override
public
boolean
isWritable
(
ExpressionState
state
)
throws
Spel
EvaluationException
{
public
boolean
isWritable
(
ExpressionState
state
)
throws
EvaluationException
{
return
isWritableProperty
(
this
.
name
,
state
.
getActiveContextObject
(),
state
.
getEvaluationContext
());
}
...
...
@@ -173,9 +174,11 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
/**
* Attempt to read the named property from the current context object.
* @return the value of the property
* @throws
Spel
EvaluationException if any problem accessing the property or it cannot be found
* @throws EvaluationException if any problem accessing the property or it cannot be found
*/
private
TypedValue
readProperty
(
TypedValue
contextObject
,
EvaluationContext
eContext
,
String
name
)
throws
EvaluationException
{
private
TypedValue
readProperty
(
TypedValue
contextObject
,
EvaluationContext
eContext
,
String
name
)
throws
EvaluationException
{
Object
targetObject
=
contextObject
.
getValue
();
if
(
targetObject
==
null
&&
this
.
nullSafe
)
{
return
TypedValue
.
NULL
;
...
...
@@ -193,7 +196,8 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
// Go through the accessors that may be able to resolve it. If they are a cacheable accessor then
// get the accessor and use it. If they are not cacheable but report they can read the property
// then ask them to read it
...
...
@@ -223,7 +227,9 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
private
void
writeProperty
(
TypedValue
contextObject
,
EvaluationContext
eContext
,
String
name
,
Object
newValue
)
throws
SpelEvaluationException
{
private
void
writeProperty
(
TypedValue
contextObject
,
EvaluationContext
eContext
,
String
name
,
Object
newValue
)
throws
EvaluationException
{
if
(
contextObject
.
getValue
()
==
null
&&
this
.
nullSafe
)
{
return
;
}
...
...
@@ -241,7 +247,8 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
if
(
accessorsToTry
!=
null
)
{
try
{
for
(
PropertyAccessor
accessor
:
accessorsToTry
)
{
...
...
@@ -266,8 +273,11 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
public
boolean
isWritableProperty
(
String
name
,
TypedValue
contextObject
,
EvaluationContext
eContext
)
throws
SpelEvaluationException
{
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
public
boolean
isWritableProperty
(
String
name
,
TypedValue
contextObject
,
EvaluationContext
eContext
)
throws
EvaluationException
{
List
<
PropertyAccessor
>
accessorsToTry
=
getPropertyAccessorsToTry
(
contextObject
.
getValue
(),
eContext
.
getPropertyAccessors
());
if
(
accessorsToTry
!=
null
)
{
for
(
PropertyAccessor
accessor
:
accessorsToTry
)
{
try
{
...
...
@@ -360,8 +370,8 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
@Override
public
TypedValue
getValue
()
{
TypedValue
value
=
this
.
ref
.
getValueInternal
(
this
.
contextObject
,
this
.
eContext
,
this
.
autoGrowNullReferences
);
if
(
ref
.
cachedReadAccessor
instanceof
CompilablePropertyAccessor
)
{
CompilablePropertyAccessor
accessor
=
(
CompilablePropertyAccessor
)
this
.
ref
.
cachedReadAccessor
;
if
(
this
.
ref
.
cachedReadAccessor
instanceof
CompilablePropertyAccessor
)
{
CompilablePropertyAccessor
accessor
=
(
CompilablePropertyAccessor
)
this
.
ref
.
cachedReadAccessor
;
this
.
ref
.
exitTypeDescriptor
=
CodeFlow
.
toDescriptor
(
accessor
.
getPropertyType
());
}
return
value
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录