Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
0df46317
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,发现更多精彩内容 >>
提交
0df46317
编写于
7月 20, 2011
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
alignment with backported 3.0.6 code (SPR-8538)
上级
718f025d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
45 addition
and
43 deletion
+45
-43
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java
...framework/core/convert/support/ArrayToArrayConverter.java
+1
-1
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToCollectionConverter.java
...work/core/convert/support/ArrayToCollectionConverter.java
+4
-3
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToObjectConverter.java
...ramework/core/convert/support/ArrayToObjectConverter.java
+2
-2
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToArrayConverter.java
...work/core/convert/support/CollectionToArrayConverter.java
+3
-3
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToCollectionConverter.java
...core/convert/support/CollectionToCollectionConverter.java
+4
-3
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToObjectConverter.java
...ork/core/convert/support/CollectionToObjectConverter.java
+1
-1
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToStringConverter.java
...ork/core/convert/support/CollectionToStringConverter.java
+3
-3
org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
...springframework/core/convert/support/ConversionUtils.java
+12
-13
org.springframework.core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java
...ringframework/core/convert/support/MapToMapConverter.java
+4
-4
org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArrayConverter.java
...ramework/core/convert/support/ObjectToArrayConverter.java
+3
-3
org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToCollectionConverter.java
...ork/core/convert/support/ObjectToCollectionConverter.java
+6
-5
org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java
...mework/core/convert/support/StringToBooleanConverter.java
+2
-2
未找到文件。
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToArrayConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToCollectionConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
@@ -49,7 +49,7 @@ final class ArrayToCollectionConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
.
getElementTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
.
getElementTypeDescriptor
(),
this
.
conversionService
);
}
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -64,7 +64,8 @@ final class ArrayToCollectionConverter implements ConditionalGenericConverter {
Object
sourceElement
=
Array
.
get
(
source
,
i
);
target
.
add
(
sourceElement
);
}
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
Object
sourceElement
=
Array
.
get
(
source
,
i
);
Object
targetElement
=
this
.
conversionService
.
convert
(
sourceElement
,
sourceType
.
elementTypeDescriptor
(
sourceElement
),
targetType
.
getElementTypeDescriptor
());
...
...
org.springframework.core/src/main/java/org/springframework/core/convert/support/ArrayToObjectConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
@@ -43,7 +43,7 @@ final class ArrayToObjectConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
this
.
conversionService
);
}
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToArrayConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
@@ -49,7 +49,7 @@ final class CollectionToArrayConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
.
getElementTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
.
getElementTypeDescriptor
(),
this
.
conversionService
);
}
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
@@ -66,4 +66,4 @@ final class CollectionToArrayConverter implements ConditionalGenericConverter {
return
array
;
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToCollectionConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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.
...
...
@@ -63,7 +63,8 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
for
(
Object
element
:
sourceCollection
)
{
target
.
add
(
element
);
}
}
else
{
}
else
{
for
(
Object
sourceElement
:
sourceCollection
)
{
Object
targetElement
=
this
.
conversionService
.
convert
(
sourceElement
,
sourceType
.
elementTypeDescriptor
(
sourceElement
),
targetType
.
getElementTypeDescriptor
());
target
.
add
(
targetElement
);
...
...
@@ -72,4 +73,4 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
return
target
;
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToObjectConverter.java
浏览文件 @
0df46317
...
...
@@ -43,7 +43,7 @@ final class CollectionToObjectConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
this
.
conversionService
);
}
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
org.springframework.core/src/main/java/org/springframework/core/convert/support/CollectionToStringConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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.
...
...
@@ -45,7 +45,7 @@ final class CollectionToStringConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getElementTypeDescriptor
(),
targetType
,
this
.
conversionService
);
}
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
@@ -69,4 +69,4 @@ final class CollectionToStringConverter implements ConditionalGenericConverter {
return
sb
.
toString
();
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
浏览文件 @
0df46317
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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.
...
...
@@ -41,7 +41,7 @@ abstract class ConversionUtils {
throw
new
ConversionFailedException
(
sourceType
,
targetType
,
source
,
ex
);
}
}
public
static
boolean
canConvertElements
(
TypeDescriptor
sourceElementType
,
TypeDescriptor
targetElementType
,
ConversionService
conversionService
)
{
if
(
targetElementType
==
null
)
{
// yes
...
...
@@ -51,19 +51,18 @@ abstract class ConversionUtils {
// maybe
return
true
;
}
boolean
canConvert
=
conversionService
.
canConvert
(
sourceElementType
,
targetElementType
);
if
(
canConvert
)
{
if
(
conversionService
.
canConvert
(
sourceElementType
,
targetElementType
))
{
// yes
return
true
;
}
else
{
if
(
sourceElementType
.
getType
().
isAssignableFrom
(
targetElementType
.
getType
()))
{
// maybe;
return
true
;
}
else
{
// no;
return
false
;
}
}
}
else
if
(
sourceElementType
.
getType
().
isAssignableFrom
(
targetElementType
.
getType
()))
{
// maybe;
return
true
;
}
else
{
// no
;
return
false
;
}
}
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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.
...
...
@@ -72,11 +72,11 @@ final class MapToMapConverter implements ConditionalGenericConverter {
// internal helpers
private
boolean
canConvertKey
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getMapKeyTypeDescriptor
(),
targetType
.
getMapKeyTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getMapKeyTypeDescriptor
(),
targetType
.
getMapKeyTypeDescriptor
(),
this
.
conversionService
);
}
private
boolean
canConvertValue
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getMapValueTypeDescriptor
(),
targetType
.
getMapValueTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
.
getMapValueTypeDescriptor
(),
targetType
.
getMapValueTypeDescriptor
(),
this
.
conversionService
);
}
private
Object
convertKey
(
Object
sourceKey
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
@@ -93,4 +93,4 @@ final class MapToMapConverter implements ConditionalGenericConverter {
return
this
.
conversionService
.
convert
(
sourceValue
,
sourceType
.
mapValueTypeDescriptor
(
sourceValue
),
targetType
);
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArrayConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
@@ -44,7 +44,7 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
,
targetType
.
getElementTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
,
targetType
.
getElementTypeDescriptor
(),
this
.
conversionService
);
}
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
...
...
@@ -57,4 +57,4 @@ final class ObjectToArrayConverter implements ConditionalGenericConverter {
return
target
;
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToCollectionConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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.
...
...
@@ -46,7 +46,7 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
}
public
boolean
matches
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
ConversionUtils
.
canConvertElements
(
sourceType
,
targetType
.
getElementTypeDescriptor
(),
conversionService
);
return
ConversionUtils
.
canConvertElements
(
sourceType
,
targetType
.
getElementTypeDescriptor
(),
this
.
conversionService
);
}
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -56,12 +56,13 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
}
Collection
<
Object
>
target
=
CollectionFactory
.
createCollection
(
targetType
.
getType
(),
1
);
if
(
targetType
.
getElementTypeDescriptor
()
==
null
||
targetType
.
getElementTypeDescriptor
().
isCollection
())
{
target
.
add
(
source
);
}
else
{
target
.
add
(
source
);
}
else
{
Object
singleElement
=
this
.
conversionService
.
convert
(
source
,
sourceType
,
targetType
.
getElementTypeDescriptor
());
target
.
add
(
singleElement
);
}
return
target
;
}
}
\ No newline at end of file
}
org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java
浏览文件 @
0df46317
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
11
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.
...
...
@@ -48,7 +48,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
public
Boolean
convert
(
String
source
)
{
String
value
=
source
.
trim
();
if
(
value
.
length
()
==
0
)
{
if
(
""
.
equals
(
value
)
)
{
return
null
;
}
value
=
value
.
toLowerCase
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录