Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e619227f
提交
e619227f
authored
11月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass StringBuilder to StringUtils.indent()
上级
140e8a8d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
35 行增加
和
33 行删除
+35
-33
Select.java
h2/src/main/org/h2/command/dml/Select.java
+1
-1
ConditionExists.java
h2/src/main/org/h2/expression/ConditionExists.java
+1
-2
ConditionInSelect.java
h2/src/main/org/h2/expression/ConditionInSelect.java
+2
-1
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+3
-3
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-1
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+26
-25
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
e619227f
...
@@ -1336,7 +1336,7 @@ public class Select extends Query {
...
@@ -1336,7 +1336,7 @@ public class Select extends Query {
for
(
int
i
=
0
;
i
<
visibleColumnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
visibleColumnCount
;
i
++)
{
buff
.
appendExceptFirst
(
","
);
buff
.
appendExceptFirst
(
","
);
buff
.
append
(
'\n'
);
buff
.
append
(
'\n'
);
buff
.
append
(
StringUtils
.
indent
(
exprList
[
i
].
getSQL
(),
4
,
false
)
);
StringUtils
.
indent
(
buff
.
builder
(),
exprList
[
i
].
getSQL
(),
4
,
false
);
}
}
buff
.
append
(
"\nFROM "
);
buff
.
append
(
"\nFROM "
);
TableFilter
filter
=
topTableFilter
;
TableFilter
filter
=
topTableFilter
;
...
...
h2/src/main/org/h2/expression/ConditionExists.java
浏览文件 @
e619227f
...
@@ -43,8 +43,7 @@ public class ConditionExists extends Condition {
...
@@ -43,8 +43,7 @@ public class ConditionExists extends Condition {
@Override
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
builder
.
append
(
"EXISTS(\n"
);
builder
.
append
(
"EXISTS(\n"
);
builder
.
append
(
StringUtils
.
indent
(
query
.
getPlanSQL
(),
4
,
false
));
return
StringUtils
.
indent
(
builder
,
query
.
getPlanSQL
(),
4
,
false
).
append
(
')'
);
return
builder
.
append
(
')'
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/expression/ConditionInSelect.java
浏览文件 @
e619227f
...
@@ -143,7 +143,8 @@ public class ConditionInSelect extends Condition {
...
@@ -143,7 +143,8 @@ public class ConditionInSelect extends Condition {
append
(
" ANY"
);
append
(
" ANY"
);
}
}
}
}
return
builder
.
append
(
"(\n"
).
append
(
StringUtils
.
indent
(
query
.
getPlanSQL
(),
4
,
false
)).
append
(
"))"
);
builder
.
append
(
"(\n"
);
return
StringUtils
.
indent
(
builder
,
query
.
getPlanSQL
(),
4
,
false
).
append
(
"))"
);
}
}
@Override
@Override
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
e619227f
...
@@ -774,7 +774,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -774,7 +774,7 @@ public class TableFilter implements ColumnResolver {
if
(
enclose
)
{
if
(
enclose
)
{
buff
.
append
(
"(\n"
);
buff
.
append
(
"(\n"
);
}
}
buff
.
append
(
StringUtils
.
indent
(
nested
,
4
,
false
)
);
StringUtils
.
indent
(
buff
,
nested
,
4
,
false
);
if
(
enclose
)
{
if
(
enclose
)
{
buff
.
append
(
')'
);
buff
.
append
(
')'
);
}
}
...
@@ -842,7 +842,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -842,7 +842,7 @@ public class TableFilter implements ColumnResolver {
if
(
plan
.
indexOf
(
'\n'
)
>=
0
)
{
if
(
plan
.
indexOf
(
'\n'
)
>=
0
)
{
plan
+=
"\n"
;
plan
+=
"\n"
;
}
}
buff
.
append
(
StringUtils
.
indent
(
"/* "
+
plan
+
" */"
,
4
,
false
)
);
StringUtils
.
indent
(
buff
,
"/* "
+
plan
+
" */"
,
4
,
false
);
}
}
if
(
isJoin
)
{
if
(
isJoin
)
{
buff
.
append
(
"\n ON "
);
buff
.
append
(
"\n ON "
);
...
@@ -858,7 +858,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -858,7 +858,7 @@ public class TableFilter implements ColumnResolver {
buff
.
append
(
'\n'
);
buff
.
append
(
'\n'
);
String
condition
=
StringUtils
.
unEnclose
(
filterCondition
.
getSQL
());
String
condition
=
StringUtils
.
unEnclose
(
filterCondition
.
getSQL
());
condition
=
"/* WHERE "
+
StringUtils
.
quoteRemarkSQL
(
condition
)
+
"\n*/"
;
condition
=
"/* WHERE "
+
StringUtils
.
quoteRemarkSQL
(
condition
)
+
"\n*/"
;
buff
.
append
(
StringUtils
.
indent
(
condition
,
4
,
false
)
);
StringUtils
.
indent
(
buff
,
condition
,
4
,
false
);
}
}
if
(
scanCount
>
0
)
{
if
(
scanCount
>
0
)
{
buff
.
append
(
"\n /* scanCount: "
).
append
(
scanCount
).
append
(
" */"
);
buff
.
append
(
"\n /* scanCount: "
).
append
(
scanCount
).
append
(
" */"
);
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
e619227f
...
@@ -468,7 +468,8 @@ public class TableView extends Table {
...
@@ -468,7 +468,8 @@ public class TableView extends Table {
@Override
@Override
public
String
getSQL
()
{
public
String
getSQL
()
{
if
(
isTemporary
()
&&
querySQL
!=
null
)
{
if
(
isTemporary
()
&&
querySQL
!=
null
)
{
return
"(\n"
+
StringUtils
.
indent
(
querySQL
)
+
")"
;
StringBuilder
builder
=
new
StringBuilder
(
querySQL
.
length
()
+
16
).
append
(
"(\n"
);
return
StringUtils
.
indent
(
builder
,
querySQL
,
4
,
true
).
append
(
')'
).
toString
();
}
}
return
super
.
getSQL
();
return
super
.
getSQL
();
}
}
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
e619227f
...
@@ -560,49 +560,49 @@ public class StringUtils {
...
@@ -560,49 +560,49 @@ public class StringUtils {
*/
*/
public
static
String
xmlNode
(
String
name
,
String
attributes
,
public
static
String
xmlNode
(
String
name
,
String
attributes
,
String
content
,
boolean
indent
)
{
String
content
,
boolean
indent
)
{
String
start
=
attributes
==
null
?
name
:
name
+
attributes
;
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
'<'
).
append
(
name
);
if
(
attributes
!=
null
)
{
builder
.
append
(
attributes
);
}
if
(
content
==
null
)
{
if
(
content
==
null
)
{
return
"<"
+
start
+
"/>\n"
;
builder
.
append
(
"/>\n"
);
return
builder
.
toString
();
}
}
builder
.
append
(
'>'
);
if
(
indent
&&
content
.
indexOf
(
'\n'
)
>=
0
)
{
if
(
indent
&&
content
.
indexOf
(
'\n'
)
>=
0
)
{
content
=
"\n"
+
indent
(
content
);
builder
.
append
(
'\n'
);
indent
(
builder
,
content
,
4
,
true
);
}
else
{
builder
.
append
(
content
);
}
}
return
"<"
+
start
+
">"
+
content
+
"</"
+
name
+
">\n"
;
builder
.
append
(
"</"
).
append
(
name
).
append
(
">\n"
);
}
return
builder
.
toString
();
/**
* Indents a string with 4 spaces.
*
* @param s the string
* @return the indented string
*/
public
static
String
indent
(
String
s
)
{
return
indent
(
s
,
4
,
true
);
}
}
/**
/**
* Indents a string with spaces.
* Indents a string with spaces
and appends it to a specified builder
.
*
*
* @param builder string builder to append to
* @param s the string
* @param s the string
* @param spaces the number of spaces
* @param spaces the number of spaces
* @param newline append a newline if there is none
* @param newline append a newline if there is none
* @return the
indented string
* @return the
specified string builder
*/
*/
public
static
String
indent
(
String
s
,
int
spaces
,
boolean
newline
)
{
public
static
StringBuilder
indent
(
StringBuilder
builder
,
String
s
,
int
spaces
,
boolean
newline
)
{
StringBuilder
buff
=
new
StringBuilder
(
s
.
length
()
+
spaces
);
for
(
int
i
=
0
,
length
=
s
.
length
();
i
<
length
;)
{
for
(
int
i
=
0
;
i
<
s
.
length
();)
{
for
(
int
j
=
0
;
j
<
spaces
;
j
++)
{
for
(
int
j
=
0
;
j
<
spaces
;
j
++)
{
bu
ff
.
append
(
' '
);
bu
ilder
.
append
(
' '
);
}
}
int
n
=
s
.
indexOf
(
'\n'
,
i
);
int
n
=
s
.
indexOf
(
'\n'
,
i
);
n
=
n
<
0
?
s
.
length
()
:
n
+
1
;
n
=
n
<
0
?
length
:
n
+
1
;
bu
ff
.
append
(
s
,
i
,
n
);
bu
ilder
.
append
(
s
,
i
,
n
);
i
=
n
;
i
=
n
;
}
}
if
(
newline
&&
!
s
.
endsWith
(
"\n"
))
{
if
(
newline
&&
!
s
.
endsWith
(
"\n"
))
{
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
}
}
return
bu
ff
.
toString
()
;
return
bu
ilder
;
}
}
/**
/**
...
@@ -625,7 +625,8 @@ public class StringUtils {
...
@@ -625,7 +625,8 @@ public class StringUtils {
// must have a space at the beginning and at the end,
// must have a space at the beginning and at the end,
// otherwise the data must not contain '-' as the first/last character
// otherwise the data must not contain '-' as the first/last character
if
(
data
.
indexOf
(
'\n'
)
>=
0
)
{
if
(
data
.
indexOf
(
'\n'
)
>=
0
)
{
return
"<!--\n"
+
indent
(
data
)
+
"-->\n"
;
StringBuilder
builder
=
new
StringBuilder
(
data
.
length
()
+
18
).
append
(
"<!--\n"
);
return
indent
(
builder
,
data
,
4
,
true
).
append
(
"-->\n"
).
toString
();
}
}
return
"<!-- "
+
data
+
" -->\n"
;
return
"<!-- "
+
data
+
" -->\n"
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论