Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e4c868b8
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 搜索 >>
提交
e4c868b8
编写于
7月 10, 2009
作者:
K
Keith Donald
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
javadoc
上级
84bdd1ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
14 deletion
+48
-14
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java
...org/springframework/ui/binding/support/GenericBinder.java
+1
-7
org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java
...pringframework/ui/binding/support/GenericBinderTests.java
+1
-1
org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericTypeConverter.java
...gframework/core/convert/support/GenericTypeConverter.java
+46
-6
未找到文件。
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java
浏览文件 @
e4c868b8
...
...
@@ -295,12 +295,6 @@ public class GenericBinder implements Binder {
"Unable to get model binding; cannot parse property expression from property string ["
+
property
+
"]"
,
e
);
}
try
{
propertyExpression
.
getValueType
(
createEvaluationContext
());
}
catch
(
EvaluationException
e
)
{
throw
new
IllegalArgumentException
(
"Unable to get model binding; cannot access property '"
+
propertyExpression
.
getExpressionString
()
+
"'"
,
e
);
}
return
new
BindingImpl
(
propertyExpression
,
configuration
.
getFormatter
());
}
...
...
@@ -694,7 +688,7 @@ public class GenericBinder implements Binder {
builder
.
arg
(
"label"
,
new
ResolvableArgument
(
property
));
builder
.
arg
(
"value"
,
sourceValue
);
builder
.
defaultMessage
(
"Successfully bound user value "
+
StylerUtils
.
style
(
sourceValue
)
+
"to property '"
+
property
+
"'"
);
+
"
to property '"
+
property
+
"'"
);
return
builder
.
build
();
}
};
...
...
org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java
浏览文件 @
e4c868b8
...
...
@@ -264,7 +264,7 @@ public class GenericBinderTests {
binder
.
registerFormatter
(
new
GenericCollectionPropertyType
(
List
.
class
,
Address
.
class
),
new
AddressListFormatter
());
Map
<
String
,
String
>
values
=
new
LinkedHashMap
<
String
,
String
>();
values
.
put
(
"addresses"
,
"4655 Macy Lane:Melbourne:FL:35452,1234 Rostock Circle:Palm Bay:FL:32901,1977 Bel Aire Estates:Coker:AL:12345"
);
binder
.
bind
(
values
);
BindingResults
results
=
binder
.
bind
(
values
);
Assert
.
assertEquals
(
3
,
bean
.
addresses
.
size
());
assertEquals
(
"4655 Macy Lane"
,
bean
.
addresses
.
get
(
0
).
street
);
assertEquals
(
"Melbourne"
,
bean
.
addresses
.
get
(
0
).
city
);
...
...
org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericTypeConverter.java
浏览文件 @
e4c868b8
...
...
@@ -159,29 +159,69 @@ public class GenericTypeConverter implements TypeConverter, ConverterRegistry {
+
"request an interface or concrete implementation instead"
);
}
return
new
ArrayToCollection
(
sourceType
,
targetType
,
this
);
}
}
if
(
targetType
.
isArray
())
{
if
(
sourceType
.
isCollection
())
{
return
new
CollectionToArray
(
sourceType
,
targetType
,
this
);
}
else
if
(
targetType
.
isMap
())
{
if
(
sourceType
.
getElementType
().
equals
(
String
.
class
))
{
// string array to map; with string element values in format foo=bar
return
null
;
}
else
{
return
null
;
}
}
else
{
// array to object
return
null
;
}
}
if
(
sourceType
.
isCollection
())
{
if
(
targetType
.
isCollection
())
{
if
(
targetType
.
isCollection
())
{
return
new
CollectionToCollection
(
sourceType
,
targetType
,
this
);
}
else
if
(
targetType
.
isArray
())
{
return
new
CollectionToArray
(
sourceType
,
targetType
,
this
);
}
else
if
(
targetType
.
isMap
())
{
if
(
sourceType
.
getElementType
().
equals
(
String
.
class
))
{
// string collection to map; with string element values in format foo=bar
return
null
;
}
else
{
return
null
;
}
}
else
{
// collection to object
return
null
;
}
}
if
(
sourceType
.
isMap
())
{
if
(
targetType
.
isMap
())
{
return
new
MapToMap
(
sourceType
,
targetType
,
this
);
}
else
if
(
targetType
.
isArray
())
{
if
(
targetType
.
getElementType
().
equals
(
String
.
class
))
{
// map to string array; with string element values in format foo=bar
return
null
;
}
else
{
return
null
;
}
}
else
if
(
targetType
.
isCollection
())
{
if
(
targetType
.
getElementType
().
equals
(
String
.
class
))
{
// map to string collection; with string element values in format foo=bar
return
null
;
}
else
{
return
null
;
}
}
else
{
// map to object
return
null
;
}
}
if
(
targetType
.
isArray
())
{
// object to array
return
null
;
}
if
(
targetType
.
isCollection
())
{
// object to collection
return
null
;
}
if
(
targetType
.
isMap
())
{
// object to map
return
null
;
}
if
(
sourceType
.
isAssignableTo
(
targetType
))
{
return
NoOpConversionExecutor
.
INSTANCE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录