Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
c62d4cb4
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,发现更多精彩内容 >>
提交
c62d4cb4
编写于
11月 08, 2008
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generified StringUtils, and replaced StringBuffer usage with StringBuilder
上级
ba425941
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
14 deletion
+15
-14
org.springframework.core/src/main/java/org/springframework/util/StringUtils.java
...e/src/main/java/org/springframework/util/StringUtils.java
+15
-14
未找到文件。
org.springframework.core/src/main/java/org/springframework/util/StringUtils.java
浏览文件 @
c62d4cb4
...
@@ -48,6 +48,7 @@ import java.util.TreeSet;
...
@@ -48,6 +48,7 @@ import java.util.TreeSet;
* @author Keith Donald
* @author Keith Donald
* @author Rob Harrop
* @author Rob Harrop
* @author Rick Evans
* @author Rick Evans
* @author Arjen Poutsma
* @since 16 April 2001
* @since 16 April 2001
* @see org.apache.commons.lang.StringUtils
* @see org.apache.commons.lang.StringUtils
*/
*/
...
@@ -598,7 +599,7 @@ public abstract class StringUtils {
...
@@ -598,7 +599,7 @@ public abstract class StringUtils {
}
}
String
[]
pathArray
=
delimitedListToStringArray
(
pathToUse
,
FOLDER_SEPARATOR
);
String
[]
pathArray
=
delimitedListToStringArray
(
pathToUse
,
FOLDER_SEPARATOR
);
List
pathElements
=
new
LinkedList
();
List
<
String
>
pathElements
=
new
LinkedList
<
String
>
();
int
tops
=
0
;
int
tops
=
0
;
for
(
int
i
=
pathArray
.
length
-
1
;
i
>=
0
;
i
--)
{
for
(
int
i
=
pathArray
.
length
-
1
;
i
>=
0
;
i
--)
{
...
@@ -736,7 +737,7 @@ public abstract class StringUtils {
...
@@ -736,7 +737,7 @@ public abstract class StringUtils {
if
(
ObjectUtils
.
isEmpty
(
array2
))
{
if
(
ObjectUtils
.
isEmpty
(
array2
))
{
return
array1
;
return
array1
;
}
}
List
result
=
new
ArrayList
();
List
<
String
>
result
=
new
ArrayList
<
String
>
();
result
.
addAll
(
Arrays
.
asList
(
array1
));
result
.
addAll
(
Arrays
.
asList
(
array1
));
for
(
int
i
=
0
;
i
<
array2
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
array2
.
length
;
i
++)
{
String
str
=
array2
[
i
];
String
str
=
array2
[
i
];
...
@@ -767,11 +768,11 @@ public abstract class StringUtils {
...
@@ -767,11 +768,11 @@ public abstract class StringUtils {
* @return the String array (<code>null</code> if the passed-in
* @return the String array (<code>null</code> if the passed-in
* Collection was <code>null</code>)
* Collection was <code>null</code>)
*/
*/
public
static
String
[]
toStringArray
(
Collection
collection
)
{
public
static
String
[]
toStringArray
(
Collection
<
String
>
collection
)
{
if
(
collection
==
null
)
{
if
(
collection
==
null
)
{
return
null
;
return
null
;
}
}
return
(
String
[])
collection
.
toArray
(
new
String
[
collection
.
size
()]);
return
collection
.
toArray
(
new
String
[
collection
.
size
()]);
}
}
/**
/**
...
@@ -781,12 +782,12 @@ public abstract class StringUtils {
...
@@ -781,12 +782,12 @@ public abstract class StringUtils {
* @return the String array (<code>null</code> if the passed-in
* @return the String array (<code>null</code> if the passed-in
* Enumeration was <code>null</code>)
* Enumeration was <code>null</code>)
*/
*/
public
static
String
[]
toStringArray
(
Enumeration
enumeration
)
{
public
static
String
[]
toStringArray
(
Enumeration
<
String
>
enumeration
)
{
if
(
enumeration
==
null
)
{
if
(
enumeration
==
null
)
{
return
null
;
return
null
;
}
}
List
list
=
Collections
.
list
(
enumeration
);
List
<
String
>
list
=
Collections
.
list
(
enumeration
);
return
(
String
[])
list
.
toArray
(
new
String
[
list
.
size
()]);
return
list
.
toArray
(
new
String
[
list
.
size
()]);
}
}
/**
/**
...
@@ -817,7 +818,7 @@ public abstract class StringUtils {
...
@@ -817,7 +818,7 @@ public abstract class StringUtils {
if
(
ObjectUtils
.
isEmpty
(
array
))
{
if
(
ObjectUtils
.
isEmpty
(
array
))
{
return
array
;
return
array
;
}
}
Set
set
=
new
TreeSet
();
Set
<
String
>
set
=
new
TreeSet
<
String
>
();
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
set
.
add
(
array
[
i
]);
set
.
add
(
array
[
i
]);
}
}
...
@@ -941,7 +942,7 @@ public abstract class StringUtils {
...
@@ -941,7 +942,7 @@ public abstract class StringUtils {
return
null
;
return
null
;
}
}
StringTokenizer
st
=
new
StringTokenizer
(
str
,
delimiters
);
StringTokenizer
st
=
new
StringTokenizer
(
str
,
delimiters
);
List
tokens
=
new
ArrayList
();
List
<
String
>
tokens
=
new
ArrayList
<
String
>
();
while
(
st
.
hasMoreTokens
())
{
while
(
st
.
hasMoreTokens
())
{
String
token
=
st
.
nextToken
();
String
token
=
st
.
nextToken
();
if
(
trimTokens
)
{
if
(
trimTokens
)
{
...
@@ -989,7 +990,7 @@ public abstract class StringUtils {
...
@@ -989,7 +990,7 @@ public abstract class StringUtils {
if
(
delimiter
==
null
)
{
if
(
delimiter
==
null
)
{
return
new
String
[]
{
str
};
return
new
String
[]
{
str
};
}
}
List
result
=
new
ArrayList
();
List
<
String
>
result
=
new
ArrayList
<
String
>
();
if
(
""
.
equals
(
delimiter
))
{
if
(
""
.
equals
(
delimiter
))
{
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
result
.
add
(
deleteAny
(
str
.
substring
(
i
,
i
+
1
),
charsToDelete
));
result
.
add
(
deleteAny
(
str
.
substring
(
i
,
i
+
1
),
charsToDelete
));
...
@@ -1025,8 +1026,8 @@ public abstract class StringUtils {
...
@@ -1025,8 +1026,8 @@ public abstract class StringUtils {
* @param str the input String
* @param str the input String
* @return a Set of String entries in the list
* @return a Set of String entries in the list
*/
*/
public
static
Set
commaDelimitedListToSet
(
String
str
)
{
public
static
Set
<
String
>
commaDelimitedListToSet
(
String
str
)
{
Set
set
=
new
TreeSet
();
Set
<
String
>
set
=
new
TreeSet
<
String
>
();
String
[]
tokens
=
commaDelimitedListToStringArray
(
str
);
String
[]
tokens
=
commaDelimitedListToStringArray
(
str
);
for
(
int
i
=
0
;
i
<
tokens
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
tokens
.
length
;
i
++)
{
set
.
add
(
tokens
[
i
]);
set
.
add
(
tokens
[
i
]);
...
@@ -1047,7 +1048,7 @@ public abstract class StringUtils {
...
@@ -1047,7 +1048,7 @@ public abstract class StringUtils {
if
(
CollectionUtils
.
isEmpty
(
coll
))
{
if
(
CollectionUtils
.
isEmpty
(
coll
))
{
return
""
;
return
""
;
}
}
StringBu
ffer
sb
=
new
StringBuff
er
();
StringBu
ilder
sb
=
new
StringBuild
er
();
Iterator
it
=
coll
.
iterator
();
Iterator
it
=
coll
.
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
sb
.
append
(
prefix
).
append
(
it
.
next
()).
append
(
suffix
);
sb
.
append
(
prefix
).
append
(
it
.
next
()).
append
(
suffix
);
...
@@ -1090,7 +1091,7 @@ public abstract class StringUtils {
...
@@ -1090,7 +1091,7 @@ public abstract class StringUtils {
if
(
ObjectUtils
.
isEmpty
(
arr
))
{
if
(
ObjectUtils
.
isEmpty
(
arr
))
{
return
""
;
return
""
;
}
}
StringBu
ffer
sb
=
new
StringBuff
er
();
StringBu
ilder
sb
=
new
StringBuild
er
();
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
if
(
i
>
0
)
{
if
(
i
>
0
)
{
sb
.
append
(
delim
);
sb
.
append
(
delim
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录