Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
7d062df9
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 搜索 >>
提交
7d062df9
编写于
2月 21, 2017
作者:
S
stonio
提交者:
Stephane Nicoll
2月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use String#isEmpty()
Closes gh-1335
上级
c85f063d
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
45 addition
and
43 deletion
+45
-43
spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java
.../main/java/org/springframework/beans/PropertyMatches.java
+3
-3
spring-core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java
...work/core/convert/support/StringToCharacterConverter.java
+2
-2
spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
...rk/core/convert/support/StringToEnumConverterFactory.java
+2
-2
spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java
.../core/convert/support/StringToNumberConverterFactory.java
+2
-2
spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java
.../core/io/support/PathMatchingResourcePatternResolver.java
+2
-2
spring-core/src/main/java/org/springframework/util/Base64Utils.java
...e/src/main/java/org/springframework/util/Base64Utils.java
+2
-2
spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java
...src/main/java/org/springframework/util/MimeTypeUtils.java
+1
-1
spring-core/src/main/java/org/springframework/util/StringUtils.java
...e/src/main/java/org/springframework/util/StringUtils.java
+2
-2
spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java
...ava/org/springframework/util/xml/AbstractStaxHandler.java
+3
-3
spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
...work/expression/common/TemplateAwareExpressionParser.java
+3
-3
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java
...ion/support/AbstractNamedValueMethodArgumentResolver.java
+1
-1
spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java
.../annotation/AbstractNamedValueMethodArgumentResolver.java
+2
-2
spring-web/src/main/java/org/springframework/web/util/patterns/PathPattern.java
...va/org/springframework/web/util/patterns/PathPattern.java
+10
-9
spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java
.../web/multipart/commons/CommonsMultipartResolverTests.java
+3
-3
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
...method/annotation/AbstractNamedValueArgumentResolver.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolver.java
.../method/annotation/RequestPartMethodArgumentResolver.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java
...amework/web/servlet/mvc/method/annotation/SseEmitter.java
+3
-2
未找到文件。
spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -150,10 +150,10 @@ public abstract class PropertyMatches {
* @return the distance value
*/
private
static
int
calculateStringDistance
(
String
s1
,
String
s2
)
{
if
(
s1
.
length
()
==
0
)
{
if
(
s1
.
isEmpty
()
)
{
return
s2
.
length
();
}
if
(
s2
.
length
()
==
0
)
{
if
(
s2
.
isEmpty
()
)
{
return
s1
.
length
();
}
int
d
[][]
=
new
int
[
s1
.
length
()
+
1
][
s2
.
length
()
+
1
];
...
...
spring-core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -28,7 +28,7 @@ final class StringToCharacterConverter implements Converter<String, Character> {
@Override
public
Character
convert
(
String
source
)
{
if
(
source
.
length
()
==
0
)
{
if
(
source
.
isEmpty
()
)
{
return
null
;
}
if
(
source
.
length
()
>
1
)
{
...
...
spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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 StringToEnumConverterFactory implements ConverterFactory<String, Enu
@Override
public
T
convert
(
String
source
)
{
if
(
source
.
length
()
==
0
)
{
if
(
source
.
isEmpty
()
)
{
// It's an empty enum identifier: reset the enum value to null.
return
null
;
}
...
...
spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -56,7 +56,7 @@ final class StringToNumberConverterFactory implements ConverterFactory<String, N
@Override
public
T
convert
(
String
source
)
{
if
(
source
.
length
()
==
0
)
{
if
(
source
.
isEmpty
()
)
{
return
null
;
}
return
NumberUtils
.
parseNumber
(
source
,
this
.
targetType
);
...
...
spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -809,7 +809,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
public
PatternVirtualFileVisitor
(
String
rootPath
,
String
subPattern
,
PathMatcher
pathMatcher
)
{
this
.
subPattern
=
subPattern
;
this
.
pathMatcher
=
pathMatcher
;
this
.
rootPath
=
(
rootPath
.
length
()
==
0
||
rootPath
.
endsWith
(
"/"
)
?
rootPath
:
rootPath
+
"/"
);
this
.
rootPath
=
(
rootPath
.
isEmpty
()
||
rootPath
.
endsWith
(
"/"
)
?
rootPath
:
rootPath
+
"/"
);
}
@Override
...
...
spring-core/src/main/java/org/springframework/util/Base64Utils.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -120,7 +120,7 @@ public abstract class Base64Utils {
if
(
src
==
null
)
{
return
null
;
}
if
(
src
.
length
()
==
0
)
{
if
(
src
.
isEmpty
()
)
{
return
new
byte
[
0
];
}
return
decode
(
src
.
getBytes
(
DEFAULT_CHARSET
));
...
...
spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java
浏览文件 @
7d062df9
...
...
@@ -180,7 +180,7 @@ public abstract class MimeTypeUtils {
int
index
=
mimeType
.
indexOf
(
';'
);
String
fullType
=
(
index
>=
0
?
mimeType
.
substring
(
0
,
index
)
:
mimeType
).
trim
();
if
(
fullType
.
length
()
==
0
)
{
if
(
fullType
.
isEmpty
()
)
{
throw
new
InvalidMimeTypeException
(
mimeType
,
"'mimeType' must not be empty"
);
}
...
...
spring-core/src/main/java/org/springframework/util/StringUtils.java
浏览文件 @
7d062df9
...
...
@@ -373,7 +373,7 @@ public abstract class StringUtils {
* @param sub string to search for. Return 0 if this is {@code null}.
*/
public
static
int
countOccurrencesOf
(
String
str
,
String
sub
)
{
if
(
str
==
null
||
sub
==
null
||
str
.
length
()
==
0
||
sub
.
length
()
==
0
)
{
if
(
!
hasLength
(
str
)
||
!
hasLength
(
sub
)
)
{
return
0
;
}
int
count
=
0
;
...
...
@@ -515,7 +515,7 @@ public abstract class StringUtils {
}
private
static
String
changeFirstCharacterCase
(
String
str
,
boolean
capitalize
)
{
if
(
str
==
null
||
str
.
length
()
==
0
)
{
if
(
!
hasLength
(
str
)
)
{
return
str
;
}
else
{
...
...
spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -223,8 +223,8 @@ abstract class AbstractStaxHandler implements ContentHandler, LexicalHandler {
protected
boolean
isNamespaceDeclaration
(
QName
qName
)
{
String
prefix
=
qName
.
getPrefix
();
String
localPart
=
qName
.
getLocalPart
();
return
(
XMLConstants
.
XMLNS_ATTRIBUTE
.
equals
(
localPart
)
&&
prefix
.
length
()
==
0
)
||
(
XMLConstants
.
XMLNS_ATTRIBUTE
.
equals
(
prefix
)
&&
localPart
.
length
()
!=
0
);
return
(
XMLConstants
.
XMLNS_ATTRIBUTE
.
equals
(
localPart
)
&&
prefix
.
isEmpty
()
)
||
(
XMLConstants
.
XMLNS_ATTRIBUTE
.
equals
(
prefix
)
&&
!
localPart
.
isEmpty
()
);
}
...
...
spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -79,7 +79,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
private
Expression
parseTemplate
(
String
expressionString
,
ParserContext
context
)
throws
ParseException
{
if
(
expressionString
.
length
()
==
0
)
{
if
(
expressionString
.
isEmpty
()
)
{
return
new
LiteralExpression
(
""
);
}
Expression
[]
expressions
=
parseExpressions
(
expressionString
,
context
);
...
...
@@ -145,7 +145,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
suffixIndex
);
expr
=
expr
.
trim
();
if
(
expr
.
length
()
==
0
)
{
if
(
expr
.
isEmpty
()
)
{
throw
new
ParseException
(
expressionString
,
prefixIndex
,
"No expression defined within delimiter '"
+
prefix
+
suffix
+
"' at character "
+
prefixIndex
);
...
...
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java
浏览文件 @
7d062df9
...
...
@@ -142,7 +142,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
*/
private
NamedValueInfo
updateNamedValueInfo
(
MethodParameter
parameter
,
NamedValueInfo
info
)
{
String
name
=
info
.
name
;
if
(
info
.
name
.
length
()
==
0
)
{
if
(
info
.
name
.
isEmpty
()
)
{
name
=
parameter
.
getParameterName
();
if
(
name
==
null
)
{
throw
new
IllegalArgumentException
(
"Name for argument type ["
+
parameter
.
getParameterType
().
getName
()
+
...
...
spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -160,7 +160,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
*/
private
NamedValueInfo
updateNamedValueInfo
(
MethodParameter
parameter
,
NamedValueInfo
info
)
{
String
name
=
info
.
name
;
if
(
info
.
name
.
length
()
==
0
)
{
if
(
info
.
name
.
isEmpty
()
)
{
name
=
parameter
.
getParameterName
();
if
(
name
==
null
)
{
throw
new
IllegalArgumentException
(
...
...
spring-web/src/main/java/org/springframework/web/util/patterns/PathPattern.java
浏览文件 @
7d062df9
...
...
@@ -21,6 +21,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
org.springframework.util.PathMatcher
;
import
static
org
.
springframework
.
util
.
StringUtils
.
hasLength
;
/**
* Represents a parsed path pattern. Includes a chain of path elements
...
...
@@ -132,9 +133,9 @@ public class PathPattern implements Comparable<PathPattern> {
*/
public
boolean
matches
(
String
path
)
{
if
(
head
==
null
)
{
return
(
path
==
null
)
||
(
path
.
length
()
==
0
);
return
!
hasLength
(
path
);
}
else
if
(
path
==
null
||
path
.
length
()
==
0
)
{
else
if
(
!
hasLength
(
path
)
)
{
if
(
head
instanceof
WildcardTheRestPathElement
||
head
instanceof
CaptureTheRestPathElement
)
{
path
=
""
;
// Will allow CaptureTheRest to bind the variable to empty
}
...
...
@@ -152,9 +153,9 @@ public class PathPattern implements Comparable<PathPattern> {
*/
public
boolean
matchStart
(
String
path
)
{
if
(
head
==
null
)
{
return
(
path
==
null
||
path
.
length
()
==
0
);
return
!
hasLength
(
path
);
}
else
if
(
path
==
null
||
path
.
length
()
==
0
)
{
else
if
(
!
hasLength
(
path
)
)
{
return
true
;
}
MatchingContext
matchingContext
=
new
MatchingContext
(
path
,
false
);
...
...
@@ -172,7 +173,7 @@ public class PathPattern implements Comparable<PathPattern> {
return
matchingContext
.
getExtractedVariables
();
}
else
{
if
(
path
==
null
||
path
.
length
()
==
0
)
{
if
(
!
hasLength
(
path
)
)
{
return
NO_VARIABLES_MAP
;
}
else
{
...
...
@@ -434,15 +435,15 @@ public class PathPattern implements Comparable<PathPattern> {
*/
public
String
combine
(
String
pattern2string
)
{
// If one of them is empty the result is the other. If both empty the result is ""
if
(
patternString
==
null
||
patternString
.
length
()
==
0
)
{
if
(
pattern2string
==
null
||
pattern2string
.
length
()
==
0
)
{
if
(
!
hasLength
(
patternString
)
)
{
if
(
!
hasLength
(
pattern2string
)
)
{
return
""
;
}
else
{
return
pattern2string
;
}
}
else
if
(
pattern2string
==
null
||
pattern2string
.
length
()
==
0
)
{
else
if
(
!
hasLength
(
pattern2string
)
)
{
return
patternString
;
}
...
...
@@ -504,4 +505,4 @@ public class PathPattern implements Comparable<PathPattern> {
}
}
}
\ No newline at end of file
}
spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -258,13 +258,13 @@ public class CommonsMultipartResolverTests {
binder
.
setBindEmptyMultipartFiles
(
false
);
String
firstBound
=
mtb2
.
getField2
();
binder
.
bind
(
request
);
assert
True
(
mtb2
.
getField2
().
length
()
>
0
);
assert
False
(
mtb2
.
getField2
().
isEmpty
()
);
assertEquals
(
firstBound
,
mtb2
.
getField2
());
request
=
resolver
.
resolveMultipart
(
originalRequest
);
binder
.
setBindEmptyMultipartFiles
(
true
);
binder
.
bind
(
request
);
assertTrue
(
mtb2
.
getField2
().
length
()
==
0
);
assertTrue
(
mtb2
.
getField2
().
isEmpty
()
);
}
@Test
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -132,7 +132,7 @@ public abstract class AbstractNamedValueArgumentResolver implements HandlerMetho
*/
private
NamedValueInfo
updateNamedValueInfo
(
MethodParameter
parameter
,
NamedValueInfo
info
)
{
String
name
=
info
.
name
;
if
(
info
.
name
.
length
()
==
0
)
{
if
(
info
.
name
.
isEmpty
()
)
{
name
=
parameter
.
getParameterName
();
if
(
name
==
null
)
{
String
type
=
parameter
.
getNestedParameterType
().
getName
();
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolver.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -159,7 +159,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageConverterM
private
String
getPartName
(
MethodParameter
methodParam
,
RequestPart
requestPart
)
{
String
partName
=
(
requestPart
!=
null
?
requestPart
.
name
()
:
""
);
if
(
partName
.
length
()
==
0
)
{
if
(
partName
.
isEmpty
()
)
{
partName
=
methodParam
.
getParameterName
();
if
(
partName
==
null
)
{
throw
new
IllegalArgumentException
(
"Request part name for argument type ["
+
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java
浏览文件 @
7d062df9
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -25,6 +25,7 @@ import java.util.Set;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.util.StringUtils
;
/**
* A specialization of {@link ResponseBodyEmitter} for sending
...
...
@@ -234,7 +235,7 @@ public class SseEmitter extends ResponseBodyEmitter {
@Override
public
Set
<
DataWithMediaType
>
build
()
{
if
(
(
this
.
sb
==
null
||
this
.
sb
.
length
()
==
0
)
&&
this
.
dataToSend
.
isEmpty
())
{
if
(
!
StringUtils
.
hasLength
(
this
.
sb
)
&&
this
.
dataToSend
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
append
(
"\n"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录