Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
chenpeng_fei
spring-framework
提交
540d8792
S
spring-framework
项目概览
chenpeng_fei
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
540d8792
编写于
2月 27, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed javadoc warnings and revised FastByteArrayOutputStream code style
上级
45a80fa3
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
241 addition
and
232 deletion
+241
-232
spring-core/src/main/java/org/springframework/util/DigestUtils.java
...e/src/main/java/org/springframework/util/DigestUtils.java
+17
-11
spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java
...a/org/springframework/util/FastByteArrayOutputStream.java
+180
-184
spring-core/src/main/java/org/springframework/util/ResizableByteArrayOutputStream.java
.../springframework/util/ResizableByteArrayOutputStream.java
+7
-2
spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java
.../springframework/util/UpdateMessageDigestInputStream.java
+16
-17
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java
.../jdbc/datasource/init/ScriptStatementFailedException.java
+10
-10
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/HtmlEscapingAwareTag.java
...pringframework/web/servlet/tags/HtmlEscapingAwareTag.java
+11
-8
未找到文件。
spring-core/src/main/java/org/springframework/util/DigestUtils.java
浏览文件 @
540d8792
...
...
@@ -28,6 +28,7 @@ import java.security.NoSuchAlgorithmException;
* more comprehensive suite of digest utilities.
*
* @author Arjen Poutsma
* @author Craig Andrews
* @since 3.0
* @see org.apache.commons.codec.digest.DigestUtils
*/
...
...
@@ -38,6 +39,7 @@ public abstract class DigestUtils {
private
static
final
char
[]
HEX_CHARS
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
/**
* Calculate the MD5 digest of the given bytes.
* @param bytes the bytes to calculate the digest over
...
...
@@ -53,7 +55,7 @@ public abstract class DigestUtils {
* @return the digest
* @since 4.2
*/
public
static
byte
[]
md5Digest
(
InputStream
inputStream
)
throws
IOException
{
public
static
byte
[]
md5Digest
(
InputStream
inputStream
)
throws
IOException
{
return
digest
(
MD5_ALGORITHM_NAME
,
inputStream
);
}
...
...
@@ -74,7 +76,7 @@ public abstract class DigestUtils {
* @return a hexadecimal digest string
* @since 4.2
*/
public
static
String
md5DigestAsHex
(
InputStream
inputStream
)
throws
IOException
{
public
static
String
md5DigestAsHex
(
InputStream
inputStream
)
throws
IOException
{
return
digestAsHexString
(
MD5_ALGORITHM_NAME
,
inputStream
);
}
...
...
@@ -97,13 +99,14 @@ public abstract class DigestUtils {
* @return the given string builder
* @since 4.2
*/
public
static
StringBuilder
appendMd5DigestAsHex
(
InputStream
inputStream
,
StringBuilder
builder
)
throws
IOException
{
public
static
StringBuilder
appendMd5DigestAsHex
(
InputStream
inputStream
,
StringBuilder
builder
)
throws
IOException
{
return
appendDigestAsHex
(
MD5_ALGORITHM_NAME
,
inputStream
,
builder
);
}
/**
* Create
s a new {@link MessageDigest} with the given algorithm. Necessary
* because {@code MessageDigest} is not thread-safe.
* Create
a new {@link MessageDigest} with the given algorithm.
*
Necessary
because {@code MessageDigest} is not thread-safe.
*/
private
static
MessageDigest
getDigest
(
String
algorithm
)
{
try
{
...
...
@@ -118,12 +121,13 @@ public abstract class DigestUtils {
return
getDigest
(
algorithm
).
digest
(
bytes
);
}
private
static
byte
[]
digest
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
private
static
byte
[]
digest
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
MessageDigest
messageDigest
=
getDigest
(
algorithm
);
if
(
inputStream
instanceof
UpdateMessageDigestInputStream
){
if
(
inputStream
instanceof
UpdateMessageDigestInputStream
){
((
UpdateMessageDigestInputStream
)
inputStream
).
updateMessageDigest
(
messageDigest
);
return
messageDigest
.
digest
();
}
else
{
}
else
{
return
messageDigest
.
digest
(
StreamUtils
.
copyToByteArray
(
inputStream
));
}
}
...
...
@@ -133,7 +137,7 @@ public abstract class DigestUtils {
return
new
String
(
hexDigest
);
}
private
static
String
digestAsHexString
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
private
static
String
digestAsHexString
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
char
[]
hexDigest
=
digestAsHexChars
(
algorithm
,
inputStream
);
return
new
String
(
hexDigest
);
}
...
...
@@ -143,7 +147,9 @@ public abstract class DigestUtils {
return
builder
.
append
(
hexDigest
);
}
private
static
StringBuilder
appendDigestAsHex
(
String
algorithm
,
InputStream
inputStream
,
StringBuilder
builder
)
throws
IOException
{
private
static
StringBuilder
appendDigestAsHex
(
String
algorithm
,
InputStream
inputStream
,
StringBuilder
builder
)
throws
IOException
{
char
[]
hexDigest
=
digestAsHexChars
(
algorithm
,
inputStream
);
return
builder
.
append
(
hexDigest
);
}
...
...
@@ -153,7 +159,7 @@ public abstract class DigestUtils {
return
encodeHex
(
digest
);
}
private
static
char
[]
digestAsHexChars
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
private
static
char
[]
digestAsHexChars
(
String
algorithm
,
InputStream
inputStream
)
throws
IOException
{
byte
[]
digest
=
digest
(
algorithm
,
inputStream
);
return
encodeHex
(
digest
);
}
...
...
spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java
浏览文件 @
540d8792
此差异已折叠。
点击以展开。
spring-core/src/main/java/org/springframework/util/ResizableByteArrayOutputStream.java
浏览文件 @
540d8792
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -27,6 +27,11 @@ import java.io.ByteArrayOutputStream;
* <li>has a higher initial capacity (256) by default</li>
* </ul>
*
* <p>As of 4.2, this class has been superseded by {@link FastByteArrayOutputStream}
* for Spring's internal use where no assignability to {@link ByteArrayOutputStream}
* is needed (since {@link FastByteArrayOutputStream} is more efficient with buffer
* resize management but doesn't extend the standard {@link ByteArrayOutputStream}).
*
* @author Brian Clozel
* @author Juergen Hoeller
* @since 4.0.3
...
...
@@ -38,7 +43,7 @@ public class ResizableByteArrayOutputStream extends ByteArrayOutputStream {
/**
* Create a new <code>ResizableByteArrayOutputStream</code>
* with the default initial capacity of
128
bytes.
* with the default initial capacity of
256
bytes.
*/
public
ResizableByteArrayOutputStream
()
{
super
(
DEFAULT_INITIAL_CAPACITY
);
...
...
spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java
浏览文件 @
540d8792
...
...
@@ -27,38 +27,37 @@ import java.security.MessageDigest;
* @author Craig Andrews
* @since 4.2
*/
public
abstract
class
UpdateMessageDigestInputStream
extends
InputStream
{
abstract
class
UpdateMessageDigestInputStream
extends
InputStream
{
/**
* Update the message digest with the rest of the bytes in this stream
*
* <p>Using this method is more optimized since it avoids creating new byte arrays for each call.</p>
*
* Update the message digest with the rest of the bytes in this stream.
* <p>Using this method is more optimized since it avoids creating new
* byte arrays for each call.
* @param messageDigest The message digest to update
* @throws IOException
* @throws IOException
when propagated from {@link #read()}
*/
public
void
updateMessageDigest
(
MessageDigest
messageDigest
)
throws
IOException
{
public
void
updateMessageDigest
(
MessageDigest
messageDigest
)
throws
IOException
{
int
data
;
while
((
data
=
read
())
!=
-
1
){
messageDigest
.
update
((
byte
)
data
);
while
((
data
=
read
())
!=
-
1
){
messageDigest
.
update
((
byte
)
data
);
}
}
/**
* Update the message digest with the next len bytes in this stream
*
* <p>Using this method is more optimized since it avoids creating new byte arrays for each call.</p>
*
* Update the message digest with the next len bytes in this stream.
* <p>Using this method is more optimized since it avoids creating new
* byte arrays for each call.
* @param messageDigest The message digest to update
* @param len how many bytes to read from this stream and use to update the message digest
* @throws IOException
* @throws IOException
when propagated from {@link #read()}
*/
public
void
updateMessageDigest
(
MessageDigest
messageDigest
,
int
len
)
throws
IOException
{
public
void
updateMessageDigest
(
MessageDigest
messageDigest
,
int
len
)
throws
IOException
{
int
data
;
int
bytesRead
=
0
;
while
(
bytesRead
<
len
&&
(
data
=
read
())
!=
-
1
){
messageDigest
.
update
((
byte
)
data
);
while
(
bytesRead
<
len
&&
(
data
=
read
())
!=
-
1
){
messageDigest
.
update
((
byte
)
data
);
bytesRead
++;
}
}
}
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java
浏览文件 @
540d8792
...
...
@@ -31,30 +31,30 @@ public class ScriptStatementFailedException extends ScriptException {
/**
* Construct a new {@code ScriptStatementFailedException}.
* @param st
atemen
t the actual SQL statement that failed
* @param st
atemen
tNumber the statement number in the SQL script (i.e.,
* @param st
m
t the actual SQL statement that failed
* @param st
m
tNumber the statement number in the SQL script (i.e.,
* the nth statement present in the resource)
* @param resource the resource from which the SQL statement was read
* @param cause the underlying cause of the failure
*/
public
ScriptStatementFailedException
(
String
st
atement
,
int
statemen
tNumber
,
EncodedResource
resource
,
Throwable
cause
)
{
super
(
buildErrorMessage
(
st
atement
,
statemen
tNumber
,
resource
),
cause
);
public
ScriptStatementFailedException
(
String
st
mt
,
int
stm
tNumber
,
EncodedResource
resource
,
Throwable
cause
)
{
super
(
buildErrorMessage
(
st
mt
,
stm
tNumber
,
resource
),
cause
);
}
/**
* Build an error message for an SQL script execution failure,
based on
* the supplied arguments.
* @param st
atemen
t the actual SQL statement that failed
* @param st
atemen
tNumber the statement number in the SQL script (i.e.,
* Build an error message for an SQL script execution failure,
*
based on
the supplied arguments.
* @param st
m
t the actual SQL statement that failed
* @param st
m
tNumber the statement number in the SQL script (i.e.,
* the n<sup>th</sup> statement present in the resource)
* @param encodedResource the resource from which the SQL statement was read
* @return an error message suitable for an exception's <em>detail message</em>
* or logging
* @since 4.2
*/
public
static
String
buildErrorMessage
(
String
st
atement
,
int
statemen
tNumber
,
EncodedResource
encodedResource
)
{
public
static
String
buildErrorMessage
(
String
st
mt
,
int
stm
tNumber
,
EncodedResource
encodedResource
)
{
return
String
.
format
(
"Failed to execute SQL script statement #%s of %s: %s"
,
st
atementNumber
,
encodedResource
,
statemen
t
);
st
mtNumber
,
encodedResource
,
stm
t
);
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/tags/HtmlEscapingAwareTag.java
浏览文件 @
540d8792
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -29,6 +29,7 @@ import org.springframework.web.util.HtmlUtils;
* context-param in {@code web.xml}) is used.
*
* @author Juergen Hoeller
* @author Brian Clozel
* @since 1.1
* @see #setHtmlEscape
* @see HtmlEscapeTag
...
...
@@ -76,24 +77,26 @@ public abstract class HtmlEscapingAwareTag extends RequestContextAwareTag {
}
/**
* Return the applicable default for the use of response encoding with HTML escape for this tag.
* Return the applicable default for the use of response encoding with
* HTML escaping for this tag.
* <p>The default implementation checks the RequestContext's setting,
* falling back to {@code false} in case of no explicit default given.
* @see #getRequestContext()
* @since 4.1.2
* @see #getRequestContext()
*/
protected
boolean
isResponseEncodedHtmlEscape
()
{
return
getRequestContext
().
isResponseEncodedHtmlEscape
();
}
/**
* HTML encodes the given string, only if the htmlEscape setting is enabled.
* The response encoding will be taken into account if the responseEncodedHtmlEscape setting is enabled.
* @param content
* @return
* HTML-encodes the given String, only if the "htmlEscape" setting is enabled.
* <p>The response encoding will be taken into account if the
* "responseEncodedHtmlEscape" setting is enabled as well.
* @param content the String to escape
* @return the escaped String
* @since 4.1.2
* @see #isHtmlEscape()
* @see #isResponseEncodedHtmlEscape()
* @since 4.1.2
*/
protected
String
htmlEscape
(
String
content
)
{
String
out
=
content
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录