Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
caa1218d
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,发现更多精彩内容 >>
提交
caa1218d
编写于
8月 29, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
c6640100
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
61 deletion
+67
-61
spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContext.java
...springframework/format/datetime/joda/JodaTimeContext.java
+5
-5
spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java
...ngframework/format/datetime/standard/DateTimeContext.java
+5
-5
spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
...k/core/convert/support/GenericConversionServiceTests.java
+41
-38
spring-webmvc/src/main/java/org/springframework/web/servlet/support/JstlUtils.java
...va/org/springframework/web/servlet/support/JstlUtils.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java
...g/springframework/web/servlet/support/RequestContext.java
+14
-11
未找到文件。
spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContext.java
浏览文件 @
caa1218d
...
...
@@ -38,31 +38,31 @@ public class JodaTimeContext {
/**
* Set the user's chronology.
* Set the user's chronology
(calendar system)
.
*/
public
void
setChronology
(
Chronology
chronology
)
{
this
.
chronology
=
chronology
;
}
/**
*
T
he user's chronology (calendar system), if any.
*
Return t
he user's chronology (calendar system), if any.
*/
public
Chronology
getChronology
()
{
return
this
.
chronology
;
}
/**
* Set the user's timezone.
* Set the user's time
zone.
*/
public
void
setTimeZone
(
DateTimeZone
timeZone
)
{
this
.
timeZone
=
timeZone
;
}
/**
*
The user's time
zone, if any.
*
Return the user's time
zone, if any.
*/
public
DateTimeZone
getTimeZone
()
{
return
timeZone
;
return
t
his
.
t
imeZone
;
}
...
...
spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java
浏览文件 @
caa1218d
...
...
@@ -37,31 +37,31 @@ public class DateTimeContext {
/**
* Set the user's chronology.
* Set the user's chronology
(calendar system)
.
*/
public
void
setChronology
(
Chronology
chronology
)
{
this
.
chronology
=
chronology
;
}
/**
*
T
he user's chronology (calendar system), if any.
*
Return t
he user's chronology (calendar system), if any.
*/
public
Chronology
getChronology
()
{
return
this
.
chronology
;
}
/**
* Set the user's timezone.
* Set the user's time
zone.
*/
public
void
setTimeZone
(
ZoneId
timeZone
)
{
this
.
timeZone
=
timeZone
;
}
/**
*
The user's time
zone, if any.
*
Return the user's time
zone, if any.
*/
public
ZoneId
getTimeZone
()
{
return
timeZone
;
return
t
his
.
t
imeZone
;
}
...
...
spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
浏览文件 @
caa1218d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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 @@ import org.springframework.tests.TestGroup;
import
org.springframework.util.StopWatch
;
import
org.springframework.util.StringUtils
;
import
static
org
.
hamcrest
.
Matchers
.
greaterThan
;
import
static
org
.
hamcrest
.
Matchers
.
*
;
import
static
org
.
junit
.
Assert
.*;
/**
...
...
@@ -81,14 +81,14 @@ public class GenericConversionServiceTests {
try
{
assertFalse
(
conversionService
.
canConvert
(
String
.
class
,
null
));
fail
(
"Should have failed"
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
ex
)
{
}
try
{
assertFalse
(
conversionService
.
canConvert
(
TypeDescriptor
.
valueOf
(
String
.
class
),
null
));
fail
(
"Should have failed"
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
ex
)
{
}
}
...
...
@@ -151,8 +151,8 @@ public class GenericConversionServiceTests {
}
});
fail
(
"Should have failed"
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
ex
)
{
}
}
...
...
@@ -254,7 +254,8 @@ public class GenericConversionServiceTests {
try
{
conversionService
.
convert
(
"3,4,5"
,
Integer
[].
class
);
fail
(
"should have failed"
);
}
catch
(
ConverterNotFoundException
e
)
{
}
catch
(
ConverterNotFoundException
ex
)
{
}
}
...
...
@@ -389,7 +390,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
testConvertUUID
()
throws
Exception
{
public
void
testConvertUUID
()
{
GenericConversionService
service
=
new
DefaultConversionService
();
UUID
uuid
=
UUID
.
randomUUID
();
String
convertToString
=
service
.
convert
(
uuid
,
String
.
class
);
...
...
@@ -472,7 +473,7 @@ public class GenericConversionServiceTests {
public
static
Map
<
String
,
Integer
>
map
;
@Test
public
void
emptyListToArray
()
throws
Exception
{
public
void
emptyListToArray
()
{
conversionService
.
addConverter
(
new
CollectionToArrayConverter
(
conversionService
));
conversionService
.
addConverterFactory
(
new
StringToNumberConverterFactory
());
List
<
String
>
list
=
new
ArrayList
<
String
>();
...
...
@@ -483,7 +484,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
emptyListToObject
()
throws
Exception
{
public
void
emptyListToObject
()
{
conversionService
.
addConverter
(
new
CollectionToObjectConverter
(
conversionService
));
conversionService
.
addConverterFactory
(
new
StringToNumberConverterFactory
());
List
<
String
>
list
=
new
ArrayList
<
String
>();
...
...
@@ -590,14 +591,14 @@ public class GenericConversionServiceTests {
public
Collection
<
Integer
>
stringToCollection
;
@Test
public
void
testConvertiblePairsInSet
()
throws
Exception
{
public
void
testConvertiblePairsInSet
()
{
Set
<
GenericConverter
.
ConvertiblePair
>
set
=
new
HashSet
<
GenericConverter
.
ConvertiblePair
>();
set
.
add
(
new
GenericConverter
.
ConvertiblePair
(
Number
.
class
,
String
.
class
));
assert
set
.
contains
(
new
GenericConverter
.
ConvertiblePair
(
Number
.
class
,
String
.
class
));
}
@Test
public
void
testConvertiblePairEqualsAndHash
()
throws
Exception
{
public
void
testConvertiblePairEqualsAndHash
()
{
GenericConverter
.
ConvertiblePair
pair
=
new
GenericConverter
.
ConvertiblePair
(
Number
.
class
,
String
.
class
);
GenericConverter
.
ConvertiblePair
pairEqual
=
new
GenericConverter
.
ConvertiblePair
(
Number
.
class
,
String
.
class
);
assertEquals
(
pair
,
pairEqual
);
...
...
@@ -605,7 +606,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
testConvertiblePairDifferentEqualsAndHash
()
throws
Exception
{
public
void
testConvertiblePairDifferentEqualsAndHash
()
{
GenericConverter
.
ConvertiblePair
pair
=
new
GenericConverter
.
ConvertiblePair
(
Number
.
class
,
String
.
class
);
GenericConverter
.
ConvertiblePair
pairOpposite
=
new
GenericConverter
.
ConvertiblePair
(
String
.
class
,
Number
.
class
);
assertFalse
(
pair
.
equals
(
pairOpposite
));
...
...
@@ -613,7 +614,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
convertPrimitiveArray
()
throws
Exception
{
public
void
convertPrimitiveArray
()
{
GenericConversionService
conversionService
=
new
DefaultConversionService
();
byte
[]
byteArray
=
new
byte
[]
{
1
,
2
,
3
};
Byte
[]
converted
=
conversionService
.
convert
(
byteArray
,
Byte
[].
class
);
...
...
@@ -625,7 +626,8 @@ public class GenericConversionServiceTests {
try
{
conversionService
.
canConvert
(
String
.
class
,
null
);
fail
(
"Did not thow IllegalArgumentException"
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
ex
)
{
}
}
...
...
@@ -634,13 +636,14 @@ public class GenericConversionServiceTests {
try
{
conversionService
.
canConvert
(
TypeDescriptor
.
valueOf
(
String
.
class
),
null
);
fail
(
"Did not thow IllegalArgumentException"
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
ex
)
{
}
}
@Test
@SuppressWarnings
({
"rawtypes"
})
public
void
convertHashMapValuesToList
()
throws
Exception
{
public
void
convertHashMapValuesToList
()
{
GenericConversionService
conversionService
=
new
DefaultConversionService
();
Map
<
String
,
Integer
>
hashMap
=
new
LinkedHashMap
<
String
,
Integer
>();
hashMap
.
put
(
"1"
,
1
);
...
...
@@ -650,7 +653,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
removeConvertible
()
throws
Exception
{
public
void
removeConvertible
()
{
conversionService
.
addConverter
(
new
ColorConverter
());
assertTrue
(
conversionService
.
canConvert
(
String
.
class
,
Color
.
class
));
conversionService
.
removeConvertible
(
String
.
class
,
Color
.
class
);
...
...
@@ -658,7 +661,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
conditionalConverter
()
throws
Exception
{
public
void
conditionalConverter
()
{
GenericConversionService
conversionService
=
new
GenericConversionService
();
MyConditionalConverter
converter
=
new
MyConditionalConverter
();
conversionService
.
addConverter
(
new
ColorConverter
());
...
...
@@ -668,7 +671,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
conditionalConverterFactory
()
throws
Exception
{
public
void
conditionalConverterFactory
()
{
GenericConversionService
conversionService
=
new
GenericConversionService
();
MyConditionalConverterFactory
converter
=
new
MyConditionalConverterFactory
();
conversionService
.
addConverter
(
new
ColorConverter
());
...
...
@@ -679,32 +682,29 @@ public class GenericConversionServiceTests {
}
@Test
public
void
shouldNotSuportNullConvertibleTypesFromNonConditionalGenericConverter
()
throws
Exception
{
public
void
shouldNotSuportNullConvertibleTypesFromNonConditionalGenericConverter
()
{
GenericConversionService
conversionService
=
new
GenericConversionService
();
GenericConverter
converter
=
new
GenericConverter
()
{
@Override
public
Set
<
ConvertiblePair
>
getConvertibleTypes
()
{
return
null
;
}
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
null
;
}
};
try
{
conversionService
.
addConverter
(
converter
);
fail
(
"Did not throw"
);
}
catch
(
IllegalStateException
e
)
{
assertEquals
(
"Only conditional converters may return null convertible types"
,
e
.
getMessage
());
}
catch
(
IllegalStateException
ex
)
{
assertEquals
(
"Only conditional converters may return null convertible types"
,
ex
.
getMessage
());
}
}
@Test
public
void
conditionalConversionForAllTypes
()
throws
Exception
{
public
void
conditionalConversionForAllTypes
()
{
GenericConversionService
conversionService
=
new
GenericConversionService
();
MyConditionalGenericConverter
converter
=
new
MyConditionalGenericConverter
();
conversionService
.
addConverter
(
converter
);
...
...
@@ -717,7 +717,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
convertOptimizeArray
()
throws
Exception
{
public
void
convertOptimizeArray
()
{
// SPR-9566
GenericConversionService
conversionService
=
new
DefaultConversionService
();
byte
[]
byteArray
=
new
byte
[]
{
1
,
2
,
3
};
...
...
@@ -726,7 +726,7 @@ public class GenericConversionServiceTests {
}
@Test
public
void
convertCannotOptimizeArray
()
throws
Exception
{
public
void
convertCannotOptimizeArray
()
{
GenericConversionService
conversionService
=
new
GenericConversionService
();
conversionService
.
addConverter
(
new
Converter
<
Byte
,
Byte
>()
{
@Override
...
...
@@ -766,6 +766,7 @@ public class GenericConversionServiceTests {
conversionService
.
convert
(
source
,
sourceType
,
targetType
);
}
@ExampleAnnotation
public
String
annotatedString
;
...
...
@@ -773,8 +774,7 @@ public class GenericConversionServiceTests {
public
static
@interface
ExampleAnnotation
{
}
private
static
class
MyConditionalConverter
implements
Converter
<
String
,
Color
>,
ConditionalConverter
{
private
static
class
MyConditionalConverter
implements
Converter
<
String
,
Color
>,
ConditionalConverter
{
private
int
matchAttempts
=
0
;
...
...
@@ -850,23 +850,26 @@ public class GenericConversionServiceTests {
}
interface
MyEnumInterface
{
String
getCode
();
}
public
static
enum
MyEnum
implements
MyEnumInterface
{
A
{
@Override
public
String
getCode
()
{
return
"1"
;
}
}
;
}
}
private
static
class
MyEnumInterfaceToStringConverter
<
T
extends
MyEnumInterface
>
implements
Converter
<
T
,
String
>
{
private
static
class
MyEnumInterfaceToStringConverter
<
T
extends
MyEnumInterface
>
implements
Converter
<
T
,
String
>
{
@Override
public
String
convert
(
T
source
)
{
return
source
.
getCode
();
}
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/support/JstlUtils.java
浏览文件 @
caa1218d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -141,6 +141,6 @@ public abstract class JstlUtils {
}
return
RequestContextUtils
.
getLocale
(
this
.
request
);
}
}
;
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java
浏览文件 @
caa1218d
...
...
@@ -20,14 +20,12 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.jsp.jstl.core.Config
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.context.MessageSource
;
import
org.springframework.context.MessageSourceResolvable
;
import
org.springframework.context.NoSuchMessageException
;
...
...
@@ -90,6 +88,7 @@ public class RequestContext {
*/
private
static
final
String
REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
=
"requestDataValueProcessor"
;
protected
static
final
boolean
jstlPresent
=
ClassUtils
.
isPresent
(
"javax.servlet.jsp.jstl.core.Config"
,
RequestContext
.
class
.
getClassLoader
());
...
...
@@ -113,6 +112,7 @@ public class RequestContext {
private
Map
<
String
,
Errors
>
errorsMap
;
/**
* Create a new RequestContext for the given request, using the request attributes for Errors retrieval. <p>This
* only works with InternalResourceViews, as Errors instances are part of the model and not normally exposed as
...
...
@@ -181,6 +181,7 @@ public class RequestContext {
protected
RequestContext
()
{
}
/**
* Initialize this context with the given request, using the given model attributes for Errors retrieval.
* <p>Delegates to {@code getFallbackLocale} and {@code getFallbackTheme} for determining the fallback
...
...
@@ -214,7 +215,8 @@ public class RequestContext {
if
(
localeResolver
!=
null
)
{
// Try LocaleResolver (we're within a DispatcherServlet request).
this
.
locale
=
localeResolver
.
resolveLocale
(
request
);
}
else
{
}
else
{
// No LocaleResolver available -> try fallback.
this
.
locale
=
getFallbackLocale
();
}
...
...
@@ -225,13 +227,10 @@ public class RequestContext {
this
.
urlPathHelper
=
new
UrlPathHelper
();
try
{
if
(
this
.
webApplicationContext
.
containsBean
(
REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
))
{
this
.
requestDataValueProcessor
=
this
.
webApplicationContext
.
getBean
(
REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
,
RequestDataValueProcessor
.
class
);
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
// Ignored
}
}
/**
...
...
@@ -269,6 +268,7 @@ public class RequestContext {
return
theme
;
}
/**
* Return the underlying HttpServletRequest. Only intended for cooperating classes in this package.
*/
...
...
@@ -702,7 +702,8 @@ public class RequestContext {
if
(
htmlEscape
&&
!(
errors
instanceof
EscapedErrors
))
{
errors
=
new
EscapedErrors
(
errors
);
put
=
true
;
}
else
if
(!
htmlEscape
&&
errors
instanceof
EscapedErrors
)
{
}
else
if
(!
htmlEscape
&&
errors
instanceof
EscapedErrors
)
{
errors
=
((
EscapedErrors
)
errors
).
getSource
();
put
=
true
;
}
...
...
@@ -720,7 +721,8 @@ public class RequestContext {
protected
Object
getModelObject
(
String
modelName
)
{
if
(
this
.
model
!=
null
)
{
return
this
.
model
.
get
(
modelName
);
}
else
{
}
else
{
return
this
.
request
.
getAttribute
(
modelName
);
}
}
...
...
@@ -746,9 +748,10 @@ public class RequestContext {
return
new
BindStatus
(
this
,
path
,
htmlEscape
);
}
/**
* Inner class that isolates the JSTL dependency.
Just called to resolve the fallback locale if the JSTL API is
* present.
* Inner class that isolates the JSTL dependency.
*
Just called to resolve the fallback locale if the JSTL API is
present.
*/
private
static
class
JstlLocaleResolver
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录