Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
140e8a8d
提交
140e8a8d
authored
11月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add StringBuilder-based variants of convertBytesToHex()
上级
390fe075
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
67 行增加
和
23 行删除
+67
-23
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+1
-1
User.java
h2/src/main/org/h2/engine/User.java
+4
-4
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+4
-1
JdbcXid.java
h2/src/main/org/h2/jdbcx/JdbcXid.java
+9
-2
TraceObject.java
h2/src/main/org/h2/message/TraceObject.java
+3
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+10
-9
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+28
-0
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+2
-1
ValueGeometry.java
h2/src/main/org/h2/value/ValueGeometry.java
+2
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+2
-1
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-1
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
140e8a8d
...
...
@@ -471,7 +471,7 @@ public class ScriptCommand extends ScriptBase {
if
(
len
<=
0
)
{
break
;
}
buff
.
append
(
StringUtils
.
convertBytesToHex
(
bytes
,
len
)
).
append
(
"')"
);
StringUtils
.
convertBytesToHex
(
buff
,
bytes
,
len
).
append
(
"')"
);
String
sql
=
buff
.
toString
();
add
(
sql
,
true
);
}
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
140e8a8d
...
...
@@ -163,10 +163,10 @@ public class User extends RightOwner {
StringUtils
.
quoteStringSQL
(
buff
,
comment
);
}
if
(
password
)
{
buff
.
append
(
" SALT '"
)
.
append
(
StringUtils
.
convertBytesToHex
(
salt
)
).
append
(
"' HASH '"
)
.
append
(
StringUtils
.
convertBytesToHex
(
passwordHash
)
).
buff
.
append
(
" SALT '"
)
;
StringUtils
.
convertBytesToHex
(
buff
,
salt
).
append
(
"' HASH '"
)
;
StringUtils
.
convertBytesToHex
(
buff
,
passwordHash
).
append
(
'\''
);
}
else
{
buff
.
append
(
" PASSWORD ''"
);
...
...
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
140e8a8d
...
...
@@ -514,7 +514,10 @@ public class FullText {
if
(
data
instanceof
UUID
)
{
return
"'"
+
data
.
toString
()
+
"'"
;
}
return
"'"
+
StringUtils
.
convertBytesToHex
((
byte
[])
data
)
+
"'"
;
byte
[]
bytes
=
(
byte
[])
data
;
StringBuilder
builder
=
new
StringBuilder
(
bytes
.
length
*
2
+
2
).
append
(
'\''
);
StringUtils
.
convertBytesToHex
(
builder
,
bytes
).
append
(
'\''
);
return
builder
.
toString
();
case
Types
.
CLOB
:
case
Types
.
JAVA_OBJECT
:
case
Types
.
OTHER
:
...
...
h2/src/main/org/h2/jdbcx/JdbcXid.java
浏览文件 @
140e8a8d
...
...
@@ -44,8 +44,15 @@ public class JdbcXid extends TraceObject implements Xid {
* INTERNAL
*/
public
static
String
toString
(
Xid
xid
)
{
return
PREFIX
+
'_'
+
xid
.
getFormatId
()
+
'_'
+
StringUtils
.
convertBytesToHex
(
xid
.
getBranchQualifier
())
+
'_'
+
StringUtils
.
convertBytesToHex
(
xid
.
getGlobalTransactionId
());
StringBuilder
builder
=
new
StringBuilder
()
.
append
(
PREFIX
)
.
append
(
'_'
)
.
append
(
xid
.
getFormatId
())
.
append
(
'_'
);
StringUtils
.
convertBytesToHex
(
builder
,
xid
.
getBranchQualifier
())
.
append
(
'_'
);
StringUtils
.
convertBytesToHex
(
builder
,
xid
.
getGlobalTransactionId
());
return
builder
.
toString
();
}
/**
...
...
h2/src/main/org/h2/message/TraceObject.java
浏览文件 @
140e8a8d
...
...
@@ -312,8 +312,9 @@ public class TraceObject {
if
(
x
==
null
)
{
return
"null"
;
}
return
"org.h2.util.StringUtils.convertHexToBytes(\""
+
StringUtils
.
convertBytesToHex
(
x
)
+
"\")"
;
StringBuilder
builder
=
new
StringBuilder
(
x
.
length
*
2
+
45
)
.
append
(
"org.h2.util.StringUtils.convertHexToBytes(\""
);
return
StringUtils
.
convertBytesToHex
(
builder
,
x
).
append
(
"\")"
).
toString
();
}
/**
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
140e8a8d
...
...
@@ -732,10 +732,11 @@ public class Recover extends Tool implements DataHandler {
try
{
for
(
int
seq
=
0
;;
seq
++)
{
int
l
=
IOUtils
.
readFully
(
in
,
block
,
block
.
length
);
String
x
=
StringUtils
.
convertBytesToHex
(
block
,
l
);
if
(
l
>
0
)
{
writer
.
println
(
"INSERT INTO INFORMATION_SCHEMA.LOB_BLOCKS "
+
"VALUES("
+
lobId
+
", "
+
seq
+
", '"
+
x
+
"');"
);
writer
.
print
(
"INSERT INTO INFORMATION_SCHEMA.LOB_BLOCKS "
+
"VALUES("
+
lobId
+
", "
+
seq
+
", '"
);
writer
.
print
(
StringUtils
.
convertBytesToHex
(
block
,
l
));
writer
.
println
(
"');"
);
}
if
(
l
!=
len
)
{
break
;
...
...
@@ -1446,12 +1447,12 @@ public class Recover extends Tool implements DataHandler {
byte
[]
salt
=
MathUtils
.
secureRandomBytes
(
Constants
.
SALT_LEN
);
byte
[]
passwordHash
=
SHA256
.
getHashWithSalt
(
userPasswordHash
,
salt
);
StringBuilder
buff
=
new
StringBuilder
()
;
buff
.
append
(
"SALT '"
).
append
(
StringUtils
.
convertBytesToHex
(
salt
)).
append
(
"' HASH '"
).
append
(
StringUtils
.
convertBytesToHex
(
passwordHash
)).
append
(
'\''
);
StringBuilder
buff
=
new
StringBuilder
()
.
append
(
"SALT '"
);
StringUtils
.
convertBytesToHex
(
buff
,
salt
)
.
append
(
"' HASH '"
);
StringUtils
.
convertBytesToHex
(
buff
,
passwordHash
)
.
append
(
'\''
);
byte
[]
replacement
=
buff
.
toString
().
getBytes
();
System
.
arraycopy
(
replacement
,
0
,
s
.
getBytes
(),
saltIndex
,
replacement
.
length
);
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
140e8a8d
...
...
@@ -1057,6 +1057,34 @@ public class StringUtils {
return
new
String
(
buff
);
}
/**
* Convert a byte array to a hex encoded string and appends it to a specified string builder.
*
* @param builder string builder to append to
* @param value the byte array
* @return the hex encoded string
*/
public
static
StringBuilder
convertBytesToHex
(
StringBuilder
builder
,
byte
[]
value
)
{
return
convertBytesToHex
(
builder
,
value
,
value
.
length
);
}
/**
* Convert a byte array to a hex encoded string and appends it to a specified string builder.
*
* @param builder string builder to append to
* @param value the byte array
* @param len the number of bytes to encode
* @return the hex encoded string
*/
public
static
StringBuilder
convertBytesToHex
(
StringBuilder
builder
,
byte
[]
value
,
int
len
)
{
char
[]
hex
=
HEX
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
c
=
value
[
i
]
&
0xff
;
builder
.
append
(
hex
[
c
>>>
4
]).
append
(
hex
[
c
&
0xf
]);
}
return
builder
;
}
/**
* Check if this string is a decimal number.
*
...
...
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
140e8a8d
...
...
@@ -80,7 +80,8 @@ public class ValueBytes extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
return
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())).
append
(
'\''
);
builder
.
append
(
"X'"
);
return
StringUtils
.
convertBytesToHex
(
builder
,
getBytesNoCopy
()).
append
(
'\''
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueGeometry.java
浏览文件 @
140e8a8d
...
...
@@ -270,7 +270,8 @@ public class ValueGeometry extends Value {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
// Using bytes is faster than converting to EWKT.
return
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytesNoCopy
())).
append
(
"'::Geometry"
);
builder
.
append
(
"X'"
);
return
StringUtils
.
convertBytesToHex
(
builder
,
getBytesNoCopy
()).
append
(
"'::Geometry"
);
}
@Override
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
140e8a8d
...
...
@@ -574,7 +574,8 @@ public class ValueLob extends Value {
if
(
valueType
==
Value
.
CLOB
)
{
StringUtils
.
quoteStringSQL
(
builder
,
getString
());
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
builder
.
append
(
"X'"
);
StringUtils
.
convertBytesToHex
(
builder
,
getBytes
()).
append
(
'\''
);
}
return
builder
;
}
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
140e8a8d
...
...
@@ -465,7 +465,8 @@ public class ValueLobDb extends Value {
if
(
valueType
==
Value
.
CLOB
)
{
StringUtils
.
quoteStringSQL
(
builder
,
getString
());
}
else
{
builder
.
append
(
"X'"
).
append
(
StringUtils
.
convertBytesToHex
(
getBytes
())).
append
(
'\''
);
builder
.
append
(
"X'"
);
StringUtils
.
convertBytesToHex
(
builder
,
getBytes
()).
append
(
'\''
);
}
return
builder
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论