Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e2f5284c
提交
e2f5284c
authored
2月 27, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Limit line length to 80 characters
上级
81985ba2
全部展开
显示空白字符变更
内嵌
并排
正在显示
41 个修改的文件
包含
762 行增加
和
411 行删除
+762
-411
HtmlConverter.java
h2/src/tools/org/h2/build/indexer/HtmlConverter.java
+55
-34
Indexer.java
h2/src/tools/org/h2/build/indexer/Indexer.java
+12
-7
CacheLIRS.java
h2/src/tools/org/h2/dev/cache/CacheLIRS.java
+11
-5
FilePathZip2.java
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
+8
-4
FileShell.java
h2/src/tools/org/h2/dev/fs/FileShell.java
+44
-22
FtpClient.java
h2/src/tools/org/h2/dev/ftp/FtpClient.java
+8
-4
FtpControl.java
h2/src/tools/org/h2/dev/ftp/server/FtpControl.java
+16
-7
FtpServer.java
h2/src/tools/org/h2/dev/ftp/server/FtpServer.java
+19
-9
PgTcpRedirect.java
h2/src/tools/org/h2/dev/net/PgTcpRedirect.java
+10
-5
SecureKeyStoreBuilder.java
h2/src/tools/org/h2/dev/security/SecureKeyStoreBuilder.java
+17
-7
InPlaceStableMergeSort.java
h2/src/tools/org/h2/dev/sort/InPlaceStableMergeSort.java
+2
-1
ArrayUtils.java
h2/src/tools/org/h2/dev/util/ArrayUtils.java
+4
-2
FileViewer.java
h2/src/tools/org/h2/dev/util/FileViewer.java
+4
-2
Migrate.java
h2/src/tools/org/h2/dev/util/Migrate.java
+12
-6
Db.java
h2/src/tools/org/h2/jaqu/Db.java
+31
-24
DbInspector.java
h2/src/tools/org/h2/jaqu/DbInspector.java
+29
-21
DbUpgrader.java
h2/src/tools/org/h2/jaqu/DbUpgrader.java
+10
-6
DbVersion.java
h2/src/tools/org/h2/jaqu/DbVersion.java
+3
-2
Define.java
h2/src/tools/org/h2/jaqu/Define.java
+8
-5
ModelUtils.java
h2/src/tools/org/h2/jaqu/ModelUtils.java
+13
-8
Query.java
h2/src/tools/org/h2/jaqu/Query.java
+21
-15
SQLDialect.java
h2/src/tools/org/h2/jaqu/SQLDialect.java
+11
-10
SQLStatement.java
h2/src/tools/org/h2/jaqu/SQLStatement.java
+2
-1
SelectTable.java
h2/src/tools/org/h2/jaqu/SelectTable.java
+4
-3
TableDefinition.java
h2/src/tools/org/h2/jaqu/TableDefinition.java
+2
-1
TableInspector.java
h2/src/tools/org/h2/jaqu/TableInspector.java
+106
-73
ValidationRemark.java
h2/src/tools/org/h2/jaqu/ValidationRemark.java
+22
-12
ClassReader.java
h2/src/tools/org/h2/jaqu/bytecode/ClassReader.java
+55
-29
ClassUtils.java
h2/src/tools/org/h2/jaqu/util/ClassUtils.java
+7
-5
GenerateModels.java
h2/src/tools/org/h2/jaqu/util/GenerateModels.java
+17
-11
ClassObj.java
h2/src/tools/org/h2/java/ClassObj.java
+18
-5
Expr.java
h2/src/tools/org/h2/java/Expr.java
+36
-1
JavaParser.java
h2/src/tools/org/h2/java/JavaParser.java
+100
-58
Statement.java
h2/src/tools/org/h2/java/Statement.java
+30
-1
Test.java
h2/src/tools/org/h2/java/Test.java
+1
-0
Object.java
h2/src/tools/org/h2/java/lang/Object.java
+2
-0
String.java
h2/src/tools/org/h2/java/lang/String.java
+1
-0
StringBuilder.java
h2/src/tools/org/h2/java/lang/StringBuilder.java
+1
-0
System.java
h2/src/tools/org/h2/java/lang/System.java
+4
-2
Railroads.java
h2/src/tools/org/h2/jcr/Railroads.java
+4
-2
FunctionsMySQL.java
h2/src/tools/org/h2/mode/FunctionsMySQL.java
+2
-1
没有找到文件。
h2/src/tools/org/h2/build/indexer/HtmlConverter.java
浏览文件 @
e2f5284c
...
@@ -14,41 +14,62 @@ import java.util.HashMap;
...
@@ -14,41 +14,62 @@ import java.util.HashMap;
*/
*/
public
class
HtmlConverter
{
public
class
HtmlConverter
{
private
static
final
HashMap
<
String
,
Character
>
CHAR_MAP
=
new
HashMap
<
String
,
Character
>();
private
static
final
HashMap
<
String
,
Character
>
CHAR_MAP
=
private
static
final
HashMap
<
Character
,
String
>
CODE_MAP
=
new
HashMap
<
Character
,
String
>();
new
HashMap
<
String
,
Character
>();
private
static
final
HashMap
<
Character
,
String
>
CODE_MAP
=
new
HashMap
<
Character
,
String
>();
private
static
final
String
[]
CHARS
=
{
"quot:34"
,
"amp:38"
,
"lt:60"
,
"gt:62"
,
"nbsp:160"
,
"iexcl:161"
,
"cent:162"
,
private
static
final
String
[]
CHARS
=
{
"quot:34"
,
"amp:38"
,
"lt:60"
,
"pound:163"
,
"curren:164"
,
"yen:165"
,
"brvbar:166"
,
"sect:167"
,
"uml:168"
,
"copy:169"
,
"ordf:170"
,
"gt:62"
,
"nbsp:160"
,
"iexcl:161"
,
"cent:162"
,
"pound:163"
,
"laquo:171"
,
"not:172"
,
"shy:173"
,
"reg:174"
,
"macr:175"
,
"deg:176"
,
"plusmn:177"
,
"sup2:178"
,
"sup3:179"
,
"curren:164"
,
"yen:165"
,
"brvbar:166"
,
"sect:167"
,
"uml:168"
,
"acute:180"
,
"micro:181"
,
"para:182"
,
"middot:183"
,
"cedil:184"
,
"sup1:185"
,
"ordm:186"
,
"raquo:187"
,
"copy:169"
,
"ordf:170"
,
"laquo:171"
,
"not:172"
,
"shy:173"
,
"frac14:188"
,
"frac12:189"
,
"frac34:190"
,
"iquest:191"
,
"Agrave:192"
,
"Aacute:193"
,
"Acirc:194"
,
"reg:174"
,
"macr:175"
,
"deg:176"
,
"plusmn:177"
,
"sup2:178"
,
"Atilde:195"
,
"Auml:196"
,
"Aring:197"
,
"AElig:198"
,
"Ccedil:199"
,
"Egrave:200"
,
"Eacute:201"
,
"Ecirc:202"
,
"sup3:179"
,
"acute:180"
,
"micro:181"
,
"para:182"
,
"middot:183"
,
"Euml:203"
,
"Igrave:204"
,
"Iacute:205"
,
"Icirc:206"
,
"Iuml:207"
,
"ETH:208"
,
"Ntilde:209"
,
"Ograve:210"
,
"cedil:184"
,
"sup1:185"
,
"ordm:186"
,
"raquo:187"
,
"frac14:188"
,
"Oacute:211"
,
"Ocirc:212"
,
"Otilde:213"
,
"Ouml:214"
,
"times:215"
,
"Oslash:216"
,
"Ugrave:217"
,
"Uacute:218"
,
"frac12:189"
,
"frac34:190"
,
"iquest:191"
,
"Agrave:192"
,
"Ucirc:219"
,
"Uuml:220"
,
"Yacute:221"
,
"THORN:222"
,
"szlig:223"
,
"agrave:224"
,
"aacute:225"
,
"acirc:226"
,
"Aacute:193"
,
"Acirc:194"
,
"Atilde:195"
,
"Auml:196"
,
"Aring:197"
,
"atilde:227"
,
"auml:228"
,
"aring:229"
,
"aelig:230"
,
"ccedil:231"
,
"egrave:232"
,
"eacute:233"
,
"ecirc:234"
,
"AElig:198"
,
"Ccedil:199"
,
"Egrave:200"
,
"Eacute:201"
,
"Ecirc:202"
,
"euml:235"
,
"igrave:236"
,
"iacute:237"
,
"icirc:238"
,
"iuml:239"
,
"eth:240"
,
"ntilde:241"
,
"ograve:242"
,
"Euml:203"
,
"Igrave:204"
,
"Iacute:205"
,
"Icirc:206"
,
"Iuml:207"
,
"oacute:243"
,
"ocirc:244"
,
"otilde:245"
,
"ouml:246"
,
"divide:247"
,
"oslash:248"
,
"ugrave:249"
,
"ETH:208"
,
"Ntilde:209"
,
"Ograve:210"
,
"Oacute:211"
,
"Ocirc:212"
,
"uacute:250"
,
"ucirc:251"
,
"uuml:252"
,
"yacute:253"
,
"thorn:254"
,
"yuml:255"
,
"Alpha:913"
,
"alpha:945"
,
"Otilde:213"
,
"Ouml:214"
,
"times:215"
,
"Oslash:216"
,
"Ugrave:217"
,
"Beta:914"
,
"beta:946"
,
"Gamma:915"
,
"gamma:947"
,
"Delta:916"
,
"delta:948"
,
"Epsilon:917"
,
"epsilon:949"
,
"Uacute:218"
,
"Ucirc:219"
,
"Uuml:220"
,
"Yacute:221"
,
"THORN:222"
,
"Zeta:918"
,
"zeta:950"
,
"Eta:919"
,
"eta:951"
,
"Theta:920"
,
"theta:952"
,
"Iota:921"
,
"iota:953"
,
"szlig:223"
,
"agrave:224"
,
"aacute:225"
,
"acirc:226"
,
"atilde:227"
,
"Kappa:922"
,
"kappa:954"
,
"Lambda:923"
,
"lambda:955"
,
"Mu:924"
,
"mu:956"
,
"Nu:925"
,
"nu:957"
,
"Xi:926"
,
"auml:228"
,
"aring:229"
,
"aelig:230"
,
"ccedil:231"
,
"egrave:232"
,
"xi:958"
,
"Omicron:927"
,
"omicron:959"
,
"Pi:928"
,
"pi:960"
,
"Rho:929"
,
"rho:961"
,
"Sigma:931"
,
"eacute:233"
,
"ecirc:234"
,
"euml:235"
,
"igrave:236"
,
"iacute:237"
,
"sigmaf:962"
,
"sigma:963"
,
"Tau:932"
,
"tau:964"
,
"Upsilon:933"
,
"upsilon:965"
,
"Phi:934"
,
"phi:966"
,
"icirc:238"
,
"iuml:239"
,
"eth:240"
,
"ntilde:241"
,
"ograve:242"
,
"Chi:935"
,
"chi:967"
,
"Psi:936"
,
"psi:968"
,
"Omega:937"
,
"omega:969"
,
"thetasym:977"
,
"upsih:978"
,
"oacute:243"
,
"ocirc:244"
,
"otilde:245"
,
"ouml:246"
,
"divide:247"
,
"piv:982"
,
"forall:8704"
,
"part:8706"
,
"exist:8707"
,
"empty:8709"
,
"nabla:8711"
,
"isin:8712"
,
"notin:8713"
,
"oslash:248"
,
"ugrave:249"
,
"uacute:250"
,
"ucirc:251"
,
"uuml:252"
,
"ni:8715"
,
"prod:8719"
,
"sum:8721"
,
"minus:8722"
,
"lowast:8727"
,
"radic:8730"
,
"prop:8733"
,
"infin:8734"
,
"yacute:253"
,
"thorn:254"
,
"yuml:255"
,
"Alpha:913"
,
"alpha:945"
,
"ang:8736"
,
"and:8743"
,
"or:8744"
,
"cap:8745"
,
"cup:8746"
,
"int:8747"
,
"there4:8756"
,
"sim:8764"
,
"Beta:914"
,
"beta:946"
,
"Gamma:915"
,
"gamma:947"
,
"Delta:916"
,
"cong:8773"
,
"asymp:8776"
,
"ne:8800"
,
"equiv:8801"
,
"le:8804"
,
"ge:8805"
,
"sub:8834"
,
"sup:8835"
,
"delta:948"
,
"Epsilon:917"
,
"epsilon:949"
,
"Zeta:918"
,
"zeta:950"
,
"nsub:8836"
,
"sube:8838"
,
"supe:8839"
,
"oplus:8853"
,
"otimes:8855"
,
"perp:8869"
,
"sdot:8901"
,
"loz:9674"
,
"Eta:919"
,
"eta:951"
,
"Theta:920"
,
"theta:952"
,
"Iota:921"
,
"lceil:8968"
,
"rceil:8969"
,
"lfloor:8970"
,
"rfloor:8971"
,
"lang:9001"
,
"rang:9002"
,
"larr:8592"
,
"iota:953"
,
"Kappa:922"
,
"kappa:954"
,
"Lambda:923"
,
"lambda:955"
,
"uarr:8593"
,
"rarr:8594"
,
"darr:8595"
,
"harr:8596"
,
"crarr:8629"
,
"lArr:8656"
,
"uArr:8657"
,
"rArr:8658"
,
"Mu:924"
,
"mu:956"
,
"Nu:925"
,
"nu:957"
,
"Xi:926"
,
"xi:958"
,
"dArr:8659"
,
"hArr:8660"
,
"bull:8226"
,
"prime:8242"
,
"oline:8254"
,
"frasl:8260"
,
"weierp:8472"
,
"Omicron:927"
,
"omicron:959"
,
"Pi:928"
,
"pi:960"
,
"Rho:929"
,
"image:8465"
,
"real:8476"
,
"trade:8482"
,
"euro:8364"
,
"alefsym:8501"
,
"spades:9824"
,
"clubs:9827"
,
"rho:961"
,
"Sigma:931"
,
"sigmaf:962"
,
"sigma:963"
,
"Tau:932"
,
"hearts:9829"
,
"diams:9830"
,
"ensp:8194"
,
"emsp:8195"
,
"thinsp:8201"
,
"zwnj:8204"
,
"zwj:8205"
,
"lrm:8206"
,
"tau:964"
,
"Upsilon:933"
,
"upsilon:965"
,
"Phi:934"
,
"phi:966"
,
"rlm:8207"
,
"ndash:8211"
,
"mdash:8212"
,
"lsquo:8216"
,
"rsquo:8217"
,
"sbquo:8218"
,
"ldquo:8220"
,
"Chi:935"
,
"chi:967"
,
"Psi:936"
,
"psi:968"
,
"Omega:937"
,
"rdquo:8221"
,
"bdquo:8222"
,
"dagger:8224"
,
"Dagger:8225"
,
"hellip:8230"
,
"permil:8240"
,
"lsaquo:8249"
,
"omega:969"
,
"thetasym:977"
,
"upsih:978"
,
"piv:982"
,
"forall:8704"
,
"rsaquo:8250"
};
"part:8706"
,
"exist:8707"
,
"empty:8709"
,
"nabla:8711"
,
"isin:8712"
,
"notin:8713"
,
"ni:8715"
,
"prod:8719"
,
"sum:8721"
,
"minus:8722"
,
"lowast:8727"
,
"radic:8730"
,
"prop:8733"
,
"infin:8734"
,
"ang:8736"
,
"and:8743"
,
"or:8744"
,
"cap:8745"
,
"cup:8746"
,
"int:8747"
,
"there4:8756"
,
"sim:8764"
,
"cong:8773"
,
"asymp:8776"
,
"ne:8800"
,
"equiv:8801"
,
"le:8804"
,
"ge:8805"
,
"sub:8834"
,
"sup:8835"
,
"nsub:8836"
,
"sube:8838"
,
"supe:8839"
,
"oplus:8853"
,
"otimes:8855"
,
"perp:8869"
,
"sdot:8901"
,
"loz:9674"
,
"lceil:8968"
,
"rceil:8969"
,
"lfloor:8970"
,
"rfloor:8971"
,
"lang:9001"
,
"rang:9002"
,
"larr:8592"
,
"uarr:8593"
,
"rarr:8594"
,
"darr:8595"
,
"harr:8596"
,
"crarr:8629"
,
"lArr:8656"
,
"uArr:8657"
,
"rArr:8658"
,
"dArr:8659"
,
"hArr:8660"
,
"bull:8226"
,
"prime:8242"
,
"oline:8254"
,
"frasl:8260"
,
"weierp:8472"
,
"image:8465"
,
"real:8476"
,
"trade:8482"
,
"euro:8364"
,
"alefsym:8501"
,
"spades:9824"
,
"clubs:9827"
,
"hearts:9829"
,
"diams:9830"
,
"ensp:8194"
,
"emsp:8195"
,
"thinsp:8201"
,
"zwnj:8204"
,
"zwj:8205"
,
"lrm:8206"
,
"rlm:8207"
,
"ndash:8211"
,
"mdash:8212"
,
"lsquo:8216"
,
"rsquo:8217"
,
"sbquo:8218"
,
"ldquo:8220"
,
"rdquo:8221"
,
"bdquo:8222"
,
"dagger:8224"
,
"Dagger:8225"
,
"hellip:8230"
,
"permil:8240"
,
"lsaquo:8249"
,
"rsaquo:8250"
};
private
HtmlConverter
()
{
private
HtmlConverter
()
{
// utility class
// utility class
...
...
h2/src/tools/org/h2/build/indexer/Indexer.java
浏览文件 @
e2f5284c
...
@@ -73,16 +73,20 @@ public class Indexer {
...
@@ -73,16 +73,20 @@ public class Indexer {
File
file
=
new
File
(
dir
);
File
file
=
new
File
(
dir
);
setNoIndex
(
"index.html"
,
"html/header.html"
,
"html/search.html"
,
setNoIndex
(
"index.html"
,
"html/header.html"
,
"html/search.html"
,
"html/frame.html"
,
"html/fragments.html"
,
"html/frame.html"
,
"html/fragments.html"
,
"html/sourceError.html"
,
"html/source.html"
,
"html/mainWeb.html"
,
"html/sourceError.html"
,
"html/source.html"
,
"javadoc/index.html"
,
"javadoc/classes.html"
,
"javadoc/allclasses-frame.html"
,
"html/mainWeb.html"
,
"javadoc/index.html"
,
"javadoc/allclasses-noframe.html"
,
"javadoc/constant-values.html"
,
"javadoc/overview-frame.html"
,
"javadoc/classes.html"
,
"javadoc/allclasses-frame.html"
,
"javadoc/allclasses-noframe.html"
,
"javadoc/constant-values.html"
,
"javadoc/overview-frame.html"
,
"javadoc/overview-summary.html"
,
"javadoc/serialized-form.html"
);
"javadoc/overview-summary.html"
,
"javadoc/serialized-form.html"
);
output
=
new
PrintWriter
(
new
FileWriter
(
destDir
+
"/index.js"
));
output
=
new
PrintWriter
(
new
FileWriter
(
destDir
+
"/index.js"
));
readPages
(
""
,
file
,
0
);
readPages
(
""
,
file
,
0
);
output
.
println
(
"var pages=new Array();"
);
output
.
println
(
"var pages=new Array();"
);
output
.
println
(
"var ref=new Array();"
);
output
.
println
(
"var ref=new Array();"
);
output
.
println
(
"var ignored='';"
);
output
.
println
(
"var ignored='';"
);
output
.
println
(
"function Page(title, file) { this.title=title; this.file=file; }"
);
output
.
println
(
"function Page(title, file) { "
);
output
.
println
(
" this.title=title; this.file=file;"
);
output
.
println
(
"}"
);
output
.
println
(
"function load() {"
);
output
.
println
(
"function load() {"
);
sortWords
();
sortWords
();
removeOverflowRelations
();
removeOverflowRelations
();
...
@@ -174,8 +178,8 @@ public class Indexer {
...
@@ -174,8 +178,8 @@ public class Indexer {
private
void
listPages
()
{
private
void
listPages
()
{
for
(
Page
p
:
pages
)
{
for
(
Page
p
:
pages
)
{
output
.
println
(
"pages["
+
p
.
id
+
"]=new Page('"
+
convertUTF
(
p
.
title
)
+
"', '"
+
p
.
fileName
output
.
println
(
"pages["
+
p
.
id
+
"]=new Page('"
+
"');"
);
+
convertUTF
(
p
.
title
)
+
"', '"
+
p
.
fileName
+
"');"
);
}
}
}
}
...
@@ -333,7 +337,8 @@ public class Indexer {
...
@@ -333,7 +337,8 @@ public class Indexer {
}
}
// this list of constants needs to be the same in search.js
// this list of constants needs to be the same in search.js
// (char) 160: nbsp
// (char) 160: nbsp
StringTokenizer
t
=
new
StringTokenizer
(
text
,
" \t\r\n\"'.,:;!&/\\?%@`[]{}()+-=<>|*^~#$"
+
(
char
)
160
,
false
);
StringTokenizer
t
=
new
StringTokenizer
(
text
,
" \t\r\n\"'.,:;!&/\\?%@`[]{}()+-=<>|*^~#$"
+
(
char
)
160
,
false
);
while
(
t
.
hasMoreTokens
())
{
while
(
t
.
hasMoreTokens
())
{
String
token
=
t
.
nextToken
();
String
token
=
t
.
nextToken
();
if
(
token
.
length
()
<
MIN_WORD_SIZE
)
{
if
(
token
.
length
()
<
MIN_WORD_SIZE
)
{
...
...
h2/src/tools/org/h2/dev/cache/CacheLIRS.java
浏览文件 @
e2f5284c
...
@@ -84,11 +84,14 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
...
@@ -84,11 +84,14 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
* of the stack before the current item is moved
* of the stack before the current item is moved
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
CacheLIRS
(
long
maxMemory
,
int
averageMemory
,
int
segmentCount
,
int
stackMoveDistance
)
{
public
CacheLIRS
(
long
maxMemory
,
int
averageMemory
,
int
segmentCount
,
int
stackMoveDistance
)
{
setMaxMemory
(
maxMemory
);
setMaxMemory
(
maxMemory
);
setAverageMemory
(
averageMemory
);
setAverageMemory
(
averageMemory
);
if
(
Integer
.
bitCount
(
segmentCount
)
!=
1
)
{
if
(
Integer
.
bitCount
(
segmentCount
)
!=
1
)
{
throw
new
IllegalArgumentException
(
"The segment count must be a power of 2, is "
+
segmentCount
);
throw
new
IllegalArgumentException
(
"The segment count must be a power of 2, is "
+
segmentCount
);
}
}
this
.
segmentCount
=
segmentCount
;
this
.
segmentCount
=
segmentCount
;
this
.
segmentMask
=
segmentCount
-
1
;
this
.
segmentMask
=
segmentCount
-
1
;
...
@@ -513,7 +516,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
...
@@ -513,7 +516,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
* @param stackMoveDistance the number of other entries to be moved to
* @param stackMoveDistance the number of other entries to be moved to
* the top of the stack before moving an entry to the top
* the top of the stack before moving an entry to the top
*/
*/
Segment
(
CacheLIRS
<
K
,
V
>
cache
,
long
maxMemory
,
int
averageMemory
,
int
stackMoveDistance
)
{
Segment
(
CacheLIRS
<
K
,
V
>
cache
,
long
maxMemory
,
int
averageMemory
,
int
stackMoveDistance
)
{
this
.
cache
=
cache
;
this
.
cache
=
cache
;
setMaxMemory
(
maxMemory
);
setMaxMemory
(
maxMemory
);
setAverageMemory
(
averageMemory
);
setAverageMemory
(
averageMemory
);
...
@@ -589,7 +593,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
...
@@ -589,7 +593,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
}
}
if
(
e
.
isHot
())
{
if
(
e
.
isHot
())
{
if
(
e
!=
stack
.
stackNext
)
{
if
(
e
!=
stack
.
stackNext
)
{
if
(
stackMoveDistance
==
0
||
stackMoveCounter
-
e
.
topMove
>
stackMoveDistance
)
{
if
(
stackMoveDistance
==
0
||
stackMoveCounter
-
e
.
topMove
>
stackMoveDistance
)
{
access
(
key
,
hash
);
access
(
key
,
hash
);
}
}
}
}
...
@@ -612,7 +617,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
...
@@ -612,7 +617,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
}
}
if
(
e
.
isHot
())
{
if
(
e
.
isHot
())
{
if
(
e
!=
stack
.
stackNext
)
{
if
(
e
!=
stack
.
stackNext
)
{
if
(
stackMoveDistance
==
0
||
stackMoveCounter
-
e
.
topMove
>
stackMoveDistance
)
{
if
(
stackMoveDistance
==
0
||
stackMoveCounter
-
e
.
topMove
>
stackMoveDistance
)
{
// move a hot entry to the top of the stack
// move a hot entry to the top of the stack
// unless it is already there
// unless it is already there
boolean
wasEnd
=
e
==
stack
.
stackPrev
;
boolean
wasEnd
=
e
==
stack
.
stackPrev
;
...
...
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
浏览文件 @
e2f5284c
...
@@ -62,11 +62,13 @@ public class FilePathZip2 extends FilePath {
...
@@ -62,11 +62,13 @@ public class FilePathZip2 extends FilePath {
}
}
@Override
@Override
public
FilePath
createTempFile
(
String
suffix
,
boolean
deleteOnExit
,
boolean
inTempDir
)
throws
IOException
{
public
FilePath
createTempFile
(
String
suffix
,
boolean
deleteOnExit
,
boolean
inTempDir
)
throws
IOException
{
if
(!
inTempDir
)
{
if
(!
inTempDir
)
{
throw
new
IOException
(
"File system is read-only"
);
throw
new
IOException
(
"File system is read-only"
);
}
}
return
new
FilePathDisk
().
getPath
(
name
).
createTempFile
(
suffix
,
deleteOnExit
,
true
);
return
new
FilePathDisk
().
getPath
(
name
).
createTempFile
(
suffix
,
deleteOnExit
,
true
);
}
}
@Override
@Override
...
@@ -358,7 +360,8 @@ class FileZip2 extends FileBase {
...
@@ -358,7 +360,8 @@ class FileZip2 extends FileBase {
@Override
@Override
public
int
read
(
ByteBuffer
dst
)
throws
IOException
{
public
int
read
(
ByteBuffer
dst
)
throws
IOException
{
seek
();
seek
();
int
len
=
in
.
read
(
dst
.
array
(),
dst
.
arrayOffset
()
+
dst
.
position
(),
dst
.
remaining
());
int
len
=
in
.
read
(
dst
.
array
(),
dst
.
arrayOffset
()
+
dst
.
position
(),
dst
.
remaining
());
if
(
len
>
0
)
{
if
(
len
>
0
)
{
dst
.
position
(
dst
.
position
()
+
len
);
dst
.
position
(
dst
.
position
()
+
len
);
pos
+=
len
;
pos
+=
len
;
...
@@ -421,7 +424,8 @@ class FileZip2 extends FileBase {
...
@@ -421,7 +424,8 @@ class FileZip2 extends FileBase {
}
}
@Override
@Override
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
if
(
shared
)
{
if
(
shared
)
{
// cast to FileChannel to avoid JDK 1.7 ambiguity
// cast to FileChannel to avoid JDK 1.7 ambiguity
...
...
h2/src/tools/org/h2/dev/fs/FileShell.java
浏览文件 @
e2f5284c
...
@@ -334,7 +334,8 @@ public class FileShell extends Tool {
...
@@ -334,7 +334,8 @@ public class FileShell extends Tool {
}
}
}
}
private
static
void
zip
(
String
zipFileName
,
String
base
,
ArrayList
<
String
>
source
)
{
private
static
void
zip
(
String
zipFileName
,
String
base
,
ArrayList
<
String
>
source
)
{
FileUtils
.
delete
(
zipFileName
);
FileUtils
.
delete
(
zipFileName
);
OutputStream
fileOut
=
null
;
OutputStream
fileOut
=
null
;
try
{
try
{
...
@@ -388,14 +389,17 @@ public class FileShell extends Tool {
...
@@ -388,14 +389,17 @@ public class FileShell extends Tool {
}
}
String
fileName
=
entry
.
getName
();
String
fileName
=
entry
.
getName
();
// restoring windows backups on linux and vice versa
// restoring windows backups on linux and vice versa
fileName
=
fileName
.
replace
(
'\\'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
fileName
=
fileName
.
replace
(
'\\'
,
fileName
=
fileName
.
replace
(
'/'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
fileName
=
fileName
.
replace
(
'/'
,
SysProperties
.
FILE_SEPARATOR
.
charAt
(
0
));
if
(
fileName
.
startsWith
(
SysProperties
.
FILE_SEPARATOR
))
{
if
(
fileName
.
startsWith
(
SysProperties
.
FILE_SEPARATOR
))
{
fileName
=
fileName
.
substring
(
1
);
fileName
=
fileName
.
substring
(
1
);
}
}
OutputStream
o
=
null
;
OutputStream
o
=
null
;
try
{
try
{
o
=
FileUtils
.
newOutputStream
(
targetDir
+
SysProperties
.
FILE_SEPARATOR
+
fileName
,
false
);
o
=
FileUtils
.
newOutputStream
(
targetDir
+
SysProperties
.
FILE_SEPARATOR
+
fileName
,
false
);
IOUtils
.
copy
(
zipIn
,
o
);
IOUtils
.
copy
(
zipIn
,
o
);
o
.
close
();
o
.
close
();
}
finally
{
}
finally
{
...
@@ -412,7 +416,8 @@ public class FileShell extends Tool {
...
@@ -412,7 +416,8 @@ public class FileShell extends Tool {
}
}
}
}
private
int
readFileList
(
String
[]
list
,
int
i
,
ArrayList
<
String
>
target
,
boolean
recursive
)
throws
IOException
{
private
int
readFileList
(
String
[]
list
,
int
i
,
ArrayList
<
String
>
target
,
boolean
recursive
)
throws
IOException
{
while
(
i
<
list
.
length
)
{
while
(
i
<
list
.
length
)
{
String
c
=
list
[
i
++];
String
c
=
list
[
i
++];
if
(
";"
.
equals
(
c
))
{
if
(
";"
.
equals
(
c
))
{
...
@@ -453,23 +458,40 @@ public class FileShell extends Tool {
...
@@ -453,23 +458,40 @@ public class FileShell extends Tool {
private
void
showHelp
()
{
private
void
showHelp
()
{
println
(
"Commands are case sensitive"
);
println
(
"Commands are case sensitive"
);
println
(
"? or help Display this help"
);
println
(
"? or help "
+
println
(
"cat <file> Print the contents of the file"
);
"Display this help"
);
println
(
"cd <dir> Change the directory"
);
println
(
"cat <file> "
+
println
(
"chmod -w <file> Make the file read-only"
);
"Print the contents of the file"
);
println
(
"cp <source> <target> Copy a file"
);
println
(
"cd <dir> "
+
println
(
"head <file> Print the first few lines of the contents"
);
"Change the directory"
);
println
(
"ls [<dir>] Print the directory contents"
);
println
(
"chmod -w <file> "
+
println
(
"mkdir <dir> Create a directory (including parent directories)"
);
"Make the file read-only"
);
println
(
"mv <source> <target> Rename a file or directory"
);
println
(
"cp <source> <target> "
+
println
(
"pwd Print the current working directory"
);
"Copy a file"
);
println
(
"rm <file> Remove a file"
);
println
(
"head <file> "
+
println
(
"rm -r <dir> Remove a directory, recursively"
);
"Print the first few lines of the contents"
);
println
(
"rm -rf <dir> Remove a directory, recursively; force"
);
println
(
"ls [<dir>] "
+
println
(
"touch <file> Update the last modified date (creates the file)"
);
"Print the directory contents"
);
println
(
"truncate -s <size> <file> Set the file length"
);
println
(
"mkdir <dir> "
+
println
(
"unzip <zip> Extract all files from the zip file"
);
"Create a directory (including parent directories)"
);
println
(
"zip [-r] <zip> <files..> Create a zip file (-r to recurse directories)"
);
println
(
"mv <source> <target> "
+
"Rename a file or directory"
);
println
(
"pwd "
+
"Print the current working directory"
);
println
(
"rm <file> "
+
"Remove a file"
);
println
(
"rm -r <dir> "
+
"Remove a directory, recursively"
);
println
(
"rm -rf <dir> "
+
"Remove a directory, recursively; force"
);
println
(
"touch <file> "
+
"Update the last modified date (creates the file)"
);
println
(
"truncate -s <size> <file> "
+
"Set the file length"
);
println
(
"unzip <zip> "
+
"Extract all files from the zip file"
);
println
(
"zip [-r] <zip> <files..> "
+
"Create a zip file (-r to recurse directories)"
);
println
(
"exit Exit"
);
println
(
"exit Exit"
);
println
(
""
);
println
(
""
);
}
}
...
...
h2/src/tools/org/h2/dev/ftp/FtpClient.java
浏览文件 @
e2f5284c
...
@@ -68,7 +68,8 @@ public class FtpClient {
...
@@ -68,7 +68,8 @@ public class FtpClient {
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
int
idxSpace
=
message
.
indexOf
(
' '
);
int
idxSpace
=
message
.
indexOf
(
' '
);
int
idxMinus
=
message
.
indexOf
(
'-'
);
int
idxMinus
=
message
.
indexOf
(
'-'
);
int
idx
=
idxSpace
<
0
?
idxMinus
:
idxMinus
<
0
?
idxSpace
:
Math
.
min
(
idxSpace
,
idxMinus
);
int
idx
=
idxSpace
<
0
?
idxMinus
:
idxMinus
<
0
?
idxSpace
:
Math
.
min
(
idxSpace
,
idxMinus
);
if
(
idx
<
0
)
{
if
(
idx
<
0
)
{
code
=
0
;
code
=
0
;
}
else
{
}
else
{
...
@@ -86,7 +87,8 @@ public class FtpClient {
...
@@ -86,7 +87,8 @@ public class FtpClient {
readLine
();
readLine
();
}
}
if
(
code
!=
expected
)
{
if
(
code
!=
expected
)
{
throw
new
IOException
(
"Expected: "
+
expected
+
" got: "
+
code
+
" "
+
message
);
throw
new
IOException
(
"Expected: "
+
expected
+
" got: "
+
code
+
" "
+
message
);
}
}
}
}
...
@@ -227,7 +229,8 @@ public class FtpClient {
...
@@ -227,7 +229,8 @@ public class FtpClient {
readCode
(
226
,
227
);
readCode
(
226
,
227
);
int
first
=
message
.
indexOf
(
'('
)
+
1
;
int
first
=
message
.
indexOf
(
'('
)
+
1
;
int
last
=
message
.
indexOf
(
')'
);
int
last
=
message
.
indexOf
(
')'
);
String
[]
address
=
StringUtils
.
arraySplit
(
message
.
substring
(
first
,
last
),
','
,
true
);
String
[]
address
=
StringUtils
.
arraySplit
(
message
.
substring
(
first
,
last
),
','
,
true
);
StatementBuilder
buff
=
new
StatementBuilder
();
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
buff
.
appendExceptFirst
(
"."
);
buff
.
appendExceptFirst
(
"."
);
...
@@ -273,7 +276,8 @@ public class FtpClient {
...
@@ -273,7 +276,8 @@ public class FtpClient {
* @param out the output stream
* @param out the output stream
* @param restartAt restart at the given position (0 if no restart is required).
* @param restartAt restart at the given position (0 if no restart is required).
*/
*/
void
retrieve
(
String
fileName
,
OutputStream
out
,
long
restartAt
)
throws
IOException
{
void
retrieve
(
String
fileName
,
OutputStream
out
,
long
restartAt
)
throws
IOException
{
passive
();
passive
();
if
(
restartAt
>
0
)
{
if
(
restartAt
>
0
)
{
send
(
"REST "
+
restartAt
);
send
(
"REST "
+
restartAt
);
...
...
h2/src/tools/org/h2/dev/ftp/server/FtpControl.java
浏览文件 @
e2f5284c
...
@@ -47,14 +47,16 @@ public class FtpControl extends Thread {
...
@@ -47,14 +47,16 @@ public class FtpControl extends Thread {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
output
=
new
PrintWriter
(
new
OutputStreamWriter
(
control
.
getOutputStream
(),
Constants
.
UTF8
));
output
=
new
PrintWriter
(
new
OutputStreamWriter
(
control
.
getOutputStream
(),
Constants
.
UTF8
));
if
(
stop
)
{
if
(
stop
)
{
reply
(
421
,
"Too many users"
);
reply
(
421
,
"Too many users"
);
}
else
{
}
else
{
reply
(
220
,
SERVER_NAME
);
reply
(
220
,
SERVER_NAME
);
// TODO need option to configure the serverIpAddress?
// TODO need option to configure the serverIpAddress?
serverIpAddress
=
control
.
getLocalAddress
().
getHostAddress
().
replace
(
'.'
,
','
);
serverIpAddress
=
control
.
getLocalAddress
().
getHostAddress
().
replace
(
'.'
,
','
);
BufferedReader
input
=
new
BufferedReader
(
new
InputStreamReader
(
control
.
getInputStream
()));
BufferedReader
input
=
new
BufferedReader
(
new
InputStreamReader
(
control
.
getInputStream
()));
while
(!
stop
)
{
while
(!
stop
)
{
String
command
=
null
;
String
command
=
null
;
try
{
try
{
...
@@ -169,7 +171,9 @@ public class FtpControl extends Thread {
...
@@ -169,7 +171,9 @@ public class FtpControl extends Thread {
case
'D'
:
case
'D'
:
if
(
"DELE"
.
equals
(
command
))
{
if
(
"DELE"
.
equals
(
command
))
{
String
fileName
=
getFileName
(
param
);
String
fileName
=
getFileName
(
param
);
if
(!
readonly
&&
FileUtils
.
exists
(
fileName
)
&&
!
FileUtils
.
isDirectory
(
fileName
)
&&
FileUtils
.
tryDelete
(
fileName
))
{
if
(!
readonly
&&
FileUtils
.
exists
(
fileName
)
&&
!
FileUtils
.
isDirectory
(
fileName
)
&&
FileUtils
.
tryDelete
(
fileName
))
{
if
(
server
.
getAllowTask
()
&&
fileName
.
endsWith
(
FtpServer
.
TASK_SUFFIX
))
{
if
(
server
.
getAllowTask
()
&&
fileName
.
endsWith
(
FtpServer
.
TASK_SUFFIX
))
{
server
.
stopTask
(
fileName
);
server
.
stopTask
(
fileName
);
}
}
...
@@ -217,7 +221,8 @@ public class FtpControl extends Thread {
...
@@ -217,7 +221,8 @@ public class FtpControl extends Thread {
data
=
new
FtpData
(
server
,
control
.
getInetAddress
(),
dataSocket
);
data
=
new
FtpData
(
server
,
control
.
getInetAddress
(),
dataSocket
);
data
.
start
();
data
.
start
();
int
port
=
dataSocket
.
getLocalPort
();
int
port
=
dataSocket
.
getLocalPort
();
reply
(
227
,
"Passive Mode ("
+
serverIpAddress
+
","
+
(
port
>>
8
)
+
","
+
(
port
&
255
)
+
")"
);
reply
(
227
,
"Passive Mode ("
+
serverIpAddress
+
","
+
(
port
>>
8
)
+
","
+
(
port
&
255
)
+
")"
);
}
else
if
(
"PORT"
.
equals
(
command
))
{
}
else
if
(
"PORT"
.
equals
(
command
))
{
String
[]
list
=
StringUtils
.
arraySplit
(
param
,
','
,
true
);
String
[]
list
=
StringUtils
.
arraySplit
(
param
,
','
,
true
);
String
host
=
list
[
0
]
+
"."
+
list
[
1
]
+
"."
+
list
[
2
]
+
"."
+
list
[
3
];
String
host
=
list
[
0
]
+
"."
+
list
[
1
]
+
"."
+
list
[
2
]
+
"."
+
list
[
3
];
...
@@ -227,7 +232,8 @@ public class FtpControl extends Thread {
...
@@ -227,7 +232,8 @@ public class FtpControl extends Thread {
data
=
new
FtpData
(
server
,
address
,
port
);
data
=
new
FtpData
(
server
,
address
,
port
);
reply
(
200
,
"Ok"
);
reply
(
200
,
"Ok"
);
}
else
{
}
else
{
server
.
trace
(
"Port REJECTED:"
+
address
+
" expected:"
+
control
.
getInetAddress
());
server
.
trace
(
"Port REJECTED:"
+
address
+
" expected:"
+
control
.
getInetAddress
());
reply
(
550
,
"Failed"
);
reply
(
550
,
"Failed"
);
}
}
}
}
...
@@ -304,7 +310,8 @@ public class FtpControl extends Thread {
...
@@ -304,7 +310,8 @@ public class FtpControl extends Thread {
}
}
}
else
if
(
"STOR"
.
equals
(
command
))
{
}
else
if
(
"STOR"
.
equals
(
command
))
{
String
fileName
=
getFileName
(
param
);
String
fileName
=
getFileName
(
param
);
if
(!
readonly
&&
!
FileUtils
.
exists
(
fileName
)
||
!
FileUtils
.
isDirectory
(
fileName
))
{
if
(!
readonly
&&
!
FileUtils
.
exists
(
fileName
)
||
!
FileUtils
.
isDirectory
(
fileName
))
{
reply
(
150
,
"Starting transfer"
);
reply
(
150
,
"Starting transfer"
);
try
{
try
{
data
.
receive
(
fileName
);
data
.
receive
(
fileName
);
...
@@ -368,7 +375,9 @@ public class FtpControl extends Thread {
...
@@ -368,7 +375,9 @@ public class FtpControl extends Thread {
private
void
processRemoveDir
(
String
param
)
{
private
void
processRemoveDir
(
String
param
)
{
String
fileName
=
getFileName
(
param
);
String
fileName
=
getFileName
(
param
);
if
(!
readonly
&&
FileUtils
.
exists
(
fileName
)
&&
FileUtils
.
isDirectory
(
fileName
)
&&
FileUtils
.
tryDelete
(
fileName
))
{
if
(!
readonly
&&
FileUtils
.
exists
(
fileName
)
&&
FileUtils
.
isDirectory
(
fileName
)
&&
FileUtils
.
tryDelete
(
fileName
))
{
reply
(
250
,
"Ok"
);
reply
(
250
,
"Ok"
);
}
else
{
}
else
{
reply
(
500
,
"Failed"
);
reply
(
500
,
"Failed"
);
...
...
h2/src/tools/org/h2/dev/ftp/server/FtpServer.java
浏览文件 @
e2f5284c
...
@@ -71,12 +71,16 @@ public class FtpServer extends Tool implements Service {
...
@@ -71,12 +71,16 @@ public class FtpServer extends Tool implements Service {
private
int
port
=
DEFAULT_PORT
;
private
int
port
=
DEFAULT_PORT
;
private
int
openConnectionCount
;
private
int
openConnectionCount
;
private
final
SimpleDateFormat
dateFormatNew
=
new
SimpleDateFormat
(
"MMM dd HH:mm"
,
Locale
.
ENGLISH
);
private
final
SimpleDateFormat
dateFormatNew
=
new
SimpleDateFormat
(
private
final
SimpleDateFormat
dateFormatOld
=
new
SimpleDateFormat
(
"MMM dd yyyy"
,
Locale
.
ENGLISH
);
"MMM dd HH:mm"
,
Locale
.
ENGLISH
);
private
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
private
final
SimpleDateFormat
dateFormatOld
=
new
SimpleDateFormat
(
"MMM dd yyyy"
,
Locale
.
ENGLISH
);
private
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
private
String
root
=
DEFAULT_ROOT
;
private
String
root
=
DEFAULT_ROOT
;
private
String
writeUserName
=
DEFAULT_WRITE
,
writePassword
=
DEFAULT_WRITE_PASSWORD
;
private
String
writeUserName
=
DEFAULT_WRITE
,
writePassword
=
DEFAULT_WRITE_PASSWORD
;
private
String
readUserName
=
DEFAULT_READ
;
private
String
readUserName
=
DEFAULT_READ
;
private
final
HashMap
<
String
,
Process
>
tasks
=
new
HashMap
<
String
,
Process
>();
private
final
HashMap
<
String
,
Process
>
tasks
=
new
HashMap
<
String
,
Process
>();
...
@@ -234,7 +238,9 @@ public class FtpServer extends Tool implements Service {
...
@@ -234,7 +238,9 @@ public class FtpServer extends Tool implements Service {
buff
.
append
(
' '
);
buff
.
append
(
' '
);
Date
now
=
new
Date
(),
mod
=
new
Date
(
FileUtils
.
lastModified
(
fileName
));
Date
now
=
new
Date
(),
mod
=
new
Date
(
FileUtils
.
lastModified
(
fileName
));
String
date
;
String
date
;
if
(
mod
.
after
(
now
)
||
Math
.
abs
((
now
.
getTime
()
-
mod
.
getTime
())
/
1000
/
60
/
60
/
24
)
>
180
)
{
if
(
mod
.
after
(
now
)
||
Math
.
abs
((
now
.
getTime
()
-
mod
.
getTime
())
/
1000
/
60
/
60
/
24
)
>
180
)
{
synchronized
(
dateFormatOld
)
{
synchronized
(
dateFormatOld
)
{
date
=
dateFormatOld
.
format
(
mod
);
date
=
dateFormatOld
.
format
(
mod
);
}
}
...
@@ -296,7 +302,8 @@ public class FtpServer extends Tool implements Service {
...
@@ -296,7 +302,8 @@ public class FtpServer extends Tool implements Service {
String
getDirectoryListing
(
String
directory
,
boolean
listDirectories
)
{
String
getDirectoryListing
(
String
directory
,
boolean
listDirectories
)
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
fileName
:
FileUtils
.
newDirectoryStream
(
directory
))
{
for
(
String
fileName
:
FileUtils
.
newDirectoryStream
(
directory
))
{
if
(!
FileUtils
.
isDirectory
(
fileName
)
||
(
FileUtils
.
isDirectory
(
fileName
)
&&
listDirectories
))
{
if
(!
FileUtils
.
isDirectory
(
fileName
)
||
(
FileUtils
.
isDirectory
(
fileName
)
&&
listDirectories
))
{
appendFile
(
buff
,
fileName
);
appendFile
(
buff
,
fileName
);
}
}
}
}
...
@@ -311,7 +318,8 @@ public class FtpServer extends Tool implements Service {
...
@@ -311,7 +318,8 @@ public class FtpServer extends Tool implements Service {
* @return true if this user may write
* @return true if this user may write
*/
*/
boolean
checkUserPasswordWrite
(
String
userName
,
String
password
)
{
boolean
checkUserPasswordWrite
(
String
userName
,
String
password
)
{
return
userName
.
equals
(
this
.
writeUserName
)
&&
password
.
equals
(
this
.
writePassword
);
return
userName
.
equals
(
this
.
writeUserName
)
&&
password
.
equals
(
this
.
writePassword
);
}
}
/**
/**
...
@@ -451,8 +459,10 @@ public class FtpServer extends Tool implements Service {
...
@@ -451,8 +459,10 @@ public class FtpServer extends Tool implements Service {
Properties
prop
=
SortedProperties
.
loadProperties
(
path
);
Properties
prop
=
SortedProperties
.
loadProperties
(
path
);
String
command
=
prop
.
getProperty
(
"command"
);
String
command
=
prop
.
getProperty
(
"command"
);
String
outFile
=
path
.
substring
(
0
,
path
.
length
()
-
TASK_SUFFIX
.
length
());
String
outFile
=
path
.
substring
(
0
,
path
.
length
()
-
TASK_SUFFIX
.
length
());
String
errorFile
=
root
+
"/"
+
prop
.
getProperty
(
"error"
,
outFile
+
".err.txt"
);
String
errorFile
=
root
+
"/"
String
outputFile
=
root
+
"/"
+
prop
.
getProperty
(
"output"
,
outFile
+
".out.txt"
);
+
prop
.
getProperty
(
"error"
,
outFile
+
".err.txt"
);
String
outputFile
=
root
+
"/"
+
prop
.
getProperty
(
"output"
,
outFile
+
".out.txt"
);
trace
(
"start process: "
+
path
+
" / "
+
command
);
trace
(
"start process: "
+
path
+
" / "
+
command
);
Process
p
=
Runtime
.
getRuntime
().
exec
(
command
,
null
,
new
File
(
root
));
Process
p
=
Runtime
.
getRuntime
().
exec
(
command
,
null
,
new
File
(
root
));
new
StreamRedirect
(
path
,
p
.
getErrorStream
(),
errorFile
).
start
();
new
StreamRedirect
(
path
,
p
.
getErrorStream
(),
errorFile
).
start
();
...
...
h2/src/tools/org/h2/dev/net/PgTcpRedirect.java
浏览文件 @
e2f5284c
...
@@ -99,7 +99,8 @@ public class PgTcpRedirect {
...
@@ -99,7 +99,8 @@ public class PgTcpRedirect {
}
}
}
}
private
boolean
processClient
(
InputStream
inStream
,
OutputStream
outStream
)
throws
IOException
{
private
boolean
processClient
(
InputStream
inStream
,
OutputStream
outStream
)
throws
IOException
{
DataInputStream
dataIn
=
new
DataInputStream
(
inStream
);
DataInputStream
dataIn
=
new
DataInputStream
(
inStream
);
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
DataOutputStream
dataOut
=
new
DataOutputStream
(
buff
);
DataOutputStream
dataOut
=
new
DataOutputStream
(
buff
);
...
@@ -121,7 +122,8 @@ public class PgTcpRedirect {
...
@@ -121,7 +122,8 @@ public class PgTcpRedirect {
println
(
"SSLRequest"
);
println
(
"SSLRequest"
);
}
else
{
}
else
{
println
(
"StartupMessage"
);
println
(
"StartupMessage"
);
println
(
" version "
+
version
+
" ("
+
(
version
>>
16
)
+
"."
+
(
version
&
0xff
)
+
")"
);
println
(
" version "
+
version
+
" ("
+
(
version
>>
16
)
+
"."
+
(
version
&
0xff
)
+
")"
);
while
(
true
)
{
while
(
true
)
{
String
param
=
readStringNull
(
dataIn
);
String
param
=
readStringNull
(
dataIn
);
if
(
param
.
length
()
==
0
)
{
if
(
param
.
length
()
==
0
)
{
...
@@ -266,7 +268,8 @@ public class PgTcpRedirect {
...
@@ -266,7 +268,8 @@ public class PgTcpRedirect {
return
true
;
return
true
;
}
}
private
boolean
processServer
(
InputStream
inStream
,
OutputStream
outStream
)
throws
IOException
{
private
boolean
processServer
(
InputStream
inStream
,
OutputStream
outStream
)
throws
IOException
{
DataInputStream
dataIn
=
new
DataInputStream
(
inStream
);
DataInputStream
dataIn
=
new
DataInputStream
(
inStream
);
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
();
DataOutputStream
dataOut
=
new
DataOutputStream
(
buff
);
DataOutputStream
dataOut
=
new
DataOutputStream
(
buff
);
...
@@ -453,7 +456,8 @@ public class PgTcpRedirect {
...
@@ -453,7 +456,8 @@ public class PgTcpRedirect {
}
}
case
'S'
:
{
case
'S'
:
{
println
(
"ParameterStatus"
);
println
(
"ParameterStatus"
);
println
(
" parameter "
+
readStringNull
(
dataIn
)
+
" = "
+
readStringNull
(
dataIn
));
println
(
" parameter "
+
readStringNull
(
dataIn
)
+
" = "
+
readStringNull
(
dataIn
));
break
;
break
;
}
}
case
'1'
:
{
case
'1'
:
{
...
@@ -466,7 +470,8 @@ public class PgTcpRedirect {
...
@@ -466,7 +470,8 @@ public class PgTcpRedirect {
}
}
case
'Z'
:
{
case
'Z'
:
{
println
(
"ReadyForQuery"
);
println
(
"ReadyForQuery"
);
println
(
" status (I:idle, T:transaction, E:failed): "
+
(
char
)
dataIn
.
readByte
());
println
(
" status (I:idle, T:transaction, E:failed): "
+
(
char
)
dataIn
.
readByte
());
break
;
break
;
}
}
case
'T'
:
{
case
'T'
:
{
...
...
h2/src/tools/org/h2/dev/security/SecureKeyStoreBuilder.java
浏览文件 @
e2f5284c
...
@@ -49,25 +49,34 @@ public class SecureKeyStoreBuilder {
...
@@ -49,25 +49,34 @@ public class SecureKeyStoreBuilder {
private
static
void
printKeystore
(
KeyStore
store
,
String
password
)
private
static
void
printKeystore
(
KeyStore
store
,
String
password
)
throws
KeyStoreException
,
NoSuchAlgorithmException
,
throws
KeyStoreException
,
NoSuchAlgorithmException
,
UnrecoverableKeyException
,
CertificateEncodingException
{
UnrecoverableKeyException
,
CertificateEncodingException
{
System
.
out
.
println
(
"KeyStore store = KeyStore.getInstance(\""
+
store
.
getType
()+
"\");"
);
System
.
out
.
println
(
"KeyStore store = KeyStore.getInstance(\""
+
store
.
getType
()
+
"\");"
);
System
.
out
.
println
(
"store.load(null, password.toCharArray());"
);
System
.
out
.
println
(
"store.load(null, password.toCharArray());"
);
//System.out.println("keystore provider="+store.getProvider().getName());
//System.out.println("keystore provider="+store.getProvider().getName());
Enumeration
<
String
>
en
=
store
.
aliases
();
Enumeration
<
String
>
en
=
store
.
aliases
();
while
(
en
.
hasMoreElements
())
{
while
(
en
.
hasMoreElements
())
{
String
alias
=
en
.
nextElement
();
String
alias
=
en
.
nextElement
();
Key
key
=
store
.
getKey
(
alias
,
password
.
toCharArray
());
Key
key
=
store
.
getKey
(
alias
,
password
.
toCharArray
());
System
.
out
.
println
(
"KeyFactory keyFactory = KeyFactory.getInstance(\""
+
key
.
getAlgorithm
()
+
"\");"
);
System
.
out
.
println
(
"KeyFactory keyFactory = KeyFactory.getInstance(\""
+
key
.
getAlgorithm
()
+
"\");"
);
System
.
out
.
println
(
"store.load(null, password.toCharArray());"
);
System
.
out
.
println
(
"store.load(null, password.toCharArray());"
);
String
pkFormat
=
key
.
getFormat
();
String
pkFormat
=
key
.
getFormat
();
String
encoded
=
StringUtils
.
convertBytesToHex
(
key
.
getEncoded
());
String
encoded
=
StringUtils
.
convertBytesToHex
(
key
.
getEncoded
());
System
.
out
.
println
(
pkFormat
+
"EncodedKeySpec keySpec = new "
+
pkFormat
+
"EncodedKeySpec(getBytes(\""
System
.
out
.
println
(
pkFormat
+
"EncodedKeySpec keySpec = new "
+
pkFormat
+
"EncodedKeySpec(getBytes(\""
+
encoded
+
"\"));"
);
+
encoded
+
"\"));"
);
System
.
out
.
println
(
"PrivateKey privateKey = keyFactory.generatePrivate(keySpec);"
);
System
.
out
.
println
(
"PrivateKey privateKey = keyFactory.generatePrivate(keySpec);"
);
System
.
out
.
println
(
"Certificate[] certs = {"
);
System
.
out
.
println
(
"Certificate[] certs = {"
);
for
(
Certificate
cert
:
store
.
getCertificateChain
(
alias
))
{
for
(
Certificate
cert
:
store
.
getCertificateChain
(
alias
))
{
System
.
out
.
println
(
" CertificateFactory.getInstance(\""
+
cert
.
getType
()+
"\")."
);
System
.
out
.
println
(
" CertificateFactory.getInstance(\""
+
cert
.
getType
()+
"\")."
);
String
enc
=
StringUtils
.
convertBytesToHex
(
cert
.
getEncoded
());
String
enc
=
StringUtils
.
convertBytesToHex
(
cert
.
getEncoded
());
System
.
out
.
println
(
" generateCertificate(new ByteArrayInputStream(getBytes(\""
+
enc
+
"\"))),"
);
System
.
out
.
println
(
" generateCertificate(new ByteArrayInputStream(getBytes(\""
+
enc
+
"\"))),"
);
// PublicKey pubKey = cert.getPublicKey();
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" pubKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" pubKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" pubKey format="+pubKey.getFormat());
// System.out.println(" pubKey format="+pubKey.getFormat());
...
@@ -75,7 +84,8 @@ public class SecureKeyStoreBuilder {
...
@@ -75,7 +84,8 @@ public class SecureKeyStoreBuilder {
// Utils.convertBytesToString(pubKey.getEncoded()));
// Utils.convertBytesToString(pubKey.getEncoded()));
}
}
System
.
out
.
println
(
"};"
);
System
.
out
.
println
(
"};"
);
System
.
out
.
println
(
"store.setKeyEntry(\""
+
alias
+
"\", privateKey, password.toCharArray(), certs);"
);
System
.
out
.
println
(
"store.setKeyEntry(\""
+
alias
+
"\", privateKey, password.toCharArray(), certs);"
);
}
}
}
}
...
...
h2/src/tools/org/h2/dev/sort/InPlaceStableMergeSort.java
浏览文件 @
e2f5284c
...
@@ -195,7 +195,8 @@ public class InPlaceStableMergeSort<T> {
...
@@ -195,7 +195,8 @@ public class InPlaceStableMergeSort<T> {
* @param from2 the index of the first element in the second source array
* @param from2 the index of the first element in the second source array
* @param to2 the index of the last element in the second source array
* @param to2 the index of the last element in the second source array
*/
*/
private
void
mergeSmall
(
T
[]
target
,
int
pos
,
T
[]
s1
,
int
from1
,
int
to1
,
T
[]
s2
,
int
from2
,
int
to2
)
{
private
void
mergeSmall
(
T
[]
target
,
int
pos
,
T
[]
s1
,
int
from1
,
int
to1
,
T
[]
s2
,
int
from2
,
int
to2
)
{
T
x1
=
s1
[
from1
],
x2
=
s2
[
from2
];
T
x1
=
s1
[
from1
],
x2
=
s2
[
from2
];
while
(
true
)
{
while
(
true
)
{
if
(
comp
.
compare
(
x1
,
x2
)
<=
0
)
{
if
(
comp
.
compare
(
x1
,
x2
)
<=
0
)
{
...
...
h2/src/tools/org/h2/dev/util/ArrayUtils.java
浏览文件 @
e2f5284c
...
@@ -22,7 +22,8 @@ public class ArrayUtils {
...
@@ -22,7 +22,8 @@ public class ArrayUtils {
* @param right the index of the rightmost element
* @param right the index of the rightmost element
* @param comp the comparison class
* @param comp the comparison class
*/
*/
public
static
<
T
>
void
binaryInsertionSort
(
T
[]
d
,
int
left
,
int
right
,
Comparator
<
T
>
comp
)
{
public
static
<
T
>
void
binaryInsertionSort
(
T
[]
d
,
int
left
,
int
right
,
Comparator
<
T
>
comp
)
{
for
(
int
i
=
left
+
1
;
i
<=
right
;
i
++)
{
for
(
int
i
=
left
+
1
;
i
<=
right
;
i
++)
{
T
t
=
d
[
i
];
T
t
=
d
[
i
];
int
l
=
left
;
int
l
=
left
;
...
@@ -50,7 +51,8 @@ public class ArrayUtils {
...
@@ -50,7 +51,8 @@ public class ArrayUtils {
* @param right the index of the rightmost element
* @param right the index of the rightmost element
* @param comp the comparison class
* @param comp the comparison class
*/
*/
public
static
<
T
>
void
insertionSort
(
T
[]
d
,
int
left
,
int
right
,
Comparator
<
T
>
comp
)
{
public
static
<
T
>
void
insertionSort
(
T
[]
d
,
int
left
,
int
right
,
Comparator
<
T
>
comp
)
{
for
(
int
i
=
left
+
1
,
j
;
i
<=
right
;
i
++)
{
for
(
int
i
=
left
+
1
,
j
;
i
<=
right
;
i
++)
{
T
t
=
d
[
i
];
T
t
=
d
[
i
];
for
(
j
=
i
-
1
;
j
>=
left
&&
comp
.
compare
(
d
[
j
],
t
)
>
0
;
j
--)
{
for
(
j
=
i
-
1
;
j
>=
left
&&
comp
.
compare
(
d
[
j
],
t
)
>
0
;
j
--)
{
...
...
h2/src/tools/org/h2/dev/util/FileViewer.java
浏览文件 @
e2f5284c
...
@@ -124,7 +124,8 @@ public class FileViewer extends Tool {
...
@@ -124,7 +124,8 @@ public class FileViewer extends Tool {
}
}
}
}
private
static
long
find
(
RandomAccessFile
file
,
byte
[]
find
,
boolean
quiet
)
throws
IOException
{
private
static
long
find
(
RandomAccessFile
file
,
byte
[]
find
,
boolean
quiet
)
throws
IOException
{
long
pos
=
file
.
getFilePointer
();
long
pos
=
file
.
getFilePointer
();
long
length
=
file
.
length
();
long
length
=
file
.
length
();
int
bufferSize
=
4
*
1024
;
int
bufferSize
=
4
*
1024
;
...
@@ -176,7 +177,8 @@ public class FileViewer extends Tool {
...
@@ -176,7 +177,8 @@ public class FileViewer extends Tool {
System
.
out
.
println
(
"-----------------------------------------------"
);
System
.
out
.
println
(
"-----------------------------------------------"
);
}
}
private
static
ArrayList
<
String
>
readLines
(
RandomAccessFile
file
,
int
maxLines
)
throws
IOException
{
private
static
ArrayList
<
String
>
readLines
(
RandomAccessFile
file
,
int
maxLines
)
throws
IOException
{
ArrayList
<
String
>
lines
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
lines
=
new
ArrayList
<
String
>();
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
(
100
);
ByteArrayOutputStream
buff
=
new
ByteArrayOutputStream
(
100
);
boolean
lastNewline
=
false
;
boolean
lastNewline
=
false
;
...
...
h2/src/tools/org/h2/dev/util/Migrate.java
浏览文件 @
e2f5284c
...
@@ -34,8 +34,10 @@ public class Migrate {
...
@@ -34,8 +34,10 @@ public class Migrate {
private
static
final
String
USER
=
"sa"
;
private
static
final
String
USER
=
"sa"
;
private
static
final
String
PASSWORD
=
"sa"
;
private
static
final
String
PASSWORD
=
"sa"
;
private
static
final
File
OLD_H2_FILE
=
new
File
(
"./h2-1.2.127.jar"
);
private
static
final
File
OLD_H2_FILE
=
new
File
(
"./h2-1.2.127.jar"
);
private
static
final
String
DOWNLOAD_URL
=
"http://repo2.maven.org/maven2/com/h2database/h2/1.2.127/h2-1.2.127.jar"
;
private
static
final
String
DOWNLOAD_URL
=
private
static
final
String
CHECKSUM
=
"056e784c7cf009483366ab9cd8d21d02fe47031a"
;
"http://repo2.maven.org/maven2/com/h2database/h2/1.2.127/h2-1.2.127.jar"
;
private
static
final
String
CHECKSUM
=
"056e784c7cf009483366ab9cd8d21d02fe47031a"
;
private
static
final
String
TEMP_SCRIPT
=
"backup.sql"
;
private
static
final
String
TEMP_SCRIPT
=
"backup.sql"
;
private
final
PrintStream
sysOut
=
System
.
out
;
private
final
PrintStream
sysOut
=
System
.
out
;
private
boolean
quiet
;
private
boolean
quiet
;
...
@@ -47,7 +49,8 @@ public class Migrate {
...
@@ -47,7 +49,8 @@ public class Migrate {
* @throws Exception if conversion fails
* @throws Exception if conversion fails
*/
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
Migrate
().
execute
(
new
File
(
args
.
length
==
1
?
args
[
0
]
:
"."
),
true
,
USER
,
PASSWORD
,
false
);
new
Migrate
().
execute
(
new
File
(
args
.
length
==
1
?
args
[
0
]
:
"."
),
true
,
USER
,
PASSWORD
,
false
);
}
}
/**
/**
...
@@ -61,7 +64,8 @@ public class Migrate {
...
@@ -61,7 +64,8 @@ public class Migrate {
* @param runQuiet to run in quiet mode
* @param runQuiet to run in quiet mode
* @throws Exception if conversion fails
* @throws Exception if conversion fails
*/
*/
public
void
execute
(
File
file
,
boolean
recursive
,
String
user
,
String
password
,
boolean
runQuiet
)
throws
Exception
{
public
void
execute
(
File
file
,
boolean
recursive
,
String
user
,
String
password
,
boolean
runQuiet
)
throws
Exception
{
String
pathToJavaExe
=
getJavaExecutablePath
();
String
pathToJavaExe
=
getJavaExecutablePath
();
this
.
quiet
=
runQuiet
;
this
.
quiet
=
runQuiet
;
if
(
file
.
isDirectory
()
&&
recursive
)
{
if
(
file
.
isDirectory
()
&&
recursive
)
{
...
@@ -97,9 +101,11 @@ public class Migrate {
...
@@ -97,9 +101,11 @@ public class Migrate {
private
static
String
getJavaExecutablePath
()
{
private
static
String
getJavaExecutablePath
()
{
String
pathToJava
;
String
pathToJava
;
if
(
File
.
separator
.
equals
(
"\\"
))
{
if
(
File
.
separator
.
equals
(
"\\"
))
{
pathToJava
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java.exe"
;
pathToJava
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java.exe"
;
}
else
{
}
else
{
pathToJava
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java"
;
pathToJava
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java"
;
}
}
if
(!
new
File
(
pathToJava
).
exists
())
{
if
(!
new
File
(
pathToJava
).
exists
())
{
// Fallback to old behaviour
// Fallback to old behaviour
...
...
h2/src/tools/org/h2/jaqu/Db.java
浏览文件 @
e2f5284c
...
@@ -39,14 +39,15 @@ public class Db {
...
@@ -39,14 +39,15 @@ public class Db {
* doesn't actually hold column tokens, as those are bound to the query
* doesn't actually hold column tokens, as those are bound to the query
* itself.
* itself.
*/
*/
private
static
final
Map
<
Object
,
Token
>
TOKENS
=
private
static
final
Map
<
Object
,
Token
>
TOKENS
=
Collections
Collections
.
synchronizedMap
(
new
WeakIdentityHashMap
<
Object
,
Token
>());
.
synchronizedMap
(
new
WeakIdentityHashMap
<
Object
,
Token
>());
private
final
Connection
conn
;
private
final
Connection
conn
;
private
final
Map
<
Class
<?>,
TableDefinition
<?>>
classMap
=
New
.
hashMap
();
private
final
Map
<
Class
<?>,
TableDefinition
<?>>
classMap
=
New
.
hashMap
();
private
final
SQLDialect
dialect
;
private
final
SQLDialect
dialect
;
private
DbUpgrader
dbUpgrader
=
new
DefaultDbUpgrader
();
private
DbUpgrader
dbUpgrader
=
new
DefaultDbUpgrader
();
private
final
Set
<
Class
<?>>
upgradeChecked
=
Collections
.
synchronizedSet
(
new
HashSet
<
Class
<?>>());
private
final
Set
<
Class
<?>>
upgradeChecked
=
Collections
.
synchronizedSet
(
new
HashSet
<
Class
<?>>());
private
int
todoDocumentNewFeaturesInHtmlFile
;
private
int
todoDocumentNewFeaturesInHtmlFile
;
...
@@ -74,7 +75,8 @@ public class Db {
...
@@ -74,7 +75,8 @@ public class Db {
public
static
Db
open
(
String
url
,
String
user
,
String
password
)
{
public
static
Db
open
(
String
url
,
String
user
,
String
password
)
{
try
{
try
{
Connection
conn
=
JdbcUtils
.
getConnection
(
null
,
url
,
user
,
password
);
Connection
conn
=
JdbcUtils
.
getConnection
(
null
,
url
,
user
,
password
);
return
new
Db
(
conn
);
return
new
Db
(
conn
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
convert
(
e
);
throw
convert
(
e
);
...
@@ -148,12 +150,14 @@ public class Db {
...
@@ -148,12 +150,14 @@ public class Db {
// flag as checked immediately because calls are nested.
// flag as checked immediately because calls are nested.
upgradeChecked
.
add
(
dbUpgrader
.
getClass
());
upgradeChecked
.
add
(
dbUpgrader
.
getClass
());
JQDatabase
model
=
dbUpgrader
.
getClass
().
getAnnotation
(
JQDatabase
.
class
);
JQDatabase
model
=
dbUpgrader
.
getClass
().
getAnnotation
(
JQDatabase
.
class
);
if
(
model
.
version
()
>
0
)
{
if
(
model
.
version
()
>
0
)
{
DbVersion
v
=
new
DbVersion
();
DbVersion
v
=
new
DbVersion
();
DbVersion
dbVersion
=
DbVersion
dbVersion
=
// (SCHEMA="" && TABLE="") == DATABASE
// (SCHEMA="" && TABLE="") == DATABASE
from
(
v
).
where
(
v
.
schema
).
is
(
""
).
and
(
v
.
table
).
is
(
""
).
selectFirst
();
from
(
v
).
where
(
v
.
schema
).
is
(
""
).
and
(
v
.
table
).
is
(
""
)
.
selectFirst
();
if
(
dbVersion
==
null
)
{
if
(
dbVersion
==
null
)
{
// database has no version registration, but model specifies
// database has no version registration, but model specifies
// version: insert DbVersion entry and return.
// version: insert DbVersion entry and return.
...
@@ -186,10 +190,10 @@ public class Db {
...
@@ -186,10 +190,10 @@ public class Db {
if
(
model
.
tableVersion
>
0
)
{
if
(
model
.
tableVersion
>
0
)
{
// table is using JaQu version tracking.
// table is using JaQu version tracking.
DbVersion
v
=
new
DbVersion
();
DbVersion
v
=
new
DbVersion
();
String
schema
=
StringUtils
.
isNullOrEmpty
(
model
.
schemaName
)
?
""
:
model
.
schemaName
;
String
schema
=
StringUtils
.
isNullOrEmpty
(
model
.
schemaName
)
?
""
DbVersion
dbVersion
=
:
model
.
schemaName
;
from
(
v
).
where
(
v
.
schema
).
like
(
schema
).
and
(
v
.
table
)
DbVersion
dbVersion
=
from
(
v
).
where
(
v
.
schema
).
like
(
schema
)
.
like
(
model
.
tableName
).
selectFirst
();
.
and
(
v
.
table
)
.
like
(
model
.
tableName
).
selectFirst
();
if
(
dbVersion
==
null
)
{
if
(
dbVersion
==
null
)
{
// table has no version registration, but model specifies
// table has no version registration, but model specifies
// version: insert DbVersion entry
// version: insert DbVersion entry
...
@@ -204,7 +208,8 @@ public class Db {
...
@@ -204,7 +208,8 @@ public class Db {
&&
(
dbUpgrader
!=
null
))
{
&&
(
dbUpgrader
!=
null
))
{
// table is an older version than model
// table is an older version than model
boolean
success
=
dbUpgrader
.
upgradeTable
(
this
,
schema
,
boolean
success
=
dbUpgrader
.
upgradeTable
(
this
,
schema
,
model
.
tableName
,
dbVersion
.
version
,
model
.
tableVersion
);
model
.
tableName
,
dbVersion
.
version
,
model
.
tableVersion
);
if
(
success
)
{
if
(
success
)
{
dbVersion
.
version
=
model
.
tableVersion
;
dbVersion
.
version
=
model
.
tableVersion
;
update
(
dbVersion
);
update
(
dbVersion
);
...
@@ -227,7 +232,8 @@ public class Db {
...
@@ -227,7 +232,8 @@ public class Db {
Table
table
=
(
Table
)
t
;
Table
table
=
(
Table
)
t
;
Define
.
define
(
def
,
table
);
Define
.
define
(
def
,
table
);
}
else
if
(
clazz
.
isAnnotationPresent
(
JQTable
.
class
))
{
}
else
if
(
clazz
.
isAnnotationPresent
(
JQTable
.
class
))
{
// annotated classes skip the Define().define() static initializer
// annotated classes skip the Define().define() static
// initializer
T
t
=
instance
(
clazz
);
T
t
=
instance
(
clazz
);
def
.
mapObject
(
t
);
def
.
mapObject
(
t
);
}
}
...
@@ -293,7 +299,8 @@ public class Db {
...
@@ -293,7 +299,8 @@ public class Db {
PreparedStatement
prepare
(
String
sql
,
boolean
returnGeneratedKeys
)
{
PreparedStatement
prepare
(
String
sql
,
boolean
returnGeneratedKeys
)
{
try
{
try
{
if
(
returnGeneratedKeys
)
{
if
(
returnGeneratedKeys
)
{
return
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
return
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
}
}
return
conn
.
prepareStatement
(
sql
);
return
conn
.
prepareStatement
(
sql
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
@@ -337,12 +344,12 @@ public class Db {
...
@@ -337,12 +344,12 @@ public class Db {
}
}
}
}
//
<X> FieldDefinition<X> getFieldDefinition(X x) {
//
<X> FieldDefinition<X> getFieldDefinition(X x) {
//
return aliasMap.get(x).getFieldDefinition();
//
return aliasMap.get(x).getFieldDefinition();
//
}
//
}
//
//
//
<X> SelectColumn<X> getSelectColumn(X x) {
//
<X> SelectColumn<X> getSelectColumn(X x) {
//
return aliasMap.get(x);
//
return aliasMap.get(x);
//
}
//
}
}
}
h2/src/tools/org/h2/jaqu/DbInspector.java
浏览文件 @
e2f5284c
...
@@ -38,7 +38,8 @@ public class DbInspector {
...
@@ -38,7 +38,8 @@ public class DbInspector {
*
*
* @param dateTimeClass the new class
* @param dateTimeClass the new class
*/
*/
public
void
setPreferredDateTimeClass
(
Class
<?
extends
java
.
util
.
Date
>
dateTimeClass
)
{
public
void
setPreferredDateTimeClass
(
Class
<?
extends
java
.
util
.
Date
>
dateTimeClass
)
{
this
.
dateTimeClass
=
dateTimeClass
;
this
.
dateTimeClass
=
dateTimeClass
;
}
}
...
@@ -80,7 +81,8 @@ public class DbInspector {
...
@@ -80,7 +81,8 @@ public class DbInspector {
* @param throwOnError if errors should cause validation to fail
* @param throwOnError if errors should cause validation to fail
* @return a list of validation remarks
* @return a list of validation remarks
*/
*/
public
<
T
>
List
<
ValidationRemark
>
validateModel
(
T
model
,
boolean
throwOnError
)
{
public
<
T
>
List
<
ValidationRemark
>
validateModel
(
T
model
,
boolean
throwOnError
)
{
try
{
try
{
TableInspector
inspector
=
getTable
(
model
);
TableInspector
inspector
=
getTable
(
model
);
inspector
.
read
(
metaData
);
inspector
.
read
(
metaData
);
...
@@ -112,22 +114,24 @@ public class DbInspector {
...
@@ -112,22 +114,24 @@ public class DbInspector {
Class
<
T
>
clazz
=
(
Class
<
T
>)
model
.
getClass
();
Class
<
T
>
clazz
=
(
Class
<
T
>)
model
.
getClass
();
TableDefinition
<
T
>
def
=
db
.
define
(
clazz
);
TableDefinition
<
T
>
def
=
db
.
define
(
clazz
);
boolean
forceUpperCase
=
getMetaData
().
storesUpperCaseIdentifiers
();
boolean
forceUpperCase
=
getMetaData
().
storesUpperCaseIdentifiers
();
String
schema
=
(
forceUpperCase
&&
def
.
schemaName
!=
null
)
?
String
schema
=
(
forceUpperCase
&&
def
.
schemaName
!=
null
)
?
def
.
schemaName
def
.
schemaName
.
toUpperCase
()
:
def
.
schemaName
;
.
toUpperCase
()
:
def
.
schemaName
;
String
table
=
forceUpperCase
?
def
.
tableName
.
toUpperCase
()
:
def
.
tableName
;
String
table
=
forceUpperCase
?
def
.
tableName
.
toUpperCase
()
:
def
.
tableName
;
List
<
TableInspector
>
tables
=
getTables
(
schema
,
table
);
List
<
TableInspector
>
tables
=
getTables
(
schema
,
table
);
return
tables
.
get
(
0
);
return
tables
.
get
(
0
);
}
}
/**
/**
* Returns a list of tables. This method always returns at least one
element.
* Returns a list of tables. This method always returns at least one
* If no table is found, an exception is thrown.
*
element.
If no table is found, an exception is thrown.
*
*
* @param schema the schema name
* @param schema the schema name
* @param table the table name
* @param table the table name
* @return a list of table inspectors (always contains at least one element)
* @return a list of table inspectors (always contains at least one element)
*/
*/
private
List
<
TableInspector
>
getTables
(
String
schema
,
String
table
)
throws
SQLException
{
private
List
<
TableInspector
>
getTables
(
String
schema
,
String
table
)
throws
SQLException
{
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
getMetaData
().
getSchemas
();
rs
=
getMetaData
().
getSchemas
();
...
@@ -137,24 +141,27 @@ public class DbInspector {
...
@@ -137,24 +141,27 @@ public class DbInspector {
}
}
JdbcUtils
.
closeSilently
(
rs
);
JdbcUtils
.
closeSilently
(
rs
);
String
jaquTables
=
DbVersion
.
class
.
getAnnotation
(
JQTable
.
class
).
name
();
String
jaquTables
=
DbVersion
.
class
.
getAnnotation
(
JQTable
.
class
)
.
name
();
List
<
TableInspector
>
tables
=
New
.
arrayList
();
List
<
TableInspector
>
tables
=
New
.
arrayList
();
if
(
schemaList
.
size
()
==
0
)
{
if
(
schemaList
.
size
()
==
0
)
{
schemaList
.
add
(
null
);
schemaList
.
add
(
null
);
}
}
for
(
String
s
:
schemaList
)
{
for
(
String
s
:
schemaList
)
{
rs
=
getMetaData
().
getTables
(
null
,
s
,
null
,
new
String
[]
{
"TABLE"
});
rs
=
getMetaData
().
getTables
(
null
,
s
,
null
,
new
String
[]
{
"TABLE"
});
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
String
t
=
rs
.
getString
(
"TABLE_NAME"
);
String
t
=
rs
.
getString
(
"TABLE_NAME"
);
if
(!
t
.
equalsIgnoreCase
(
jaquTables
))
{
if
(!
t
.
equalsIgnoreCase
(
jaquTables
))
{
tables
.
add
(
new
TableInspector
(
s
,
t
,
tables
.
add
(
new
TableInspector
(
s
,
t
,
getMetaData
()
getMetaData
()
.
storesUpperCaseIdentifiers
(),
dateTimeClass
));
.
storesUpperCaseIdentifiers
(),
dateTimeClass
));
}
}
}
}
}
}
if
(
StringUtils
.
isNullOrEmpty
(
schema
)
&&
StringUtils
.
isNullOrEmpty
(
table
))
{
if
(
StringUtils
.
isNullOrEmpty
(
schema
)
&&
StringUtils
.
isNullOrEmpty
(
table
))
{
// all schemas and tables
// all schemas and tables
return
tables
;
return
tables
;
}
}
...
@@ -166,9 +173,10 @@ public class DbInspector {
...
@@ -166,9 +173,10 @@ public class DbInspector {
}
}
}
}
if
(
matches
.
size
()
==
0
)
{
if
(
matches
.
size
()
==
0
)
{
throw
new
RuntimeException
(
throw
new
RuntimeException
(
MessageFormat
.
format
(
MessageFormat
.
format
(
"Failed to find schema={0} table={1}"
,
"Failed to find schema={0} table={1}"
,
schema
==
null
?
""
:
schema
,
table
==
null
?
""
:
table
));
schema
==
null
?
""
:
schema
,
table
==
null
?
""
:
table
));
}
}
return
matches
;
return
matches
;
}
finally
{
}
finally
{
...
...
h2/src/tools/org/h2/jaqu/DbUpgrader.java
浏览文件 @
e2f5284c
...
@@ -39,7 +39,8 @@ public interface DbUpgrader {
...
@@ -39,7 +39,8 @@ public interface DbUpgrader {
* @return true for successful upgrade. If the upgrade is successful, the
* @return true for successful upgrade. If the upgrade is successful, the
* version registry is automatically updated.
* version registry is automatically updated.
*/
*/
boolean
upgradeTable
(
Db
db
,
String
schema
,
String
table
,
int
fromVersion
,
int
toVersion
);
boolean
upgradeTable
(
Db
db
,
String
schema
,
String
table
,
int
fromVersion
,
int
toVersion
);
/**
/**
* The default database upgrader. It throws runtime exception instead of
* The default database upgrader. It throws runtime exception instead of
...
@@ -50,12 +51,15 @@ public interface DbUpgrader {
...
@@ -50,12 +51,15 @@ public interface DbUpgrader {
@Override
@Override
public
boolean
upgradeDatabase
(
Db
db
,
int
fromVersion
,
int
toVersion
)
{
public
boolean
upgradeDatabase
(
Db
db
,
int
fromVersion
,
int
toVersion
)
{
throw
new
RuntimeException
(
"Please provide your own DbUpgrader implementation."
);
throw
new
RuntimeException
(
"Please provide your own DbUpgrader implementation."
);
}
}
@Override
@Override
public
boolean
upgradeTable
(
Db
db
,
String
schema
,
String
table
,
int
fromVersion
,
int
toVersion
)
{
public
boolean
upgradeTable
(
Db
db
,
String
schema
,
String
table
,
throw
new
RuntimeException
(
"Please provide your own DbUpgrader implementation."
);
int
fromVersion
,
int
toVersion
)
{
throw
new
RuntimeException
(
"Please provide your own DbUpgrader implementation."
);
}
}
}
}
...
...
h2/src/tools/org/h2/jaqu/DbVersion.java
浏览文件 @
e2f5284c
...
@@ -12,7 +12,8 @@ import org.h2.jaqu.Table.JQTable;
...
@@ -12,7 +12,8 @@ import org.h2.jaqu.Table.JQTable;
/**
/**
* A system table to track database and table versions.
* A system table to track database and table versions.
*/
*/
@JQTable
(
name
=
"_jq_versions"
,
primaryKey
=
"schemaName tableName"
,
memoryTable
=
true
)
@JQTable
(
name
=
"_jq_versions"
,
primaryKey
=
"schemaName tableName"
,
memoryTable
=
true
)
public
class
DbVersion
{
public
class
DbVersion
{
@JQColumn
(
name
=
"schemaName"
,
allowNull
=
false
)
@JQColumn
(
name
=
"schemaName"
,
allowNull
=
false
)
...
...
h2/src/tools/org/h2/jaqu/Define.java
浏览文件 @
e2f5284c
...
@@ -34,12 +34,14 @@ public class Define {
...
@@ -34,12 +34,14 @@ public class Define {
public
static
void
hashIndex
(
Object
column
)
{
public
static
void
hashIndex
(
Object
column
)
{
checkInDefine
();
checkInDefine
();
currentTableDefinition
.
addIndex
(
IndexType
.
HASH
,
new
Object
[]
{
column
});
currentTableDefinition
.
addIndex
(
IndexType
.
HASH
,
new
Object
[]
{
column
});
}
}
public
static
void
uniqueHashIndex
(
Object
column
)
{
public
static
void
uniqueHashIndex
(
Object
column
)
{
checkInDefine
();
checkInDefine
();
currentTableDefinition
.
addIndex
(
IndexType
.
UNIQUE_HASH
,
new
Object
[]
{
column
});
currentTableDefinition
.
addIndex
(
IndexType
.
UNIQUE_HASH
,
new
Object
[]
{
column
});
}
}
public
static
void
maxLength
(
Object
column
,
int
length
)
{
public
static
void
maxLength
(
Object
column
,
int
length
)
{
...
@@ -62,9 +64,10 @@ public class Define {
...
@@ -62,9 +64,10 @@ public class Define {
private
static
void
checkInDefine
()
{
private
static
void
checkInDefine
()
{
if
(
currentTable
==
null
)
{
if
(
currentTable
==
null
)
{
throw
new
RuntimeException
(
"This method may only be called "
+
throw
new
RuntimeException
(
"from within the define() method, and the define() method "
+
"This method may only be called "
"is called by the framework."
);
+
"from within the define() method, and the define() method "
+
"is called by the framework."
);
}
}
}
}
...
...
h2/src/tools/org/h2/jaqu/ModelUtils.java
浏览文件 @
e2f5284c
...
@@ -26,7 +26,8 @@ public class ModelUtils {
...
@@ -26,7 +26,8 @@ public class ModelUtils {
* The list of supported data types. It is used by the runtime mapping for
* The list of supported data types. It is used by the runtime mapping for
* CREATE statements.
* CREATE statements.
*/
*/
private
static
final
Map
<
Class
<?>,
String
>
SUPPORTED_TYPES
=
new
HashMap
<
Class
<?>,
String
>();
private
static
final
Map
<
Class
<?>,
String
>
SUPPORTED_TYPES
=
new
HashMap
<
Class
<?>,
String
>();
static
{
static
{
Map
<
Class
<?>,
String
>
m
=
SUPPORTED_TYPES
;
Map
<
Class
<?>,
String
>
m
=
SUPPORTED_TYPES
;
...
@@ -50,7 +51,8 @@ public class ModelUtils {
...
@@ -50,7 +51,8 @@ public class ModelUtils {
* Convert SQL type aliases to the list of supported types.
* Convert SQL type aliases to the list of supported types.
* This map is used by generation and validation.
* This map is used by generation and validation.
*/
*/
private
static
final
Map
<
String
,
String
>
SQL_TYPES
=
new
HashMap
<
String
,
String
>();
private
static
final
Map
<
String
,
String
>
SQL_TYPES
=
new
HashMap
<
String
,
String
>();
static
{
static
{
Map
<
String
,
String
>
m
=
SQL_TYPES
;
Map
<
String
,
String
>
m
=
SQL_TYPES
;
...
@@ -99,12 +101,15 @@ public class ModelUtils {
...
@@ -99,12 +101,15 @@ public class ModelUtils {
m
.
put
(
"SMALLDATETIME"
,
"TIMESTAMP"
);
m
.
put
(
"SMALLDATETIME"
,
"TIMESTAMP"
);
}
}
private
static
final
List
<
String
>
KEYWORDS
=
Arrays
.
asList
(
"abstract"
,
"assert"
,
"boolean"
,
"break"
,
"byte"
,
"case"
,
private
static
final
List
<
String
>
KEYWORDS
=
Arrays
.
asList
(
"abstract"
,
"catch"
,
"char"
,
"class"
,
"const"
,
"continue"
,
"default"
,
"do"
,
"double"
,
"else"
,
"enum"
,
"extends"
,
"assert"
,
"boolean"
,
"break"
,
"byte"
,
"case"
,
"catch"
,
"char"
,
"final"
,
"finally"
,
"float"
,
"for"
,
"goto"
,
"if"
,
"implements"
,
"import"
,
"instanceof"
,
"int"
,
"interface"
,
"class"
,
"const"
,
"continue"
,
"default"
,
"do"
,
"double"
,
"else"
,
"long"
,
"native"
,
"new"
,
"package"
,
"private"
,
"protected"
,
"public"
,
"return"
,
"short"
,
"static"
,
"enum"
,
"extends"
,
"final"
,
"finally"
,
"float"
,
"for"
,
"goto"
,
"strictfp"
,
"super"
,
"switch"
,
"synchronized"
,
"this"
,
"throw"
,
"throws"
,
"transient"
,
"try"
,
"void"
,
"if"
,
"implements"
,
"import"
,
"instanceof"
,
"int"
,
"interface"
,
"volatile"
,
"while"
,
"false"
,
"null"
,
"true"
);
"long"
,
"native"
,
"new"
,
"package"
,
"private"
,
"protected"
,
"public"
,
"return"
,
"short"
,
"static"
,
"strictfp"
,
"super"
,
"switch"
,
"synchronized"
,
"this"
,
"throw"
,
"throws"
,
"transient"
,
"try"
,
"void"
,
"volatile"
,
"while"
,
"false"
,
"null"
,
"true"
);
private
int
todoReviewWholeClass
;
private
int
todoReviewWholeClass
;
...
...
h2/src/tools/org/h2/jaqu/Query.java
浏览文件 @
e2f5284c
...
@@ -31,9 +31,11 @@ public class Query<T> {
...
@@ -31,9 +31,11 @@ public class Query<T> {
private
final
Db
db
;
private
final
Db
db
;
private
SelectTable
<
T
>
from
;
private
SelectTable
<
T
>
from
;
private
final
ArrayList
<
Token
>
conditions
=
New
.
arrayList
();
private
final
ArrayList
<
Token
>
conditions
=
New
.
arrayList
();
private
final
ArrayList
<
UpdateColumn
>
updateColumnDeclarations
=
New
.
arrayList
();
private
final
ArrayList
<
UpdateColumn
>
updateColumnDeclarations
=
New
.
arrayList
();
private
final
ArrayList
<
SelectTable
<?>>
joins
=
New
.
arrayList
();
private
final
ArrayList
<
SelectTable
<?>>
joins
=
New
.
arrayList
();
private
final
IdentityHashMap
<
Object
,
SelectColumn
<
T
>>
aliasMap
=
ClassUtils
.
newIdentityHashMap
();
private
final
IdentityHashMap
<
Object
,
SelectColumn
<
T
>>
aliasMap
=
ClassUtils
.
newIdentityHashMap
();
private
final
ArrayList
<
OrderExpression
<
T
>>
orderByList
=
New
.
arrayList
();
private
final
ArrayList
<
OrderExpression
<
T
>>
orderByList
=
New
.
arrayList
();
private
Object
[]
groupByExpressions
;
private
Object
[]
groupByExpressions
;
private
long
limit
;
private
long
limit
;
...
@@ -46,7 +48,8 @@ public class Query<T> {
...
@@ -46,7 +48,8 @@ public class Query<T> {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
static
<
T
>
Query
<
T
>
from
(
Db
db
,
T
alias
)
{
static
<
T
>
Query
<
T
>
from
(
Db
db
,
T
alias
)
{
Query
<
T
>
query
=
new
Query
<
T
>(
db
);
Query
<
T
>
query
=
new
Query
<
T
>(
db
);
TableDefinition
<
T
>
def
=
(
TableDefinition
<
T
>)
db
.
define
(
alias
.
getClass
());
TableDefinition
<
T
>
def
=
(
TableDefinition
<
T
>)
db
.
define
(
alias
.
getClass
());
query
.
from
=
new
SelectTable
<
T
>(
db
,
query
,
alias
,
false
);
query
.
from
=
new
SelectTable
<
T
>(
db
,
query
,
alias
,
false
);
def
.
initSelectObject
(
query
.
from
,
alias
,
query
.
aliasMap
);
def
.
initSelectObject
(
query
.
from
,
alias
,
query
.
aliasMap
);
return
query
;
return
query
;
...
@@ -253,7 +256,8 @@ public class Query<T> {
...
@@ -253,7 +256,8 @@ public class Query<T> {
try
{
try
{
Object
obj
=
f
.
get
(
filter
);
Object
obj
=
f
.
get
(
filter
);
if
(
obj
==
from
.
getAlias
())
{
if
(
obj
==
from
.
getAlias
())
{
List
<
TableDefinition
.
FieldDefinition
>
fields
=
from
.
getAliasDefinition
().
getFields
();
List
<
TableDefinition
.
FieldDefinition
>
fields
=
from
.
getAliasDefinition
().
getFields
();
String
name
=
f
.
getName
();
String
name
=
f
.
getName
();
for
(
TableDefinition
.
FieldDefinition
field
:
fields
)
{
for
(
TableDefinition
.
FieldDefinition
field
:
fields
)
{
String
n
=
name
+
"."
+
field
.
field
.
getName
();
String
n
=
name
+
"."
+
field
.
field
.
getName
();
...
@@ -266,7 +270,8 @@ public class Query<T> {
...
@@ -266,7 +270,8 @@ public class Query<T> {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
Token
filterCode
=
new
ClassReader
().
decompile
(
filter
,
fieldMap
,
"where"
);
Token
filterCode
=
new
ClassReader
().
decompile
(
filter
,
fieldMap
,
"where"
);
// String filterQuery = filterCode.toString();
// String filterQuery = filterCode.toString();
conditions
.
add
(
filterCode
);
conditions
.
add
(
filterCode
);
return
new
QueryWhere
<
T
>(
this
);
return
new
QueryWhere
<
T
>(
this
);
...
@@ -301,16 +306,16 @@ public class Query<T> {
...
@@ -301,16 +306,16 @@ public class Query<T> {
*/
*/
public
Query
<
T
>
orderBy
(
Object
...
expressions
)
{
public
Query
<
T
>
orderBy
(
Object
...
expressions
)
{
for
(
Object
expr
:
expressions
)
{
for
(
Object
expr
:
expressions
)
{
OrderExpression
<
T
>
e
=
OrderExpression
<
T
>
e
=
new
OrderExpression
<
T
>(
this
,
expr
,
false
,
new
OrderExpression
<
T
>(
this
,
expr
,
false
,
false
,
false
);
false
,
false
);
addOrderBy
(
e
);
addOrderBy
(
e
);
}
}
return
this
;
return
this
;
}
}
public
Query
<
T
>
orderByDesc
(
Object
expr
)
{
public
Query
<
T
>
orderByDesc
(
Object
expr
)
{
OrderExpression
<
T
>
e
=
OrderExpression
<
T
>
e
=
new
OrderExpression
<
T
>(
this
,
expr
,
true
,
false
,
new
OrderExpression
<
T
>(
this
,
expr
,
true
,
false
,
false
);
false
);
addOrderBy
(
e
);
addOrderBy
(
e
);
return
this
;
return
this
;
}
}
...
@@ -410,7 +415,8 @@ public class Query<T> {
...
@@ -410,7 +415,8 @@ public class Query<T> {
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
<
U
>
QueryJoin
innerJoin
(
U
alias
)
{
public
<
U
>
QueryJoin
innerJoin
(
U
alias
)
{
TableDefinition
<
T
>
def
=
(
TableDefinition
<
T
>)
db
.
define
(
alias
.
getClass
());
TableDefinition
<
T
>
def
=
(
TableDefinition
<
T
>)
db
.
define
(
alias
.
getClass
());
SelectTable
<
T
>
join
=
new
SelectTable
(
db
,
this
,
alias
,
false
);
SelectTable
<
T
>
join
=
new
SelectTable
(
db
,
this
,
alias
,
false
);
def
.
initSelectObject
(
join
,
alias
,
aliasMap
);
def
.
initSelectObject
(
join
,
alias
,
aliasMap
);
joins
.
add
(
join
);
joins
.
add
(
join
);
...
...
h2/src/tools/org/h2/jaqu/SQLDialect.java
浏览文件 @
e2f5284c
...
@@ -59,8 +59,8 @@ public interface SQLDialect {
...
@@ -59,8 +59,8 @@ public interface SQLDialect {
boolean
supportsMemoryTables
();
boolean
supportsMemoryTables
();
/**
/**
*
Default implementation of an SQL dialect.
*
Default implementation of an SQL dialect. Designed for an H2 database,
*
Designed for an H2 database,
and may be suitable for others.
* and may be suitable for others.
*/
*/
public
static
class
DefaultSQLDialect
implements
SQLDialect
{
public
static
class
DefaultSQLDialect
implements
SQLDialect
{
...
@@ -78,10 +78,11 @@ public interface SQLDialect {
...
@@ -78,10 +78,11 @@ public interface SQLDialect {
}
}
@Override
@Override
public
String
getCreateIndex
(
String
schema
,
String
table
,
IndexDefinition
index
)
{
public
String
getCreateIndex
(
String
schema
,
String
table
,
IndexDefinition
index
)
{
StatementBuilder
buff
=
new
StatementBuilder
();
StatementBuilder
buff
=
new
StatementBuilder
();
buff
.
append
(
"CREATE "
);
buff
.
append
(
"CREATE "
);
switch
(
index
.
type
)
{
switch
(
index
.
type
)
{
case
STANDARD:
case
STANDARD:
break
;
break
;
case
UNIQUE:
case
UNIQUE:
...
@@ -99,7 +100,7 @@ public interface SQLDialect {
...
@@ -99,7 +100,7 @@ public interface SQLDialect {
buff
.
append
(
" ON "
);
buff
.
append
(
" ON "
);
buff
.
append
(
table
);
buff
.
append
(
table
);
buff
.
append
(
"("
);
buff
.
append
(
"("
);
for
(
String
col
:
index
.
columnNames
)
{
for
(
String
col
:
index
.
columnNames
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
col
);
buff
.
append
(
col
);
}
}
...
...
h2/src/tools/org/h2/jaqu/SQLStatement.java
浏览文件 @
e2f5284c
...
@@ -91,7 +91,8 @@ public class SQLStatement {
...
@@ -91,7 +91,8 @@ public class SQLStatement {
}
}
}
}
private
static
void
setValue
(
PreparedStatement
prep
,
int
parameterIndex
,
Object
x
)
{
private
static
void
setValue
(
PreparedStatement
prep
,
int
parameterIndex
,
Object
x
)
{
try
{
try
{
prep
.
setObject
(
parameterIndex
,
x
);
prep
.
setObject
(
parameterIndex
,
x
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
...
h2/src/tools/org/h2/jaqu/SelectTable.java
浏览文件 @
e2f5284c
...
@@ -15,7 +15,7 @@ import org.h2.util.New;
...
@@ -15,7 +15,7 @@ import org.h2.util.New;
*
*
* @param <T> the table class
* @param <T> the table class
*/
*/
class
SelectTable
<
T
>
{
class
SelectTable
<
T
>
{
private
static
int
asCounter
;
private
static
int
asCounter
;
private
final
Query
<
T
>
query
;
private
final
Query
<
T
>
query
;
...
@@ -51,7 +51,8 @@ class SelectTable <T> {
...
@@ -51,7 +51,8 @@ class SelectTable <T> {
void
appendSQL
(
SQLStatement
stat
)
{
void
appendSQL
(
SQLStatement
stat
)
{
if
(
query
.
isJoin
())
{
if
(
query
.
isJoin
())
{
stat
.
appendTable
(
aliasDef
.
schemaName
,
aliasDef
.
tableName
).
appendSQL
(
" AS "
+
as
);
stat
.
appendTable
(
aliasDef
.
schemaName
,
aliasDef
.
tableName
)
.
appendSQL
(
" AS "
+
as
);
}
else
{
}
else
{
stat
.
appendTable
(
aliasDef
.
schemaName
,
aliasDef
.
tableName
);
stat
.
appendTable
(
aliasDef
.
schemaName
,
aliasDef
.
tableName
);
}
}
...
...
h2/src/tools/org/h2/jaqu/TableDefinition.java
浏览文件 @
e2f5284c
...
@@ -354,7 +354,8 @@ class TableDefinition<T> {
...
@@ -354,7 +354,8 @@ class TableDefinition<T> {
}
}
SQLStatement
stat
=
new
SQLStatement
(
db
);
SQLStatement
stat
=
new
SQLStatement
(
db
);
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
buff
.
append
(
db
.
getDialect
().
getTableName
(
schemaName
,
tableName
)).
append
(
" SET "
);
buff
.
append
(
db
.
getDialect
().
getTableName
(
schemaName
,
tableName
))
.
append
(
" SET "
);
buff
.
resetCount
();
buff
.
resetCount
();
for
(
FieldDefinition
field
:
fields
)
{
for
(
FieldDefinition
field
:
fields
)
{
...
...
h2/src/tools/org/h2/jaqu/TableInspector.java
浏览文件 @
e2f5284c
差异被折叠。
点击展开。
h2/src/tools/org/h2/jaqu/ValidationRemark.java
浏览文件 @
e2f5284c
...
@@ -30,7 +30,8 @@ public class ValidationRemark {
...
@@ -30,7 +30,8 @@ public class ValidationRemark {
private
final
String
fieldName
;
private
final
String
fieldName
;
private
final
String
message
;
private
final
String
message
;
private
ValidationRemark
(
Level
level
,
String
table
,
String
type
,
String
message
)
{
private
ValidationRemark
(
Level
level
,
String
table
,
String
type
,
String
message
)
{
this
.
level
=
level
;
this
.
level
=
level
;
this
.
table
=
table
;
this
.
table
=
table
;
this
.
fieldType
=
type
;
this
.
fieldType
=
type
;
...
@@ -38,7 +39,8 @@ public class ValidationRemark {
...
@@ -38,7 +39,8 @@ public class ValidationRemark {
this
.
message
=
message
;
this
.
message
=
message
;
}
}
private
ValidationRemark
(
Level
level
,
String
table
,
FieldDefinition
field
,
String
message
)
{
private
ValidationRemark
(
Level
level
,
String
table
,
FieldDefinition
field
,
String
message
)
{
this
.
level
=
level
;
this
.
level
=
level
;
this
.
table
=
table
;
this
.
table
=
table
;
this
.
fieldType
=
field
.
dataType
;
this
.
fieldType
=
field
.
dataType
;
...
@@ -46,7 +48,8 @@ public class ValidationRemark {
...
@@ -46,7 +48,8 @@ public class ValidationRemark {
this
.
message
=
message
;
this
.
message
=
message
;
}
}
private
ValidationRemark
(
Level
level
,
String
table
,
ColumnInspector
col
,
String
message
)
{
private
ValidationRemark
(
Level
level
,
String
table
,
ColumnInspector
col
,
String
message
)
{
this
.
level
=
level
;
this
.
level
=
level
;
this
.
table
=
table
;
this
.
table
=
table
;
this
.
fieldType
=
col
.
type
;
this
.
fieldType
=
col
.
type
;
...
@@ -54,31 +57,38 @@ public class ValidationRemark {
...
@@ -54,31 +57,38 @@ public class ValidationRemark {
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
static
ValidationRemark
consider
(
String
table
,
String
type
,
String
message
)
{
public
static
ValidationRemark
consider
(
String
table
,
String
type
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
CONSIDER
,
table
,
type
,
message
);
return
new
ValidationRemark
(
Level
.
CONSIDER
,
table
,
type
,
message
);
}
}
public
static
ValidationRemark
consider
(
String
table
,
ColumnInspector
col
,
String
message
)
{
public
static
ValidationRemark
consider
(
String
table
,
ColumnInspector
col
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
CONSIDER
,
table
,
col
,
message
);
return
new
ValidationRemark
(
Level
.
CONSIDER
,
table
,
col
,
message
);
}
}
public
static
ValidationRemark
warn
(
String
table
,
ColumnInspector
col
,
String
message
)
{
public
static
ValidationRemark
warn
(
String
table
,
ColumnInspector
col
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
WARN
,
table
,
col
,
message
);
return
new
ValidationRemark
(
Level
.
WARN
,
table
,
col
,
message
);
}
}
public
static
ValidationRemark
warn
(
String
table
,
String
type
,
String
message
)
{
public
static
ValidationRemark
warn
(
String
table
,
String
type
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
WARN
,
table
,
type
,
message
);
return
new
ValidationRemark
(
Level
.
WARN
,
table
,
type
,
message
);
}
}
public
static
ValidationRemark
error
(
String
table
,
ColumnInspector
col
,
String
message
)
{
public
static
ValidationRemark
error
(
String
table
,
ColumnInspector
col
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
col
,
message
);
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
col
,
message
);
}
}
public
static
ValidationRemark
error
(
String
table
,
String
type
,
String
message
)
{
public
static
ValidationRemark
error
(
String
table
,
String
type
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
type
,
message
);
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
type
,
message
);
}
}
public
static
ValidationRemark
error
(
String
table
,
FieldDefinition
field
,
String
message
)
{
public
static
ValidationRemark
error
(
String
table
,
FieldDefinition
field
,
String
message
)
{
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
field
,
message
);
return
new
ValidationRemark
(
Level
.
ERROR
,
table
,
field
,
message
);
}
}
...
...
h2/src/tools/org/h2/jaqu/bytecode/ClassReader.java
浏览文件 @
e2f5284c
差异被折叠。
点击展开。
h2/src/tools/org/h2/jaqu/util/ClassUtils.java
浏览文件 @
e2f5284c
...
@@ -93,8 +93,8 @@ public class ClassUtils {
...
@@ -93,8 +93,8 @@ public class ClassUtils {
}
}
}
}
}
}
throw
new
RuntimeException
(
"Exception trying to create "
+
throw
new
RuntimeException
(
"Exception trying to create "
clazz
.
getName
()
+
": "
+
e
,
e
);
+
clazz
.
getName
()
+
": "
+
e
,
e
);
}
}
}
}
...
@@ -122,7 +122,9 @@ public class ClassUtils {
...
@@ -122,7 +122,9 @@ public class ClassUtils {
Reader
r
=
c
.
getCharacterStream
();
Reader
r
=
c
.
getCharacterStream
();
return
IOUtils
.
readStringAndClose
(
r
,
-
1
);
return
IOUtils
.
readStringAndClose
(
r
,
-
1
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Error converting CLOB to String: "
+
e
.
toString
(),
e
);
throw
new
RuntimeException
(
"Error converting CLOB to String: "
+
e
.
toString
(),
e
);
}
}
}
}
return
o
.
toString
();
return
o
.
toString
();
...
@@ -143,8 +145,8 @@ public class ClassUtils {
...
@@ -143,8 +145,8 @@ public class ClassUtils {
return
n
.
floatValue
();
return
n
.
floatValue
();
}
}
}
}
throw
new
RuntimeException
(
"Can not convert the value "
+
o
+
throw
new
RuntimeException
(
"Can not convert the value "
+
o
+
" from "
" from "
+
currentType
+
" to "
+
targetType
);
+
currentType
+
" to "
+
targetType
);
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
h2/src/tools/org/h2/jaqu/util/GenerateModels.java
浏览文件 @
e2f5284c
...
@@ -71,7 +71,8 @@ public class GenerateModels {
...
@@ -71,7 +71,8 @@ public class GenerateModels {
try
{
try
{
annotateSchema
=
Boolean
.
parseBoolean
(
args
[++
i
]);
annotateSchema
=
Boolean
.
parseBoolean
(
args
[++
i
]);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
throw
new
SQLException
(
"Can not parse -annotateSchema value"
);
throw
new
SQLException
(
"Can not parse -annotateSchema value"
);
}
}
}
else
if
(
arg
.
equals
(
"-trimStrings"
))
{
}
else
if
(
arg
.
equals
(
"-trimStrings"
))
{
try
{
try
{
...
@@ -99,14 +100,14 @@ public class GenerateModels {
...
@@ -99,14 +100,14 @@ public class GenerateModels {
* @param schema the schema to read from. null for all schemas.
* @param schema the schema to read from. null for all schemas.
* @param table the table to model. null for all tables within schema.
* @param table the table to model. null for all tables within schema.
* @param packageName the package name of the model classes.
* @param packageName the package name of the model classes.
* @param folder destination folder for model classes (package path not included)
* @param folder destination folder for model classes (package path not
* included)
* @param annotateSchema includes the schema in the table model annotations
* @param annotateSchema includes the schema in the table model annotations
* @param trimStrings automatically trim strings that exceed maxLength
* @param trimStrings automatically trim strings that exceed maxLength
*/
*/
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
public
static
void
execute
(
String
url
,
String
user
,
String
password
,
String
schema
,
String
table
,
String
packageName
,
String
folder
,
String
schema
,
String
table
,
String
packageName
,
String
folder
,
boolean
annotateSchema
,
boolean
trimStrings
)
boolean
annotateSchema
,
boolean
trimStrings
)
throws
SQLException
{
throws
SQLException
{
Connection
conn
=
null
;
Connection
conn
=
null
;
try
{
try
{
org
.
h2
.
Driver
.
load
();
org
.
h2
.
Driver
.
load
();
...
@@ -126,17 +127,21 @@ public class GenerateModels {
...
@@ -126,17 +127,21 @@ public class GenerateModels {
for
(
String
model
:
models
)
{
for
(
String
model
:
models
)
{
Matcher
m
=
p
.
matcher
(
model
);
Matcher
m
=
p
.
matcher
(
model
);
if
(
m
.
find
())
{
if
(
m
.
find
())
{
String
className
=
m
.
group
().
substring
(
"class"
.
length
()).
trim
();
String
className
=
m
.
group
().
substring
(
"class"
.
length
())
.
trim
();
File
classFile
=
new
File
(
parentFile
,
className
+
".java"
);
File
classFile
=
new
File
(
parentFile
,
className
+
".java"
);
Writer
o
=
new
FileWriter
(
classFile
,
false
);
Writer
o
=
new
FileWriter
(
classFile
,
false
);
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
o
));
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
o
));
writer
.
write
(
model
);
writer
.
write
(
model
);
writer
.
close
();
writer
.
close
();
System
.
out
.
println
(
"Generated "
+
classFile
.
getAbsolutePath
());
System
.
out
.
println
(
"Generated "
+
classFile
.
getAbsolutePath
());
}
}
}
}
}
catch
(
IOException
io
)
{
}
catch
(
IOException
io
)
{
throw
DbException
.
convertIOException
(
io
,
"could not generate model"
).
getSQLException
();
throw
DbException
.
convertIOException
(
io
,
"could not generate model"
)
.
getSQLException
();
}
finally
{
}
finally
{
JdbcUtils
.
closeSilently
(
conn
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
...
@@ -148,14 +153,15 @@ public class GenerateModels {
...
@@ -148,14 +153,15 @@ public class GenerateModels {
* @param option the unsupported option
* @param option the unsupported option
* @return this method never returns normally
* @return this method never returns normally
*/
*/
protected
SQLException
throwUnsupportedOption
(
String
option
)
throws
SQLException
{
protected
SQLException
throwUnsupportedOption
(
String
option
)
throws
SQLException
{
showUsage
();
showUsage
();
throw
new
SQLException
(
"Unsupported option: "
+
option
);
throw
new
SQLException
(
"Unsupported option: "
+
option
);
}
}
protected
void
showUsage
()
{
protected
void
showUsage
()
{
out
.
println
(
"GenerateModels"
);
out
.
println
(
"GenerateModels"
);
out
.
println
(
"Usage: java "
+
getClass
().
getName
());
out
.
println
(
"Usage: java "
+
getClass
().
getName
());
out
.
println
();
out
.
println
();
out
.
println
(
"(*) -url jdbc:h2:~test"
);
out
.
println
(
"(*) -url jdbc:h2:~test"
);
out
.
println
(
" -user <string>"
);
out
.
println
(
" -user <string>"
);
...
...
h2/src/tools/org/h2/java/ClassObj.java
浏览文件 @
e2f5284c
...
@@ -58,17 +58,20 @@ public class ClassObj {
...
@@ -58,17 +58,20 @@ public class ClassObj {
/**
/**
* The per-instance fields.
* The per-instance fields.
*/
*/
LinkedHashMap
<
String
,
FieldObj
>
instanceFields
=
new
LinkedHashMap
<
String
,
FieldObj
>();
LinkedHashMap
<
String
,
FieldObj
>
instanceFields
=
new
LinkedHashMap
<
String
,
FieldObj
>();
/**
/**
* The static fields of this class.
* The static fields of this class.
*/
*/
LinkedHashMap
<
String
,
FieldObj
>
staticFields
=
new
LinkedHashMap
<
String
,
FieldObj
>();
LinkedHashMap
<
String
,
FieldObj
>
staticFields
=
new
LinkedHashMap
<
String
,
FieldObj
>();
/**
/**
* The methods.
* The methods.
*/
*/
LinkedHashMap
<
String
,
ArrayList
<
MethodObj
>>
methods
=
new
LinkedHashMap
<
String
,
ArrayList
<
MethodObj
>>();
LinkedHashMap
<
String
,
ArrayList
<
MethodObj
>>
methods
=
new
LinkedHashMap
<
String
,
ArrayList
<
MethodObj
>>();
/**
/**
* The list of native statements.
* The list of native statements.
...
@@ -125,6 +128,7 @@ public class ClassObj {
...
@@ -125,6 +128,7 @@ public class ClassObj {
staticFields
.
put
(
field
.
name
,
field
);
staticFields
.
put
(
field
.
name
,
field
);
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
if
(
isPrimitive
)
{
if
(
isPrimitive
)
{
return
"j"
+
className
;
return
"j"
+
className
;
...
@@ -178,10 +182,12 @@ public class ClassObj {
...
@@ -178,10 +182,12 @@ public class ClassObj {
return
instanceFields
.
get
(
name
);
return
instanceFields
.
get
(
name
);
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
className
.
hashCode
();
return
className
.
hashCode
();
}
}
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(
other
instanceof
ClassObj
)
{
if
(
other
instanceof
ClassObj
)
{
ClassObj
c
=
(
ClassObj
)
other
;
ClassObj
c
=
(
ClassObj
)
other
;
...
@@ -240,7 +246,8 @@ class MethodObj {
...
@@ -240,7 +246,8 @@ class MethodObj {
/**
/**
* The parameter list.
* The parameter list.
*/
*/
LinkedHashMap
<
String
,
FieldObj
>
parameters
=
new
LinkedHashMap
<
String
,
FieldObj
>();
LinkedHashMap
<
String
,
FieldObj
>
parameters
=
new
LinkedHashMap
<
String
,
FieldObj
>();
/**
/**
* Whether this method is final.
* Whether this method is final.
...
@@ -262,6 +269,7 @@ class MethodObj {
...
@@ -262,6 +269,7 @@ class MethodObj {
*/
*/
boolean
isConstructor
;
boolean
isConstructor
;
@Override
public
String
toString
()
{
public
String
toString
()
{
return
name
;
return
name
;
}
}
...
@@ -328,6 +336,7 @@ class FieldObj {
...
@@ -328,6 +336,7 @@ class FieldObj {
*/
*/
ClassObj
declaredClass
;
ClassObj
declaredClass
;
@Override
public
String
toString
()
{
public
String
toString
()
{
return
name
;
return
name
;
}
}
...
@@ -368,6 +377,7 @@ class Type {
...
@@ -368,6 +377,7 @@ class Type {
return
arrayLevel
>
0
||
!
classObj
.
isPrimitive
;
return
arrayLevel
>
0
||
!
classObj
.
isPrimitive
;
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
return
asString
();
return
asString
();
}
}
...
@@ -414,14 +424,17 @@ class Type {
...
@@ -414,14 +424,17 @@ class Type {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
toString
().
hashCode
();
return
toString
().
hashCode
();
}
}
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(
other
instanceof
Type
)
{
if
(
other
instanceof
Type
)
{
Type
t
=
(
Type
)
other
;
Type
t
=
(
Type
)
other
;
return
t
.
classObj
.
equals
(
classObj
)
&&
t
.
arrayLevel
==
arrayLevel
&&
t
.
isVarArgs
==
isVarArgs
;
return
t
.
classObj
.
equals
(
classObj
)
&&
t
.
arrayLevel
==
arrayLevel
&&
t
.
isVarArgs
==
isVarArgs
;
}
}
return
false
;
return
false
;
}
}
...
...
h2/src/tools/org/h2/java/Expr.java
浏览文件 @
e2f5284c
...
@@ -30,6 +30,7 @@ public interface Expr {
...
@@ -30,6 +30,7 @@ public interface Expr {
* The base expression class.
* The base expression class.
*/
*/
abstract
class
ExprBase
implements
Expr
{
abstract
class
ExprBase
implements
Expr
{
@Override
public
final
String
toString
()
{
public
final
String
toString
()
{
return
"_"
+
asString
()
+
"_"
;
return
"_"
+
asString
()
+
"_"
;
}
}
...
@@ -75,6 +76,7 @@ class CallExpr extends ExprBase {
...
@@ -75,6 +76,7 @@ class CallExpr extends ExprBase {
}
}
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
initMethod
();
initMethod
();
...
@@ -112,11 +114,13 @@ class CallExpr extends ExprBase {
...
@@ -112,11 +114,13 @@ class CallExpr extends ExprBase {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
initMethod
();
initMethod
();
return
method
.
returnType
;
return
method
.
returnType
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -148,15 +152,18 @@ class AssignExpr extends ExprBase {
...
@@ -148,15 +152,18 @@ class AssignExpr extends ExprBase {
*/
*/
Type
type
;
Type
type
;
@Override
public
String
asString
()
{
public
String
asString
()
{
right
.
setType
(
left
.
getType
());
right
.
setType
(
left
.
getType
());
return
left
.
asString
()
+
" "
+
op
+
" "
+
right
.
asString
();
return
left
.
asString
()
+
" "
+
op
+
" "
+
right
.
asString
();
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
return
left
.
getType
();
return
left
.
getType
();
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -183,14 +190,18 @@ class ConditionalExpr extends ExprBase {
...
@@ -183,14 +190,18 @@ class ConditionalExpr extends ExprBase {
*/
*/
Expr
ifFalse
;
Expr
ifFalse
;
@Override
public
String
asString
()
{
public
String
asString
()
{
return
condition
.
asString
()
+
" ? "
+
ifTrue
.
asString
()
+
" : "
+
ifFalse
.
asString
();
return
condition
.
asString
()
+
" ? "
+
ifTrue
.
asString
()
+
" : "
+
ifFalse
.
asString
();
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
return
ifTrue
.
getType
();
return
ifTrue
.
getType
();
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
ifTrue
.
setType
(
type
);
ifTrue
.
setType
(
type
);
ifFalse
.
setType
(
type
);
ifFalse
.
setType
(
type
);
...
@@ -217,6 +228,7 @@ class LiteralExpr extends ExprBase {
...
@@ -217,6 +228,7 @@ class LiteralExpr extends ExprBase {
this
.
className
=
className
;
this
.
className
=
className
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
if
(
"null"
.
equals
(
literal
))
{
if
(
"null"
.
equals
(
literal
))
{
Type
t
=
getType
();
Type
t
=
getType
();
...
@@ -228,6 +240,7 @@ class LiteralExpr extends ExprBase {
...
@@ -228,6 +240,7 @@ class LiteralExpr extends ExprBase {
return
literal
;
return
literal
;
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
if
(
type
==
null
)
{
if
(
type
==
null
)
{
type
=
new
Type
();
type
=
new
Type
();
...
@@ -236,6 +249,7 @@ class LiteralExpr extends ExprBase {
...
@@ -236,6 +249,7 @@ class LiteralExpr extends ExprBase {
return
type
;
return
type
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -269,6 +283,7 @@ class OpExpr extends ExprBase {
...
@@ -269,6 +283,7 @@ class OpExpr extends ExprBase {
this
.
context
=
context
;
this
.
context
=
context
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
if
(
left
==
null
)
{
if
(
left
==
null
)
{
return
op
+
right
.
asString
();
return
op
+
right
.
asString
();
...
@@ -316,6 +331,7 @@ class OpExpr extends ExprBase {
...
@@ -316,6 +331,7 @@ class OpExpr extends ExprBase {
op
.
equals
(
">="
)
||
op
.
equals
(
"<="
)
||
op
.
equals
(
"!="
);
op
.
equals
(
">="
)
||
op
.
equals
(
"<="
)
||
op
.
equals
(
"!="
);
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
if
(
left
==
null
)
{
if
(
left
==
null
)
{
return
right
.
getType
();
return
right
.
getType
();
...
@@ -343,6 +359,7 @@ class OpExpr extends ExprBase {
...
@@ -343,6 +359,7 @@ class OpExpr extends ExprBase {
return
lt
;
return
lt
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -374,6 +391,7 @@ class NewExpr extends ExprBase {
...
@@ -374,6 +391,7 @@ class NewExpr extends ExprBase {
*/
*/
Type
type
;
Type
type
;
@Override
public
String
asString
()
{
public
String
asString
()
{
boolean
refCount
=
type
.
refCount
;
boolean
refCount
=
type
.
refCount
;
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
@@ -416,6 +434,7 @@ class NewExpr extends ExprBase {
...
@@ -416,6 +434,7 @@ class NewExpr extends ExprBase {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
Type
t
=
new
Type
();
Type
t
=
new
Type
();
t
.
classObj
=
classObj
;
t
.
classObj
=
classObj
;
...
@@ -423,6 +442,7 @@ class NewExpr extends ExprBase {
...
@@ -423,6 +442,7 @@ class NewExpr extends ExprBase {
return
t
;
return
t
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -451,10 +471,12 @@ class StringExpr extends ExprBase {
...
@@ -451,10 +471,12 @@ class StringExpr extends ExprBase {
this
.
context
=
context
;
this
.
context
=
context
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
constantName
;
return
constantName
;
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
if
(
type
==
null
)
{
if
(
type
==
null
)
{
type
=
new
Type
();
type
=
new
Type
();
...
@@ -517,6 +539,7 @@ class StringExpr extends ExprBase {
...
@@ -517,6 +539,7 @@ class StringExpr extends ExprBase {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
// ignore
// ignore
}
}
...
@@ -550,6 +573,7 @@ class VariableExpr extends ExprBase {
...
@@ -550,6 +573,7 @@ class VariableExpr extends ExprBase {
this
.
context
=
context
;
this
.
context
=
context
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
init
();
init
();
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
@@ -586,11 +610,13 @@ class VariableExpr extends ExprBase {
...
@@ -586,11 +610,13 @@ class VariableExpr extends ExprBase {
}
}
}
}
@Override
public
Type
getType
()
{
public
Type
getType
()
{
init
();
init
();
return
field
.
type
;
return
field
.
type
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -612,10 +638,12 @@ class ArrayInitExpr extends ExprBase {
...
@@ -612,10 +638,12 @@ class ArrayInitExpr extends ExprBase {
*/
*/
Type
type
;
Type
type
;
@Override
public
Type
getType
()
{
public
Type
getType
()
{
return
type
;
return
type
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
(
"{ "
);
StringBuilder
buff
=
new
StringBuilder
(
"{ "
);
int
i
=
0
;
int
i
=
0
;
...
@@ -629,6 +657,7 @@ class ArrayInitExpr extends ExprBase {
...
@@ -629,6 +657,7 @@ class ArrayInitExpr extends ExprBase {
return
buff
.
toString
();
return
buff
.
toString
();
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -650,14 +679,17 @@ class CastExpr extends ExprBase {
...
@@ -650,14 +679,17 @@ class CastExpr extends ExprBase {
*/
*/
Type
type
;
Type
type
;
@Override
public
Type
getType
()
{
public
Type
getType
()
{
return
type
;
return
type
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
"("
+
type
.
asString
()
+
") "
+
expr
.
asString
();
return
"("
+
type
.
asString
()
+
") "
+
expr
.
asString
();
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -684,6 +716,7 @@ class ArrayAccessExpr extends ExprBase {
...
@@ -684,6 +716,7 @@ class ArrayAccessExpr extends ExprBase {
*/
*/
Type
type
;
Type
type
;
@Override
public
Type
getType
()
{
public
Type
getType
()
{
Type
t
=
new
Type
();
Type
t
=
new
Type
();
t
.
classObj
=
base
.
getType
().
classObj
;
t
.
classObj
=
base
.
getType
().
classObj
;
...
@@ -691,10 +724,12 @@ class ArrayAccessExpr extends ExprBase {
...
@@ -691,10 +724,12 @@ class ArrayAccessExpr extends ExprBase {
return
t
;
return
t
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
base
.
asString
()
+
"->at("
+
index
.
asString
()
+
")"
;
return
base
.
asString
()
+
"->at("
+
index
.
asString
()
+
")"
;
}
}
@Override
public
void
setType
(
Type
type
)
{
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
...
h2/src/tools/org/h2/java/JavaParser.java
浏览文件 @
e2f5284c
差异被折叠。
点击展开。
h2/src/tools/org/h2/java/Statement.java
浏览文件 @
e2f5284c
...
@@ -30,6 +30,7 @@ public interface Statement {
...
@@ -30,6 +30,7 @@ public interface Statement {
*/
*/
abstract
class
StatementBase
implements
Statement
{
abstract
class
StatementBase
implements
Statement
{
@Override
public
boolean
isEnd
()
{
public
boolean
isEnd
()
{
return
false
;
return
false
;
}
}
...
@@ -48,10 +49,12 @@ class ReturnStatement extends StatementBase {
...
@@ -48,10 +49,12 @@ class ReturnStatement extends StatementBase {
private
MethodObj
method
;
private
MethodObj
method
;
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
this
.
method
=
method
;
this
.
method
=
method
;
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
if
(
expr
==
null
)
{
if
(
expr
==
null
)
{
return
"return;"
;
return
"return;"
;
...
@@ -84,10 +87,12 @@ class DoWhileStatement extends StatementBase {
...
@@ -84,10 +87,12 @@ class DoWhileStatement extends StatementBase {
*/
*/
Statement
block
;
Statement
block
;
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
block
.
setMethod
(
method
);
block
.
setMethod
(
method
);
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
"do {\n"
+
block
+
"} while ("
+
condition
.
asString
()
+
");"
;
return
"do {\n"
+
block
+
"} while ("
+
condition
.
asString
()
+
");"
;
}
}
...
@@ -99,10 +104,12 @@ class DoWhileStatement extends StatementBase {
...
@@ -99,10 +104,12 @@ class DoWhileStatement extends StatementBase {
*/
*/
class
ContinueStatement
extends
StatementBase
{
class
ContinueStatement
extends
StatementBase
{
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
"continue;"
;
return
"continue;"
;
}
}
...
@@ -114,10 +121,12 @@ class ContinueStatement extends StatementBase {
...
@@ -114,10 +121,12 @@ class ContinueStatement extends StatementBase {
*/
*/
class
BreakStatement
extends
StatementBase
{
class
BreakStatement
extends
StatementBase
{
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
"break;"
;
return
"break;"
;
}
}
...
@@ -129,10 +138,12 @@ class BreakStatement extends StatementBase {
...
@@ -129,10 +138,12 @@ class BreakStatement extends StatementBase {
*/
*/
class
EmptyStatement
extends
StatementBase
{
class
EmptyStatement
extends
StatementBase
{
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
";"
;
return
";"
;
}
}
...
@@ -146,13 +157,15 @@ class SwitchStatement extends StatementBase {
...
@@ -146,13 +157,15 @@ class SwitchStatement extends StatementBase {
private
StatementBlock
defaultBlock
;
private
StatementBlock
defaultBlock
;
private
final
ArrayList
<
Expr
>
cases
=
new
ArrayList
<
Expr
>();
private
final
ArrayList
<
Expr
>
cases
=
new
ArrayList
<
Expr
>();
private
final
ArrayList
<
StatementBlock
>
blocks
=
new
ArrayList
<
StatementBlock
>();
private
final
ArrayList
<
StatementBlock
>
blocks
=
new
ArrayList
<
StatementBlock
>();
private
final
Expr
expr
;
private
final
Expr
expr
;
public
SwitchStatement
(
Expr
expr
)
{
public
SwitchStatement
(
Expr
expr
)
{
this
.
expr
=
expr
;
this
.
expr
=
expr
;
}
}
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
defaultBlock
.
setMethod
(
method
);
defaultBlock
.
setMethod
(
method
);
for
(
StatementBlock
b
:
blocks
)
{
for
(
StatementBlock
b
:
blocks
)
{
...
@@ -160,6 +173,7 @@ class SwitchStatement extends StatementBase {
...
@@ -160,6 +173,7 @@ class SwitchStatement extends StatementBase {
}
}
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"switch ("
).
append
(
expr
.
asString
()).
append
(
") {\n"
);
buff
.
append
(
"switch ("
).
append
(
expr
.
asString
()).
append
(
") {\n"
);
...
@@ -203,10 +217,12 @@ class ExprStatement extends StatementBase {
...
@@ -203,10 +217,12 @@ class ExprStatement extends StatementBase {
this
.
expr
=
expr
;
this
.
expr
=
expr
;
}
}
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
expr
.
asString
()
+
";"
;
return
expr
.
asString
()
+
";"
;
}
}
...
@@ -228,10 +244,12 @@ class WhileStatement extends StatementBase {
...
@@ -228,10 +244,12 @@ class WhileStatement extends StatementBase {
*/
*/
Statement
block
;
Statement
block
;
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
block
.
setMethod
(
method
);
block
.
setMethod
(
method
);
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
String
w
=
"while ("
+
condition
.
asString
()
+
")"
;
String
w
=
"while ("
+
condition
.
asString
()
+
")"
;
String
s
=
block
.
toString
();
String
s
=
block
.
toString
();
...
@@ -260,6 +278,7 @@ class IfStatement extends StatementBase {
...
@@ -260,6 +278,7 @@ class IfStatement extends StatementBase {
*/
*/
Statement
elseBlock
;
Statement
elseBlock
;
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
block
.
setMethod
(
method
);
block
.
setMethod
(
method
);
if
(
elseBlock
!=
null
)
{
if
(
elseBlock
!=
null
)
{
...
@@ -267,6 +286,7 @@ class IfStatement extends StatementBase {
...
@@ -267,6 +286,7 @@ class IfStatement extends StatementBase {
}
}
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
String
w
=
"if ("
+
condition
.
asString
()
+
") {\n"
;
String
w
=
"if ("
+
condition
.
asString
()
+
") {\n"
;
String
s
=
block
.
asString
();
String
s
=
block
.
asString
();
...
@@ -318,10 +338,12 @@ class ForStatement extends StatementBase {
...
@@ -318,10 +338,12 @@ class ForStatement extends StatementBase {
*/
*/
Expr
iterable
;
Expr
iterable
;
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
block
.
setMethod
(
method
);
block
.
setMethod
(
method
);
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
"for ("
);
buff
.
append
(
"for ("
);
...
@@ -372,12 +394,14 @@ class StatementBlock extends StatementBase {
...
@@ -372,12 +394,14 @@ class StatementBlock extends StatementBase {
*/
*/
final
ArrayList
<
Statement
>
instructions
=
new
ArrayList
<
Statement
>();
final
ArrayList
<
Statement
>
instructions
=
new
ArrayList
<
Statement
>();
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
for
(
Statement
s
:
instructions
)
{
for
(
Statement
s
:
instructions
)
{
s
.
setMethod
(
method
);
s
.
setMethod
(
method
);
}
}
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
Statement
s
:
instructions
)
{
for
(
Statement
s
:
instructions
)
{
...
@@ -404,10 +428,12 @@ class VarDecStatement extends StatementBase {
...
@@ -404,10 +428,12 @@ class VarDecStatement extends StatementBase {
private
final
ArrayList
<
String
>
variables
=
new
ArrayList
<
String
>();
private
final
ArrayList
<
String
>
variables
=
new
ArrayList
<
String
>();
private
final
ArrayList
<
Expr
>
values
=
new
ArrayList
<
Expr
>();
private
final
ArrayList
<
Expr
>
values
=
new
ArrayList
<
Expr
>();
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
type
.
asString
()).
append
(
' '
);
buff
.
append
(
type
.
asString
()).
append
(
' '
);
...
@@ -460,14 +486,17 @@ class StatementNative extends StatementBase {
...
@@ -460,14 +486,17 @@ class StatementNative extends StatementBase {
this
.
code
=
code
;
this
.
code
=
code
;
}
}
@Override
public
void
setMethod
(
MethodObj
method
)
{
public
void
setMethod
(
MethodObj
method
)
{
// ignore
// ignore
}
}
@Override
public
String
asString
()
{
public
String
asString
()
{
return
code
;
return
code
;
}
}
@Override
public
boolean
isEnd
()
{
public
boolean
isEnd
()
{
return
code
.
equals
(
"return;"
);
return
code
.
equals
(
"return;"
);
}
}
...
...
h2/src/tools/org/h2/java/Test.java
浏览文件 @
e2f5284c
...
@@ -25,6 +25,7 @@ public class Test extends TestBase {
...
@@ -25,6 +25,7 @@ public class Test extends TestBase {
new
Test
().
test
();
new
Test
().
test
();
}
}
@Override
public
void
test
()
throws
IOException
{
public
void
test
()
throws
IOException
{
// g++ -o test test.cpp
// g++ -o test test.cpp
// chmod +x test
// chmod +x test
...
...
h2/src/tools/org/h2/java/lang/Object.java
浏览文件 @
e2f5284c
...
@@ -11,6 +11,7 @@ package org.h2.java.lang;
...
@@ -11,6 +11,7 @@ package org.h2.java.lang;
*/
*/
public
class
Object
{
public
class
Object
{
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
0
;
return
0
;
}
}
...
@@ -19,6 +20,7 @@ public class Object {
...
@@ -19,6 +20,7 @@ public class Object {
return
other
==
this
;
return
other
==
this
;
}
}
@Override
public
java
.
lang
.
String
toString
()
{
public
java
.
lang
.
String
toString
()
{
return
"?"
;
return
"?"
;
}
}
...
...
h2/src/tools/org/h2/java/lang/String.java
浏览文件 @
e2f5284c
...
@@ -166,6 +166,7 @@ public class String {
...
@@ -166,6 +166,7 @@ public class String {
System
.
arraycopy
(
chars
,
offset
,
this
.
chars
,
0
,
count
);
System
.
arraycopy
(
chars
,
offset
,
this
.
chars
,
0
,
count
);
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
int
h
=
hash
;
int
h
=
hash
;
if
(
h
==
0
)
{
if
(
h
==
0
)
{
...
...
h2/src/tools/org/h2/java/lang/StringBuilder.java
浏览文件 @
e2f5284c
...
@@ -51,6 +51,7 @@ public class StringBuilder {
...
@@ -51,6 +51,7 @@ public class StringBuilder {
return
this
;
return
this
;
}
}
@Override
public
java
.
lang
.
String
toString
()
{
public
java
.
lang
.
String
toString
()
{
return
new
java
.
lang
.
String
(
buffer
,
0
,
length
);
return
new
java
.
lang
.
String
(
buffer
,
0
,
length
);
}
}
...
...
h2/src/tools/org/h2/java/lang/System.java
浏览文件 @
e2f5284c
...
@@ -28,7 +28,8 @@ public class System {
...
@@ -28,7 +28,8 @@ public class System {
* @param destPos the first element in the destination
* @param destPos the first element in the destination
* @param length the number of element to copy
* @param length the number of element to copy
*/
*/
public
static
void
arraycopy
(
char
[]
src
,
int
srcPos
,
char
[]
dest
,
int
destPos
,
int
length
)
{
public
static
void
arraycopy
(
char
[]
src
,
int
srcPos
,
char
[]
dest
,
int
destPos
,
int
length
)
{
/* c:
/* c:
memmove(((jchar*)dest->getPointer()) + destPos,
memmove(((jchar*)dest->getPointer()) + destPos,
((jchar*)src->getPointer()) + srcPos, sizeof(jchar) * length);
((jchar*)src->getPointer()) + srcPos, sizeof(jchar) * length);
...
@@ -47,7 +48,8 @@ public class System {
...
@@ -47,7 +48,8 @@ public class System {
* @param destPos the first element in the destination
* @param destPos the first element in the destination
* @param length the number of element to copy
* @param length the number of element to copy
*/
*/
public
static
void
arraycopy
(
byte
[]
src
,
int
srcPos
,
byte
[]
dest
,
int
destPos
,
int
length
)
{
public
static
void
arraycopy
(
byte
[]
src
,
int
srcPos
,
byte
[]
dest
,
int
destPos
,
int
length
)
{
/* c:
/* c:
memmove(((jbyte*)dest->getPointer()) + destPos,
memmove(((jbyte*)dest->getPointer()) + destPos,
((jbyte*)src->getPointer()) + srcPos, sizeof(jbyte) * length);
((jbyte*)src->getPointer()) + srcPos, sizeof(jbyte) * length);
...
...
h2/src/tools/org/h2/jcr/Railroads.java
浏览文件 @
e2f5284c
...
@@ -79,7 +79,8 @@ public class Railroads {
...
@@ -79,7 +79,8 @@ public class Railroads {
}
}
private
void
map
(
String
key
,
ResultSet
rs
,
boolean
railroads
)
throws
Exception
{
private
void
map
(
String
key
,
ResultSet
rs
,
boolean
railroads
)
throws
Exception
{
ArrayList
<
HashMap
<
String
,
String
>>
list
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
ArrayList
<
HashMap
<
String
,
String
>>
list
;
list
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
...
@@ -119,7 +120,8 @@ public class Railroads {
...
@@ -119,7 +120,8 @@ public class Railroads {
int
div
=
3
;
int
div
=
3
;
int
part
=
(
list
.
size
()
+
div
-
1
)
/
div
;
int
part
=
(
list
.
size
()
+
div
-
1
)
/
div
;
for
(
int
i
=
0
,
start
=
0
;
i
<
div
;
i
++,
start
+=
part
)
{
for
(
int
i
=
0
,
start
=
0
;
i
<
div
;
i
++,
start
+=
part
)
{
List
<
HashMap
<
String
,
String
>>
listThird
=
list
.
subList
(
start
,
Math
.
min
(
start
+
part
,
list
.
size
()));
List
<
HashMap
<
String
,
String
>>
listThird
=
list
.
subList
(
start
,
Math
.
min
(
start
+
part
,
list
.
size
()));
session
.
put
(
key
+
"-"
+
i
,
listThird
);
session
.
put
(
key
+
"-"
+
i
,
listThird
);
}
}
rs
.
close
();
rs
.
close
();
...
...
h2/src/tools/org/h2/mode/FunctionsMySQL.java
浏览文件 @
e2f5284c
...
@@ -113,7 +113,8 @@ public class FunctionsMySQL {
...
@@ -113,7 +113,8 @@ public class FunctionsMySQL {
* @return a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".
* @return a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".
*/
*/
public
static
String
fromUnixTime
(
int
seconds
)
{
public
static
String
fromUnixTime
(
int
seconds
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
DATE_TIME_FORMAT
,
Locale
.
ENGLISH
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
DATE_TIME_FORMAT
,
Locale
.
ENGLISH
);
return
formatter
.
format
(
new
Date
(
seconds
*
1000L
));
return
formatter
.
format
(
new
Date
(
seconds
*
1000L
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论