Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
481146ad
提交
481146ad
authored
1月 24, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
bccf4e46
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
339 行增加
和
11 行删除
+339
-11
build.xml
h2/build.xml
+2
-2
TestManyJdbcObjects.java
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
+4
-4
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+12
-0
CheckTextFiles.java
h2/src/tools/org/h2/tools/code/CheckTextFiles.java
+24
-2
CodeSwitch.java
h2/src/tools/org/h2/tools/code/CodeSwitch.java
+3
-3
SpellChecker.java
h2/src/tools/org/h2/tools/doc/SpellChecker.java
+224
-0
dictionary.txt
h2/src/tools/org/h2/tools/doc/dictionary.txt
+70
-0
没有找到文件。
h2/build.xml
浏览文件 @
481146ad
...
@@ -133,8 +133,8 @@
...
@@ -133,8 +133,8 @@
<java
classname=
"org.h2.tools.doc.LinkChecker"
classpath=
"bin"
>
<java
classname=
"org.h2.tools.doc.LinkChecker"
classpath=
"bin"
>
<arg
line=
"-dir docs"
/>
<arg
line=
"-dir docs"
/>
</java>
</java>
<java
classname=
"org.h2.tools.doc.XMLChecker"
classpath=
"bin"
>
<java
classname=
"org.h2.tools.doc.XMLChecker"
classpath=
"bin"
/
>
<
/java
>
<
java
classname=
"org.h2.tools.doc.SpellChecker"
classpath=
"bin"
/
>
</target>
</target>
<target
name=
"gcj"
depends=
"compileResources"
>
<target
name=
"gcj"
depends=
"compileResources"
>
...
...
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
浏览文件 @
481146ad
...
@@ -44,7 +44,7 @@ public class TestManyJdbcObjects extends TestBase {
...
@@ -44,7 +44,7 @@ public class TestManyJdbcObjects extends TestBase {
// SERVER_CACHED_OBJECTS = 500: connections = 40
// SERVER_CACHED_OBJECTS = 500: connections = 40
// SERVER_CACHED_OBJECTS = 50: connections = 120
// SERVER_CACHED_OBJECTS = 50: connections = 120
deleteDb
(
"manyObjects"
);
deleteDb
(
"manyObjects"
);
Constants
.
RUN_FINALIZE
RS
=
false
;
Constants
.
RUN_FINALIZE
=
false
;
int
connCount
=
getSize
(
4
,
40
);
int
connCount
=
getSize
(
4
,
40
);
Connection
[]
conn
=
new
Connection
[
connCount
];
Connection
[]
conn
=
new
Connection
[
connCount
];
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
...
@@ -62,12 +62,12 @@ public class TestManyJdbcObjects extends TestBase {
...
@@ -62,12 +62,12 @@ public class TestManyJdbcObjects extends TestBase {
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
conn
[
i
].
close
();
conn
[
i
].
close
();
}
}
Constants
.
RUN_FINALIZE
RS
=
true
;
Constants
.
RUN_FINALIZE
=
true
;
}
}
private
void
testOneConnectionPrepare
()
throws
Exception
{
private
void
testOneConnectionPrepare
()
throws
Exception
{
deleteDb
(
"manyObjects"
);
deleteDb
(
"manyObjects"
);
Constants
.
RUN_FINALIZE
RS
=
false
;
Constants
.
RUN_FINALIZE
=
false
;
Connection
conn
=
getConnection
(
"manyObjects"
);
Connection
conn
=
getConnection
(
"manyObjects"
);
PreparedStatement
prep
;
PreparedStatement
prep
;
Statement
stat
;
Statement
stat
;
...
@@ -98,7 +98,7 @@ public class TestManyJdbcObjects extends TestBase {
...
@@ -98,7 +98,7 @@ public class TestManyJdbcObjects extends TestBase {
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
prep
.
executeQuery
();
prep
.
executeQuery
();
}
}
Constants
.
RUN_FINALIZE
RS
=
true
;
Constants
.
RUN_FINALIZE
=
true
;
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
481146ad
...
@@ -27,6 +27,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -27,6 +27,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement"
);
testUUIDGeneratedKeys
(
conn
);
testSetObject
(
conn
);
testSetObject
(
conn
);
testPreparedSubquery
(
conn
);
testPreparedSubquery
(
conn
);
testLikeIndex
(
conn
);
testLikeIndex
(
conn
);
...
@@ -43,6 +44,17 @@ public class TestPreparedStatement extends TestBase {
...
@@ -43,6 +44,17 @@ public class TestPreparedStatement extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
private
void
testUUIDGeneratedKeys
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TESTUUID(id UUID DEFAULT random_UUID() PRIMARY KEY)"
);
stat
.
execute
(
"INSERT INTO TESTUUID() VALUES()"
);
ResultSet
rs
=
stat
.
getGeneratedKeys
();
rs
.
next
();
byte
[]
data
=
rs
.
getBytes
(
1
);
check
(
data
.
length
,
16
);
stat
.
execute
(
"DROP TABLE TESTUUID"
);
}
private
void
testSetObject
(
Connection
conn
)
throws
Exception
{
private
void
testSetObject
(
Connection
conn
)
throws
Exception
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)"
);
...
...
h2/src/tools/org/h2/tools/code/CheckTextFiles.java
浏览文件 @
481146ad
...
@@ -15,7 +15,7 @@ public class CheckTextFiles {
...
@@ -15,7 +15,7 @@ public class CheckTextFiles {
new
CheckTextFiles
().
run
();
new
CheckTextFiles
().
run
();
}
}
String
[]
suffixCheck
=
new
String
[]{
"html"
,
"jsp"
,
"js"
,
"css"
,
"bat"
,
"nsi"
,
"java"
,
"txt"
,
"properties"
,
"cpp"
,
"def"
,
"h"
,
"rc"
,
"dev"
,
"sql"
,
"xml"
,
"csv"
,
"Driver"
};
String
[]
suffixCheck
=
new
String
[]{
"html"
,
"jsp"
,
"js"
,
"css"
,
"bat"
,
"nsi"
,
"java"
,
"txt"
,
"properties"
,
"cpp"
,
"def"
,
"h"
,
"rc"
,
"dev"
,
"sql"
,
"xml"
,
"csv"
,
"Driver"
,
"php"
};
String
[]
suffixIgnore
=
new
String
[]{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"layout"
,
"res"
,
"win"
,
"dll"
,
"jar"
,
"task"
};
String
[]
suffixIgnore
=
new
String
[]{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"layout"
,
"res"
,
"win"
,
"dll"
,
"jar"
,
"task"
};
boolean
failOnError
;
boolean
failOnError
;
boolean
allowTab
,
allowCR
=
true
,
allowTrailingSpaces
=
true
;
boolean
allowTab
,
allowCR
=
true
,
allowTrailingSpaces
=
true
;
...
@@ -92,6 +92,15 @@ public class CheckTextFiles {
...
@@ -92,6 +92,15 @@ public class CheckTextFiles {
if
(
text
.
indexOf
(
copyrightLicense
)
<
0
)
{
if
(
text
.
indexOf
(
copyrightLicense
)
<
0
)
{
fail
(
file
,
"license is missing"
,
0
);
fail
(
file
,
"license is missing"
,
0
);
}
}
if
(
text
.
indexOf
(
" "
+
"//#"
)
>
0
)
{
fail
(
file
,
"unexpected space,//#"
,
0
);
}
if
(
text
.
indexOf
(
" "
+
"#ifdef"
)
>
0
)
{
fail
(
file
,
"unexpected space,#if"
,
0
);
}
if
(
text
.
indexOf
(
" "
+
"#endif"
)
>
0
)
{
fail
(
file
,
"unexpected space,#endif"
,
0
);
}
}
}
}
}
int
line
=
1
;
int
line
=
1
;
...
@@ -167,7 +176,20 @@ public class CheckTextFiles {
...
@@ -167,7 +176,20 @@ public class CheckTextFiles {
}
}
private
void
fail
(
File
file
,
String
error
,
int
line
)
{
private
void
fail
(
File
file
,
String
error
,
int
line
)
{
System
.
out
.
println
(
"FAIL: File "
+
file
.
getAbsolutePath
()
+
" "
+
error
+
" at line "
+
line
);
if
(
line
<=
0
)
{
line
=
1
;
}
String
name
=
file
.
getAbsolutePath
();
int
idx
=
name
.
lastIndexOf
(
File
.
separatorChar
);
if
(
idx
>=
0
)
{
name
=
name
.
replace
(
File
.
separatorChar
,
'.'
);
name
=
name
+
"("
+
name
.
substring
(
idx
+
1
)
+
":"
+
line
+
")"
;
idx
=
name
.
indexOf
(
"org."
);
if
(
idx
>
0
)
{
name
=
name
.
substring
(
idx
);
}
}
System
.
out
.
println
(
"FAIL at "
+
name
+
" "
+
error
+
" "
+
file
.
getAbsolutePath
());
hasError
=
true
;
hasError
=
true
;
if
(
failOnError
)
{
if
(
failOnError
)
{
throw
new
Error
(
"FAIL"
);
throw
new
Error
(
"FAIL"
);
...
...
h2/src/tools/org/h2/tools/code/CodeSwitch.java
浏览文件 @
481146ad
...
@@ -194,7 +194,7 @@ public class CodeSwitch {
...
@@ -194,7 +194,7 @@ public class CodeSwitch {
if
(
lineTrim
.
startsWith
(
"//#"
))
{
if
(
lineTrim
.
startsWith
(
"//#"
))
{
if
(
lineTrim
.
startsWith
(
"//#ifdef "
))
{
if
(
lineTrim
.
startsWith
(
"//#ifdef "
))
{
if
(
state
!=
0
)
{
if
(
state
!=
0
)
{
printError
(
"//#ifdef not allowed inside //#ifdef"
);
printError
(
"//#ifdef not allowed inside
"
+
"
//#ifdef"
);
return
false
;
return
false
;
}
}
state
=
1
;
state
=
1
;
...
@@ -244,7 +244,7 @@ public class CodeSwitch {
...
@@ -244,7 +244,7 @@ public class CodeSwitch {
}
}
}
else
if
(
lineTrim
.
startsWith
(
"//#else"
))
{
}
else
if
(
lineTrim
.
startsWith
(
"//#else"
))
{
if
(
state
!=
1
)
{
if
(
state
!=
1
)
{
printError
(
"//#else without //#ifdef"
);
printError
(
"//#else without
"
+
"
//#ifdef"
);
return
false
;
return
false
;
}
}
state
=
2
;
state
=
2
;
...
@@ -259,7 +259,7 @@ public class CodeSwitch {
...
@@ -259,7 +259,7 @@ public class CodeSwitch {
}
}
}
else
if
(
lineTrim
.
startsWith
(
"//#endif"
))
{
}
else
if
(
lineTrim
.
startsWith
(
"//#endif"
))
{
if
(
state
==
0
)
{
if
(
state
==
0
)
{
printError
(
"//#endif without //#ifdef"
);
printError
(
"//#endif without
"
+
"
//#ifdef"
);
return
false
;
return
false
;
}
}
state
=
0
;
state
=
0
;
...
...
h2/src/tools/org/h2/tools/doc/SpellChecker.java
0 → 100644
浏览文件 @
481146ad
package
org
.
h2
.
tools
.
doc
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.io.StringWriter
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.StringTokenizer
;
import
org.h2.util.IOUtils
;
public
class
SpellChecker
{
private
HashSet
dictionary
=
new
HashSet
();
private
HashSet
used
=
new
HashSet
();
private
HashMap
unknown
=
new
HashMap
();
private
boolean
debug
;
private
boolean
addToDictionary
;
private
static
final
String
[]
SUFFIX
=
new
String
[]{
"java"
,
"sql"
,
"cpp"
,
"txt"
,
"html"
,
"xml"
,
"jsp"
,
"css"
,
"bat"
,
"nsi"
,
"csv"
,
"xml"
,
"js"
,
"def"
,
"dev"
,
"h"
,
"Driver"
,
"properties"
,
"win"
,
"task"
,
"php"
,
""
};
private
static
final
String
[]
IGNORE
=
new
String
[]{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"zip"
,
"bz2"
,
"rc"
,
"layout"
,
"res"
,
"dll"
,
"jar"
};
public
static
void
main
(
String
[]
args
)
throws
IOException
{
String
dir
=
"src"
;
new
SpellChecker
().
run
(
"tools/org/h2/tools/doc/dictionary.txt"
,
dir
);
}
private
void
run
(
String
dictionary
,
String
dir
)
throws
IOException
{
process
(
new
File
(
dir
+
"/"
+
dictionary
));
process
(
new
File
(
dir
));
System
.
out
.
println
(
"used words"
);
for
(
Iterator
it
=
used
.
iterator
();
it
.
hasNext
();)
{
String
s
=
(
String
)
it
.
next
();
System
.
out
.
print
(
s
+
" "
);
}
System
.
out
.
println
();
System
.
out
.
println
(
"ALL UNKNOWN ----------------------------"
);
for
(
Iterator
it
=
unknown
.
keySet
().
iterator
();
it
.
hasNext
();)
{
String
s
=
(
String
)
it
.
next
();
int
count
=
((
Integer
)
unknown
.
get
(
s
)).
intValue
();
if
(
count
>
5
)
{
System
.
out
.
print
(
s
+
" "
);
}
}
System
.
out
.
println
();
if
(
unknown
.
size
()
>
0
)
{
throw
new
IOException
(
"spell check failed"
);
}
}
private
void
process
(
File
file
)
throws
IOException
{
String
name
=
file
.
getCanonicalPath
();
if
(
name
.
endsWith
(
".svn"
))
{
return
;
}
int
removeThisLater
;
if
(
name
.
indexOf
(
"\\test\\"
)
>=
0
)
{
return
;
}
if
(
file
.
isDirectory
())
{
File
[]
list
=
file
.
listFiles
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
process
(
list
[
i
]);
}
}
else
{
String
fileName
=
file
.
getAbsolutePath
();
int
idx
=
fileName
.
lastIndexOf
(
'.'
);
String
suffix
;
if
(
idx
<
0
)
{
suffix
=
""
;
}
else
{
suffix
=
fileName
.
substring
(
idx
+
1
);
}
boolean
ignore
=
false
;
for
(
int
i
=
0
;
i
<
IGNORE
.
length
;
i
++)
{
if
(
IGNORE
[
i
].
equals
(
suffix
))
{
ignore
=
true
;
break
;
}
}
if
(
ignore
)
{
return
;
}
boolean
ok
=
false
;
for
(
int
i
=
0
;
i
<
SUFFIX
.
length
;
i
++)
{
if
(
SUFFIX
[
i
].
equals
(
suffix
))
{
ok
=
true
;
break
;
}
}
if
(!
ok
)
{
throw
new
IOException
(
"Unsupported suffix: "
+
suffix
+
" for file: "
+
fileName
);
}
if
(
"java"
.
equals
(
suffix
)
||
"xml"
.
equals
(
suffix
)
||
"txt"
.
equals
(
suffix
))
{
FileReader
reader
=
null
;
String
text
=
null
;
try
{
reader
=
new
FileReader
(
file
);
text
=
readStringAndClose
(
reader
,
-
1
);
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
if
(
fileName
.
endsWith
(
"dictionary.txt"
))
{
addToDictionary
=
true
;
}
else
{
addToDictionary
=
false
;
}
scan
(
fileName
,
text
);
}
}
}
private
void
scan
(
String
fileName
,
String
text
)
{
HashSet
notfound
=
new
HashSet
();
StringTokenizer
tokenizer
=
new
StringTokenizer
(
text
,
"\r\n \t+\"*%&/()='[]{},.-;:_<>\\!?$@#|~^`"
);
while
(
tokenizer
.
hasMoreTokens
())
{
String
token
=
tokenizer
.
nextToken
();
char
first
=
token
.
charAt
(
0
);
if
(
Character
.
isDigit
(
first
))
{
continue
;
}
if
(!
addToDictionary
&&
debug
)
{
System
.
out
.
print
(
token
+
" "
);
}
scanCombinedToken
(
notfound
,
token
);
if
(!
addToDictionary
&&
debug
)
{
System
.
out
.
println
();
}
}
if
(
notfound
.
isEmpty
())
{
return
;
}
if
(
notfound
.
size
()
>
0
)
{
System
.
out
.
println
(
"file: "
+
fileName
);
for
(
Iterator
it
=
notfound
.
iterator
();
it
.
hasNext
();)
{
String
s
=
(
String
)
it
.
next
();
System
.
out
.
print
(
s
+
" "
);
}
System
.
out
.
println
();
}
}
private
void
scanCombinedToken
(
HashSet
notfound
,
String
token
)
{
for
(
int
i
=
1
;
i
<
token
.
length
();
i
++)
{
char
cleft
=
token
.
charAt
(
i
-
1
);
char
cright
=
token
.
charAt
(
i
);
if
(
Character
.
isLowerCase
(
cleft
)
&&
Character
.
isUpperCase
(
cright
))
{
scanToken
(
notfound
,
token
.
substring
(
0
,
i
));
token
=
token
.
substring
(
i
);
i
=
1
;
}
else
if
(
Character
.
isUpperCase
(
cleft
)
&&
Character
.
isLowerCase
(
cright
))
{
scanToken
(
notfound
,
token
.
substring
(
0
,
i
-
1
));
token
=
token
.
substring
(
i
-
1
);
i
=
1
;
}
}
scanToken
(
notfound
,
token
);
}
private
void
scanToken
(
HashSet
notfound
,
String
token
)
{
if
(
token
.
length
()
<
3
)
{
return
;
}
while
(
true
)
{
char
last
=
token
.
charAt
(
token
.
length
()
-
1
);
if
(!
Character
.
isDigit
(
last
))
{
break
;
}
token
=
token
.
substring
(
0
,
token
.
length
()
-
1
);
}
if
(
token
.
length
()
<
3
)
{
return
;
}
for
(
int
i
=
0
;
i
<
token
.
length
();
i
++)
{
if
(
Character
.
isDigit
(
token
.
charAt
(
i
)))
{
return
;
}
}
token
=
token
.
toLowerCase
();
if
(!
addToDictionary
&&
debug
)
{
System
.
out
.
print
(
token
+
" "
);
}
if
(
addToDictionary
)
{
dictionary
.
add
(
token
);
}
else
{
if
(!
dictionary
.
contains
(
token
))
{
notfound
.
add
(
token
);
increment
(
unknown
,
token
);
}
else
{
used
.
add
(
token
);
}
}
}
private
void
increment
(
HashMap
map
,
String
key
)
{
Integer
value
=
(
Integer
)
map
.
get
(
key
);
value
=
new
Integer
(
value
==
null
?
0
:
value
.
intValue
()
+
1
);
map
.
put
(
key
,
value
);
}
public
static
String
readStringAndClose
(
Reader
in
,
int
length
)
throws
IOException
{
if
(
length
<=
0
)
{
length
=
Integer
.
MAX_VALUE
;
}
int
block
=
Math
.
min
(
4096
,
length
);
StringWriter
out
=
new
StringWriter
(
length
==
Integer
.
MAX_VALUE
?
block
:
length
);
char
[]
buff
=
new
char
[
block
];
while
(
length
>
0
)
{
int
len
=
Math
.
min
(
block
,
length
);
len
=
in
.
read
(
buff
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buff
,
0
,
len
);
length
-=
len
;
}
in
.
close
();
return
out
.
toString
();
}
}
h2/src/tools/org/h2/tools/doc/dictionary.txt
0 → 100644
浏览文件 @
481146ad
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论