Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e6fde6d9
提交
e6fde6d9
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Limit line length to 80 characters
上级
e2f5284c
全部展开
显示空白字符变更
内嵌
并排
正在显示
40 个修改的文件
包含
784 行增加
和
399 行删除
+784
-399
DirectInsert.java
h2/src/test/org/h2/samples/DirectInsert.java
+10
-5
FileFunctions.java
h2/src/test/org/h2/samples/FileFunctions.java
+2
-1
Function.java
h2/src/test/org/h2/samples/Function.java
+10
-5
FunctionMultiReturn.java
h2/src/test/org/h2/samples/FunctionMultiReturn.java
+25
-12
MixedMode.java
h2/src/test/org/h2/samples/MixedMode.java
+10
-5
RowAccessRights.java
h2/src/test/org/h2/samples/RowAccessRights.java
+20
-10
SQLInjection.java
h2/src/test/org/h2/samples/SQLInjection.java
+6
-3
SecurePassword.java
h2/src/test/org/h2/samples/SecurePassword.java
+10
-3
ShowProgress.java
h2/src/test/org/h2/samples/ShowProgress.java
+8
-3
TriggerPassData.java
h2/src/test/org/h2/samples/TriggerPassData.java
+4
-2
TriggerSample.java
h2/src/test/org/h2/samples/TriggerSample.java
+2
-1
UpdatableView.java
h2/src/test/org/h2/samples/UpdatableView.java
+2
-1
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+54
-27
TestStringUtils.java
h2/src/test/org/h2/test/unit/TestStringUtils.java
+85
-44
Test.java
h2/src/tools/android/test/Test.java
+8
-4
H2Cursor.java
h2/src/tools/org/h2/android/H2Cursor.java
+2
-1
H2Database.java
h2/src/tools/org/h2/android/H2Database.java
+37
-23
H2OpenHelper.java
h2/src/tools/org/h2/android/H2OpenHelper.java
+2
-1
H2QueryBuilder.java
h2/src/tools/org/h2/android/H2QueryBuilder.java
+16
-10
H2Utils.java
h2/src/tools/org/h2/android/H2Utils.java
+2
-1
Build.java
h2/src/tools/org/h2/build/Build.java
+78
-43
BuildBase.java
h2/src/tools/org/h2/build/BuildBase.java
+22
-10
CheckJavadoc.java
h2/src/tools/org/h2/build/code/CheckJavadoc.java
+5
-2
CheckTextFiles.java
h2/src/tools/org/h2/build/code/CheckTextFiles.java
+22
-12
SwitchSource.java
h2/src/tools/org/h2/build/code/SwitchSource.java
+2
-1
BnfRailroad.java
h2/src/tools/org/h2/build/doc/BnfRailroad.java
+8
-4
FileConverter.java
h2/src/tools/org/h2/build/doc/FileConverter.java
+2
-1
GenerateDoc.java
h2/src/tools/org/h2/build/doc/GenerateDoc.java
+44
-22
GenerateHelp.java
h2/src/tools/org/h2/build/doc/GenerateHelp.java
+2
-1
MergeDocs.java
h2/src/tools/org/h2/build/doc/MergeDocs.java
+22
-10
RailroadImages.java
h2/src/tools/org/h2/build/doc/RailroadImages.java
+4
-2
SpellChecker.java
h2/src/tools/org/h2/build/doc/SpellChecker.java
+24
-13
UploadBuild.java
h2/src/tools/org/h2/build/doc/UploadBuild.java
+35
-17
WebSite.java
h2/src/tools/org/h2/build/doc/WebSite.java
+4
-2
XMLChecker.java
h2/src/tools/org/h2/build/doc/XMLChecker.java
+4
-2
XMLParser.java
h2/src/tools/org/h2/build/doc/XMLParser.java
+6
-3
Doclet.java
h2/src/tools/org/h2/build/doclet/Doclet.java
+101
-51
ResourceDoclet.java
h2/src/tools/org/h2/build/doclet/ResourceDoclet.java
+2
-1
PrepareTranslation.java
h2/src/tools/org/h2/build/i18n/PrepareTranslation.java
+76
-37
PropertiesToUTF8.java
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
+6
-3
没有找到文件。
h2/src/test/org/h2/samples/DirectInsert.java
浏览文件 @
e6fde6d9
...
...
@@ -41,7 +41,8 @@ public class DirectInsert {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
long
now
=
System
.
currentTimeMillis
();
...
...
@@ -58,14 +59,18 @@ public class DirectInsert {
conn
.
close
();
}
private
static
void
createAsSelect
(
String
url
,
boolean
optimize
)
throws
SQLException
{
Connection
conn
=
DriverManager
.
getConnection
(
url
+
";OPTIMIZE_INSERT_FROM_SELECT="
+
optimize
);
private
static
void
createAsSelect
(
String
url
,
boolean
optimize
)
throws
SQLException
{
Connection
conn
=
DriverManager
.
getConnection
(
url
+
";OPTIMIZE_INSERT_FROM_SELECT="
+
optimize
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST2"
);
System
.
out
.
println
(
"CREATE TABLE ... AS SELECT "
+
(
optimize
?
"(optimized)"
:
""
));
System
.
out
.
println
(
"CREATE TABLE ... AS SELECT "
+
(
optimize
?
"(optimized)"
:
""
));
long
time
=
System
.
currentTimeMillis
();
stat
.
execute
(
"CREATE TABLE TEST2 AS SELECT * FROM TEST"
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
stat
.
execute
(
"INSERT INTO TEST2 SELECT * FROM TEST2"
);
stat
.
close
();
conn
.
close
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/FileFunctions.java
浏览文件 @
e6fde6d9
...
...
@@ -66,7 +66,8 @@ public class FileFunctions {
* @param encoding the encoding
* @return the text
*/
public
static
String
readTextFileWithEncoding
(
String
fileName
,
String
encoding
)
throws
IOException
{
public
static
String
readTextFileWithEncoding
(
String
fileName
,
String
encoding
)
throws
IOException
{
byte
[]
buff
=
readFile
(
fileName
);
String
s
=
new
String
(
buff
,
encoding
);
return
s
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/Function.java
浏览文件 @
e6fde6d9
...
...
@@ -30,13 +30,16 @@ public class Function {
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Statement
stat
=
conn
.
createStatement
();
// Using a custom Java function
stat
.
execute
(
"CREATE ALIAS IS_PRIME FOR \"org.h2.samples.Function.isPrime\" "
);
stat
.
execute
(
"CREATE ALIAS IS_PRIME "
+
"FOR \"org.h2.samples.Function.isPrime\" "
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT IS_PRIME(X), X FROM SYSTEM_RANGE(1, 20) ORDER BY X"
);
rs
=
stat
.
executeQuery
(
"SELECT IS_PRIME(X), X "
+
"FROM SYSTEM_RANGE(1, 20) ORDER BY X"
);
while
(
rs
.
next
())
{
boolean
isPrime
=
rs
.
getBoolean
(
1
);
if
(
isPrime
)
{
...
...
@@ -49,7 +52,8 @@ public class Function {
stat
.
execute
(
"CREATE TABLE TEST(ID INT) AS "
+
"SELECT X FROM SYSTEM_RANGE(1, 100)"
);
PreparedStatement
prep
;
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TABLE(X INT=?, O INT=?) J "
+
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TABLE(X INT=?, O INT=?) J "
+
"INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O"
);
prep
.
setObject
(
1
,
new
Integer
[]
{
30
,
20
});
prep
.
setObject
(
2
,
new
Integer
[]
{
1
,
2
});
...
...
@@ -61,7 +65,8 @@ public class Function {
rs
.
close
();
// Using a custom function like table
stat
.
execute
(
"CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" "
);
stat
.
execute
(
"CREATE ALIAS MATRIX "
+
"FOR \"org.h2.samples.Function.getMatrix\" "
);
prep
=
conn
.
prepareStatement
(
"SELECT * FROM MATRIX(?) "
+
"ORDER BY X, Y"
);
prep
.
setInt
(
1
,
2
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/FunctionMultiReturn.java
浏览文件 @
e6fde6d9
...
...
@@ -32,10 +32,13 @@ public class FunctionMultiReturn {
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS P2C FOR \"org.h2.samples.FunctionMultiReturn.polar2Cartesian\" "
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT X, Y FROM P2C(?, ?)"
);
stat
.
execute
(
"CREATE ALIAS P2C "
+
"FOR \"org.h2.samples.FunctionMultiReturn.polar2Cartesian\" "
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT X, Y FROM P2C(?, ?)"
);
prep
.
setDouble
(
1
,
5.0
);
prep
.
setDouble
(
2
,
0.5
);
ResultSet
rs
=
prep
.
executeQuery
();
...
...
@@ -47,18 +50,23 @@ public class FunctionMultiReturn {
stat
.
execute
(
"CREATE TABLE TEST(ID IDENTITY, R DOUBLE, A DOUBLE)"
);
stat
.
execute
(
"INSERT INTO TEST(R, A) VALUES(5.0, 0.5), (10.0, 0.6)"
);
stat
.
execute
(
"CREATE ALIAS P2C_SET FOR \"org.h2.samples.FunctionMultiReturn.polar2CartesianSet\" "
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM P2C_SET('SELECT * FROM TEST')"
);
stat
.
execute
(
"CREATE ALIAS P2C_SET "
+
"FOR \"org.h2.samples.FunctionMultiReturn.polar2CartesianSet\" "
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM P2C_SET('SELECT * FROM TEST')"
);
while
(
rs
.
next
())
{
double
r
=
rs
.
getDouble
(
"R"
);
double
a
=
rs
.
getDouble
(
"A"
);
double
x
=
rs
.
getDouble
(
"X"
);
double
y
=
rs
.
getDouble
(
"Y"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") :"
+
" (x="
+
x
+
", y="
+
y
+
")"
);
}
stat
.
execute
(
"CREATE ALIAS P2C_A FOR \"org.h2.samples.FunctionMultiReturn.polar2CartesianArray\" "
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT R, A, P2C_A(R, A) FROM TEST"
);
stat
.
execute
(
"CREATE ALIAS P2C_A "
+
"FOR \"org.h2.samples.FunctionMultiReturn.polar2CartesianArray\" "
);
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT R, A, P2C_A(R, A) FROM TEST"
);
while
(
rs
.
next
())
{
double
r
=
rs
.
getDouble
(
1
);
double
a
=
rs
.
getDouble
(
2
);
...
...
@@ -66,16 +74,20 @@ public class FunctionMultiReturn {
Object
[]
xy
=
(
Object
[])
o
;
double
x
=
((
Double
)
xy
[
0
]).
doubleValue
();
double
y
=
((
Double
)
xy
[
1
]).
doubleValue
();
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") :"
+
" (x="
+
x
+
", y="
+
y
+
")"
);
}
rs
=
stat
.
executeQuery
(
"SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)"
);
rs
=
stat
.
executeQuery
(
"SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) "
+
"FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)"
);
while
(
rs
.
next
())
{
double
r
=
rs
.
getDouble
(
1
);
double
a
=
rs
.
getDouble
(
2
);
double
x
=
rs
.
getDouble
(
3
);
double
y
=
rs
.
getDouble
(
4
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") :"
+
" (x="
+
x
+
", y="
+
y
+
")"
);
}
rs
.
close
();
...
...
@@ -128,7 +140,8 @@ public class FunctionMultiReturn {
* @param query the query
* @return a result set with the coordinates
*/
public
static
ResultSet
polar2CartesianSet
(
Connection
conn
,
String
query
)
throws
SQLException
{
public
static
ResultSet
polar2CartesianSet
(
Connection
conn
,
String
query
)
throws
SQLException
{
SimpleResultSet
result
=
new
SimpleResultSet
();
result
.
addColumn
(
"R"
,
Types
.
DOUBLE
,
0
,
0
);
result
.
addColumn
(
"A"
,
Types
.
DOUBLE
,
0
,
0
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/MixedMode.java
浏览文件 @
e6fde6d9
...
...
@@ -30,19 +30,24 @@ public class MixedMode {
// start the server, allows to access the database remotely
Server
server
=
Server
.
createTcpServer
(
"-tcpPort"
,
"9081"
);
server
.
start
();
System
.
out
.
println
(
"You can access the database remotely now, using the URL:"
);
System
.
out
.
println
(
"jdbc:h2:tcp://localhost:9081/~/test (user: sa, password: sa)"
);
System
.
out
.
println
(
"You can access the database remotely now, using the URL:"
);
System
.
out
.
println
(
"jdbc:h2:tcp://localhost:9081/~/test (user: sa, password: sa)"
);
// now use the database in your application in embedded mode
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"sa"
,
"sa"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"sa"
,
"sa"
);
// some simple 'business usage'
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE TIMER IF EXISTS"
);
stat
.
execute
(
"CREATE TABLE TIMER(ID INT PRIMARY KEY, TIME VARCHAR)"
);
System
.
out
.
println
(
"Execute this a few times: SELECT TIME FROM TIMER"
);
System
.
out
.
println
(
"To stop this application (and the server), run: DROP TABLE TIMER"
);
System
.
out
.
println
(
"Execute this a few times: "
+
"SELECT TIME FROM TIMER"
);
System
.
out
.
println
(
"To stop this application "
+
"(and the server), run: DROP TABLE TIMER"
);
try
{
while
(
true
)
{
// runs forever, except if you drop the table remotely
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/RowAccessRights.java
浏览文件 @
e6fde6d9
...
...
@@ -32,13 +32,16 @@ public class RowAccessRights extends TriggerAdapter {
DeleteDbFiles
.
execute
(
"~"
,
"test"
,
true
);
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test_data(id int, user varchar, data varchar, primary key(id, user))"
);
stat
.
execute
(
"create table test_data("
+
"id int, user varchar, data varchar, primary key(id, user))"
);
stat
.
execute
(
"create index on test_data(id, user)"
);
stat
.
execute
(
"create view test as select id, data from test_data where user = user()"
);
stat
.
execute
(
"create view test as select id, data "
+
"from test_data where user = user()"
);
stat
.
execute
(
"create trigger t_test instead of "
+
"insert, update, delete on test for each row "
+
"call \""
+
RowAccessRights
.
class
.
getName
()
+
"\""
);
...
...
@@ -49,13 +52,15 @@ public class RowAccessRights extends TriggerAdapter {
ResultSet
rs
;
Connection
connA
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"a"
,
"a"
);
Connection
connA
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"a"
,
"a"
);
Statement
statA
=
connA
.
createStatement
();
statA
.
execute
(
"insert into test values(1, 'Hello'), (2, 'World')"
);
statA
.
execute
(
"update test set data = 'Hello!' where id = 1"
);
statA
.
execute
(
"delete from test where id = 2"
);
Connection
connB
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"b"
,
"b"
);
Connection
connB
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test"
,
"b"
,
"b"
);
Statement
statB
=
connB
.
createStatement
();
statB
.
execute
(
"insert into test values(1, 'Hallo'), (2, 'Welt')"
);
statB
.
execute
(
"update test set data = 'Hallo!' where id = 1"
);
...
...
@@ -68,7 +73,8 @@ public class RowAccessRights extends TriggerAdapter {
rs
=
statB
.
executeQuery
(
"select * from test"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
"b: "
+
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getString
(
2
));
System
.
out
.
println
(
"b: "
+
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getString
(
2
));
}
connA
.
close
();
...
...
@@ -76,7 +82,8 @@ public class RowAccessRights extends TriggerAdapter {
rs
=
stat
.
executeQuery
(
"select * from test_data"
);
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getString
(
2
)
+
"/"
+
rs
.
getString
(
3
));
System
.
out
.
println
(
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getString
(
2
)
+
"/"
+
rs
.
getString
(
3
));
}
conn
.
close
();
...
...
@@ -85,13 +92,16 @@ public class RowAccessRights extends TriggerAdapter {
@Override
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
,
boolean
before
,
int
type
)
throws
SQLException
{
prepDelete
=
conn
.
prepareStatement
(
"delete from test_data where id = ? and user = ?"
);
prepInsert
=
conn
.
prepareStatement
(
"insert into test_data values(?, ?, ?)"
);
prepDelete
=
conn
.
prepareStatement
(
"delete from test_data where id = ? and user = ?"
);
prepInsert
=
conn
.
prepareStatement
(
"insert into test_data values(?, ?, ?)"
);
super
.
init
(
conn
,
schemaName
,
triggerName
,
tableName
,
before
,
type
);
}
@Override
public
void
fire
(
Connection
conn
,
ResultSet
oldRow
,
ResultSet
newRow
)
throws
SQLException
{
public
void
fire
(
Connection
conn
,
ResultSet
oldRow
,
ResultSet
newRow
)
throws
SQLException
{
String
user
=
conn
.
getMetaData
().
getUserName
();
if
(
oldRow
!=
null
&&
oldRow
.
next
())
{
prepDelete
.
setInt
(
1
,
oldRow
.
getInt
(
1
));
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/SQLInjection.java
浏览文件 @
e6fde6d9
...
...
@@ -54,7 +54,8 @@ public class SQLInjection {
* @param user the user name
* @param password the password
*/
void
run
(
String
driver
,
String
url
,
String
user
,
String
password
)
throws
Exception
{
void
run
(
String
driver
,
String
url
,
String
user
,
String
password
)
throws
Exception
{
Class
.
forName
(
driver
);
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
stat
=
conn
.
createStatement
();
...
...
@@ -147,7 +148,8 @@ public class SQLInjection {
* @param password the password
* @return a result set with the user record if the password matches
*/
public
static
ResultSet
getUser
(
Connection
conn
,
String
userName
,
String
password
)
throws
Exception
{
public
static
ResultSet
getUser
(
Connection
conn
,
String
userName
,
String
password
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM USERS WHERE NAME=? AND PASSWORD=?"
);
prep
.
setString
(
1
,
userName
);
...
...
@@ -164,7 +166,8 @@ public class SQLInjection {
* @param password the password
* @return the new password
*/
public
static
String
changePassword
(
Connection
conn
,
String
userName
,
String
password
)
throws
Exception
{
public
static
String
changePassword
(
Connection
conn
,
String
userName
,
String
password
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"UPDATE USERS SET PASSWORD=? WHERE NAME=?"
);
prep
.
setString
(
1
,
password
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/SecurePassword.java
浏览文件 @
e6fde6d9
...
...
@@ -51,7 +51,10 @@ public class SecurePassword {
stat
.
execute
(
"drop table account if exists"
);
stat
.
execute
(
"create table account(name varchar primary key, salt binary default secure_rand(16), hash binary)"
);
"create table account("
+
"name varchar primary key, "
+
"salt binary default secure_rand(16), "
+
"hash binary)"
);
PreparedStatement
prep
;
prep
=
conn
.
prepareStatement
(
"insert into account(name) values(?)"
);
prep
.
setString
(
1
,
"Joe"
);
...
...
@@ -59,14 +62,18 @@ public class SecurePassword {
prep
.
close
();
prep
=
conn
.
prepareStatement
(
"update account set hash=hash('SHA256', stringtoutf8(salt||?), 10) where name=?"
);
"update account set "
+
"hash=hash('SHA256', stringtoutf8(salt||?), 10) "
+
"where name=?"
);
prep
.
setString
(
1
,
"secret"
);
prep
.
setString
(
2
,
"Joe"
);
prep
.
execute
();
prep
.
close
();
prep
=
conn
.
prepareStatement
(
"select * from account where name=? and hash=hash('SHA256', stringtoutf8(salt||?), 10)"
);
"select * from account "
+
"where name=? "
+
"and hash=hash('SHA256', stringtoutf8(salt||?), 10)"
);
prep
.
setString
(
1
,
"Joe"
);
prep
.
setString
(
2
,
"secret"
);
ResultSet
rs
=
prep
.
executeQuery
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/ShowProgress.java
浏览文件 @
e6fde6d9
...
...
@@ -51,7 +51,8 @@ public class ShowProgress implements DatabaseEventListener {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
long
time
;
time
=
System
.
currentTimeMillis
();
int
len
=
1000
;
...
...
@@ -78,7 +79,9 @@ public class ShowProgress implements DatabaseEventListener {
System
.
out
.
println
(
"Open connection..."
);
time
=
System
.
currentTimeMillis
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:test;DATABASE_EVENT_LISTENER='"
+
getClass
().
getName
()
+
"'"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:test;DATABASE_EVENT_LISTENER='"
+
getClass
().
getName
()
+
"'"
,
"sa"
,
""
);
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
(
"Done after "
+
time
+
" ms"
);
prep
.
close
();
...
...
@@ -133,7 +136,9 @@ public class ShowProgress implements DatabaseEventListener {
}
catch
(
InterruptedException
e
)
{
// ignore
}
System
.
out
.
println
(
"State: "
+
stateName
+
" "
+
(
100
*
current
/
max
)
+
"% ("
+
current
+
" of "
+
max
+
") "
System
.
out
.
println
(
"State: "
+
stateName
+
" "
+
(
100
*
current
/
max
)
+
"% ("
+
current
+
" of "
+
max
+
") "
+
(
time
-
start
)
+
" ms"
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/TriggerPassData.java
浏览文件 @
e6fde6d9
...
...
@@ -82,13 +82,15 @@ public class TriggerPassData implements Trigger {
* @param trigger the trigger name
* @param data the data
*/
public
static
void
setTriggerData
(
Connection
conn
,
String
trigger
,
String
data
)
throws
SQLException
{
public
static
void
setTriggerData
(
Connection
conn
,
String
trigger
,
String
data
)
throws
SQLException
{
TRIGGERS
.
get
(
getPrefix
(
conn
)
+
trigger
).
triggerData
=
data
;
}
private
static
String
getPrefix
(
Connection
conn
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"call ifnull(database_path() || '_', '') || database() || '_'"
);
ResultSet
rs
=
stat
.
executeQuery
(
"call ifnull(database_path() || '_', '') || database() || '_'"
);
rs
.
next
();
return
rs
.
getString
(
1
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/TriggerSample.java
浏览文件 @
e6fde6d9
...
...
@@ -77,7 +77,8 @@ public class TriggerSample {
* @param type the operation type: INSERT, UPDATE, or DELETE
*/
@Override
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
,
boolean
before
,
int
type
)
{
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
,
boolean
before
,
int
type
)
{
// initialize the trigger object is necessary
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/UpdatableView.java
浏览文件 @
e6fde6d9
...
...
@@ -74,7 +74,8 @@ public class UpdatableView extends TriggerAdapter {
}
@Override
public
void
fire
(
Connection
conn
,
ResultSet
oldRow
,
ResultSet
newRow
)
throws
SQLException
{
public
void
fire
(
Connection
conn
,
ResultSet
oldRow
,
ResultSet
newRow
)
throws
SQLException
{
if
(
oldRow
!=
null
&&
oldRow
.
next
())
{
prepDelete
.
setInt
(
1
,
oldRow
.
getInt
(
1
));
prepDelete
.
execute
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
e6fde6d9
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestStringUtils.java
浏览文件 @
e6fde6d9
...
...
@@ -43,10 +43,15 @@ public class TestStringUtils extends TestBase {
}
private
void
testHex
()
{
assertEquals
(
"face"
,
StringUtils
.
convertBytesToHex
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
}));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"face"
));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"fAcE"
));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"FaCe"
));
assertEquals
(
"face"
,
StringUtils
.
convertBytesToHex
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
}));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"face"
));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"fAcE"
));
assertEquals
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
StringUtils
.
convertHexToBytes
(
"FaCe"
));
new
AssertThrows
(
DbException
.
class
)
{
@Override
public
void
test
()
{
StringUtils
.
convertHexToBytes
(
"120"
);
...
...
@@ -69,40 +74,67 @@ public class TestStringUtils extends TestBase {
}
private
void
testXML
()
{
assertEquals
(
"<!-- - - - - - -abc- - - - - - -->\n"
,
StringUtils
.
xmlComment
(
"------abc------"
));
assertEquals
(
"<test/>\n"
,
StringUtils
.
xmlNode
(
"test"
,
null
,
null
));
assertEquals
(
"<test>Grübel</test>\n"
,
StringUtils
.
xmlNode
(
"test"
,
null
,
StringUtils
.
xmlText
(
"Gr\u00fcbel"
)));
assertEquals
(
"Rand&Blue"
,
StringUtils
.
xmlText
(
"Rand&Blue"
));
assertEquals
(
"<<[[[]]]>>"
,
StringUtils
.
xmlCData
(
"<<[[[]]]>>"
));
Date
dt
=
DateTimeUtils
.
parseDateTime
(
"2001-02-03 04:05:06 GMT"
,
"yyyy-MM-dd HH:mm:ss z"
,
"en"
,
"GMT"
);
assertEquals
(
"<!-- - - - - - -abc- - - - - - -->\n"
,
StringUtils
.
xmlComment
(
"------abc------"
));
assertEquals
(
"<test/>\n"
,
StringUtils
.
xmlNode
(
"test"
,
null
,
null
));
assertEquals
(
"<test>Grübel</test>\n"
,
StringUtils
.
xmlNode
(
"test"
,
null
,
StringUtils
.
xmlText
(
"Gr\u00fcbel"
)));
assertEquals
(
"Rand&Blue"
,
StringUtils
.
xmlText
(
"Rand&Blue"
));
assertEquals
(
"<<[[[]]]>>"
,
StringUtils
.
xmlCData
(
"<<[[[]]]>>"
));
Date
dt
=
DateTimeUtils
.
parseDateTime
(
"2001-02-03 04:05:06 GMT"
,
"yyyy-MM-dd HH:mm:ss z"
,
"en"
,
"GMT"
);
String
s
=
StringUtils
.
xmlStartDoc
()
+
StringUtils
.
xmlComment
(
"Test Comment"
)
+
StringUtils
.
xmlNode
(
"rss"
,
StringUtils
.
xmlAttr
(
"version"
,
"2.0"
),
StringUtils
.
xmlComment
(
"Test Comment\nZeile2"
)
+
StringUtils
.
xmlNode
(
"channel"
,
null
,
StringUtils
.
xmlNode
(
"title"
,
null
,
"H2 Database Engine"
)
+
StringUtils
.
xmlNode
(
"rss"
,
StringUtils
.
xmlAttr
(
"version"
,
"2.0"
),
StringUtils
.
xmlComment
(
"Test Comment\nZeile2"
)
+
StringUtils
.
xmlNode
(
"channel"
,
null
,
StringUtils
.
xmlNode
(
"title"
,
null
,
"H2 Database Engine"
)
+
StringUtils
.
xmlNode
(
"link"
,
null
,
"http://www.h2database.com"
)
+
StringUtils
.
xmlNode
(
"description"
,
null
,
"H2 Database Engine"
)
+
StringUtils
.
xmlNode
(
"language"
,
null
,
"en-us"
)
+
StringUtils
.
xmlNode
(
"pubDate"
,
null
,
DateTimeUtils
.
formatDateTime
(
dt
,
+
StringUtils
.
xmlNode
(
"pubDate"
,
null
,
DateTimeUtils
.
formatDateTime
(
dt
,
"EEE, d MMM yyyy HH:mm:ss z"
,
"en"
,
"GMT"
))
+
StringUtils
.
xmlNode
(
"lastBuildDate"
,
null
,
DateTimeUtils
.
formatDateTime
(
dt
,
+
StringUtils
.
xmlNode
(
"lastBuildDate"
,
null
,
DateTimeUtils
.
formatDateTime
(
dt
,
"EEE, d MMM yyyy HH:mm:ss z"
,
"en"
,
"GMT"
))
+
StringUtils
.
xmlNode
(
"item"
,
null
,
StringUtils
.
xmlNode
(
"title"
,
null
,
+
StringUtils
.
xmlNode
(
"item"
,
null
,
StringUtils
.
xmlNode
(
"title"
,
null
,
"New Version 0.9.9.9.9"
)
+
StringUtils
.
xmlNode
(
"link"
,
null
,
"http://www.h2database.com"
)
+
StringUtils
.
xmlNode
(
"description"
,
null
,
StringUtils
.
xmlCData
(
"\nNew Features\nTest\n"
)))));
assertEquals
(
s
,
"<?xml version=\"1.0\"?>\n"
+
"<!-- Test Comment -->\n"
+
"<rss version=\"2.0\">\n"
+
" <!--\n"
+
" Test Comment\n"
+
" Zeile2\n"
+
" -->\n"
+
" <channel>\n"
+
" <title>H2 Database Engine</title>\n"
+
" <link>http://www.h2database.com</link>\n"
+
" <description>H2 Database Engine</description>\n"
+
" <language>en-us</language>\n"
+
StringUtils
.
xmlNode
(
"description"
,
null
,
StringUtils
.
xmlCData
(
"\nNew Features\nTest\n"
)))));
assertEquals
(
s
,
"<?xml version=\"1.0\"?>\n"
+
"<!-- Test Comment -->\n"
+
"<rss version=\"2.0\">\n"
+
" <!--\n"
+
" Test Comment\n"
+
" Zeile2\n"
+
" -->\n"
+
" <channel>\n"
+
" <title>H2 Database Engine</title>\n"
+
" <link>http://www.h2database.com</link>\n"
+
" <description>H2 Database Engine</description>\n"
+
" <language>en-us</language>\n"
+
" <pubDate>Sat, 3 Feb 2001 04:05:06 GMT</pubDate>\n"
+
" <lastBuildDate>Sat, 3 Feb 2001 04:05:06 GMT</lastBuildDate>\n"
+
" <item>\n"
+
" <lastBuildDate>Sat, 3 Feb 2001 04:05:06 GMT</lastBuildDate>\n"
+
" <item>\n"
+
" <title>New Version 0.9.9.9.9</title>\n"
+
" <link>http://www.h2database.com</link>\n"
+
" <description>\n"
+
" <![CDATA[\n"
+
" New Features\n"
+
" Test\n"
+
" ]]>\n"
+
" </description>\n"
+
" </item>\n"
+
" </channel>\n"
+
"</rss>\n"
);
+
" <link>http://www.h2database.com</link>\n"
+
" <description>\n"
+
" <![CDATA[\n"
+
" New Features\n"
+
" Test\n"
+
" ]]>\n"
+
" </description>\n"
+
" </item>\n"
+
" </channel>\n"
+
"</rss>\n"
);
}
private
void
testURL
()
throws
UnsupportedEncodingException
{
...
...
@@ -172,15 +204,24 @@ public class TestStringUtils extends TestBase {
}
private
void
testReplaceAll
()
{
assertEquals
(
"def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"abc "
,
""
));
assertEquals
(
"af"
,
StringUtils
.
replaceAll
(
"abc def"
,
"bc de"
,
""
));
assertEquals
(
"abc def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"bc "
,
"bc "
));
assertEquals
(
"abc "
,
StringUtils
.
replaceAll
(
"abc def"
,
"def"
,
""
));
assertEquals
(
" "
,
StringUtils
.
replaceAll
(
"abc abc"
,
"abc"
,
""
));
assertEquals
(
"xyz xyz"
,
StringUtils
.
replaceAll
(
"abc abc"
,
"abc"
,
"xyz"
));
assertEquals
(
"abc def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"xyz"
,
"abc"
));
assertEquals
(
""
,
StringUtils
.
replaceAll
(
"abcabcabc"
,
"abc"
,
""
));
assertEquals
(
"abcabcabc"
,
StringUtils
.
replaceAll
(
"abcabcabc"
,
"aBc"
,
""
));
assertEquals
(
"def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"abc "
,
""
));
assertEquals
(
"af"
,
StringUtils
.
replaceAll
(
"abc def"
,
"bc de"
,
""
));
assertEquals
(
"abc def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"bc "
,
"bc "
));
assertEquals
(
"abc "
,
StringUtils
.
replaceAll
(
"abc def"
,
"def"
,
""
));
assertEquals
(
" "
,
StringUtils
.
replaceAll
(
"abc abc"
,
"abc"
,
""
));
assertEquals
(
"xyz xyz"
,
StringUtils
.
replaceAll
(
"abc abc"
,
"abc"
,
"xyz"
));
assertEquals
(
"abc def"
,
StringUtils
.
replaceAll
(
"abc def"
,
"xyz"
,
"abc"
));
assertEquals
(
""
,
StringUtils
.
replaceAll
(
"abcabcabc"
,
"abc"
,
""
));
assertEquals
(
"abcabcabc"
,
StringUtils
.
replaceAll
(
"abcabcabc"
,
"aBc"
,
""
));
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/android/test/Test.java
浏览文件 @
e6fde6d9
...
...
@@ -17,12 +17,14 @@ import android.database.Cursor;
public
class
Test
extends
Activity
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
H2Database
db
=
H2Utils
.
openOrCreateDatabase
(
"helloWorld.db"
,
MODE_PRIVATE
,
null
);
H2Database
db
=
H2Utils
.
openOrCreateDatabase
(
"helloWorld.db"
,
MODE_PRIVATE
,
null
);
log
(
"opened ps="
+
db
.
getPageSize
());
try
{
// db.execSQL("DROP TABLE IF EXISTS test");
// log("dropped");
db
.
execSQL
(
"CREATE TABLE if not exists test(ID INTEGER PRIMARY KEY, NAME VARCHAR)"
);
db
.
execSQL
(
"CREATE TABLE if not exists test(ID INTEGER PRIMARY KEY, NAME VARCHAR)"
);
log
(
"created"
);
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
Cursor
c
=
db
.
rawQuery
(
"select * from test"
,
new
String
[
0
]);
...
...
@@ -39,13 +41,15 @@ public class Test extends Activity {
log
(
"delete"
);
db
.
beginTransaction
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
db
.
execSQL
(
"INSERT INTO TEST VALUES(?, 'Hello')"
,
new
Object
[]
{
i
});
db
.
execSQL
(
"INSERT INTO TEST VALUES(?, 'Hello')"
,
new
Object
[]
{
i
});
}
db
.
setTransactionSuccessful
();
db
.
endTransaction
();
log
(
"inserted"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Cursor
c
=
db
.
rawQuery
(
"select * from test where id=?"
,
new
String
[]
{
""
+
i
});
Cursor
c
=
db
.
rawQuery
(
"select * from test where id=?"
,
new
String
[]
{
""
+
i
});
int
count
=
c
.
getCount
();
if
(
count
>
0
)
{
c
.
move
(
1
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/android/H2Cursor.java
浏览文件 @
e6fde6d9
...
...
@@ -24,7 +24,8 @@ public class H2Cursor extends AbstractWindowedCursor {
private
H2Database
database
;
private
ResultInterface
result
;
H2Cursor
(
H2Database
db
,
H2CursorDriver
driver
,
String
editTable
,
H2Query
query
)
{
H2Cursor
(
H2Database
db
,
H2CursorDriver
driver
,
String
editTable
,
H2Query
query
)
{
this
.
database
=
db
;
// TODO
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/android/H2Database.java
浏览文件 @
e6fde6d9
...
...
@@ -16,7 +16,6 @@ import org.h2.engine.Database;
import
org.h2.engine.Session
;
import
org.h2.expression.Parameter
;
import
org.h2.result.ResultInterface
;
import
org.h2.store.PageStore
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
...
...
@@ -111,7 +110,8 @@ public class H2Database {
* @param flags 0, or a combination of OPEN_READONLY and CREATE_IF_NECESSARY
* @return a connection to this database
*/
public
static
H2Database
openDatabase
(
String
path
,
H2Database
.
CursorFactory
factory
,
int
flags
)
{
public
static
H2Database
openDatabase
(
String
path
,
H2Database
.
CursorFactory
factory
,
int
flags
)
{
ConnectionInfo
ci
=
new
ConnectionInfo
(
path
);
if
((
flags
&
OPEN_READWRITE
)
!=
0
)
{
// TODO readonly connections
...
...
@@ -133,7 +133,8 @@ public class H2Database {
* @param factory the cursor factory
* @return a connection to this database
*/
public
static
H2Database
openOrCreateDatabase
(
File
file
,
H2Database
.
CursorFactory
factory
)
{
public
static
H2Database
openOrCreateDatabase
(
File
file
,
H2Database
.
CursorFactory
factory
)
{
return
openDatabase
(
file
.
getPath
(),
factory
,
CREATE_IF_NECESSARY
);
}
...
...
@@ -145,7 +146,8 @@ public class H2Database {
* @param factory the cursor factory
* @return a connection to this database
*/
public
static
H2Database
openOrCreateDatabase
(
String
path
,
H2Database
.
CursorFactory
factory
)
{
public
static
H2Database
openOrCreateDatabase
(
String
path
,
H2Database
.
CursorFactory
factory
)
{
return
openDatabase
(
path
,
factory
,
CREATE_IF_NECESSARY
);
}
...
...
@@ -161,7 +163,8 @@ public class H2Database {
*
* @param transactionListener the transaction listener to use
*/
public
void
beginTransactionWithListener
(
H2TransactionListener
transactionListener
)
{
public
void
beginTransactionWithListener
(
H2TransactionListener
transactionListener
)
{
// TODO H2TransactionListener
session
.
setAutoCommit
(
false
);
}
...
...
@@ -306,7 +309,8 @@ public class H2Database {
* @param values the values
* @return TODO
*/
public
long
insertOrThrow
(
String
table
,
String
nullColumnHack
,
ContentValues
values
)
{
public
long
insertOrThrow
(
String
table
,
String
nullColumnHack
,
ContentValues
values
)
{
return
0
;
}
...
...
@@ -377,7 +381,8 @@ public class H2Database {
* @param foreignKey the foreign key
* @param updateTable TODO
*/
public
void
markTableSyncable
(
String
table
,
String
foreignKey
,
String
updateTable
)
{
public
void
markTableSyncable
(
String
table
,
String
foreignKey
,
String
updateTable
)
{
// TODO
}
...
...
@@ -405,8 +410,9 @@ public class H2Database {
* @param limit the limit or null
* @return the cursor
*/
public
Cursor
query
(
boolean
distinct
,
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
public
Cursor
query
(
boolean
distinct
,
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
return
null
;
}
...
...
@@ -422,8 +428,9 @@ public class H2Database {
* @param orderBy the order by list or null
* @return the cursor
*/
public
Cursor
query
(
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
)
{
public
Cursor
query
(
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
)
{
return
null
;
}
...
...
@@ -440,8 +447,9 @@ public class H2Database {
* @param limit the limit or null
* @return the cursor
*/
public
Cursor
query
(
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
public
Cursor
query
(
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
return
null
;
}
...
...
@@ -460,8 +468,10 @@ public class H2Database {
* @param limit the limit or null
* @return the cursor
*/
public
Cursor
queryWithFactory
(
H2Database
.
CursorFactory
cursorFactory
,
boolean
distinct
,
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
public
Cursor
queryWithFactory
(
H2Database
.
CursorFactory
cursorFactory
,
boolean
distinct
,
String
table
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
return
null
;
}
...
...
@@ -487,8 +497,8 @@ public class H2Database {
* @param editTable TODO
* @return the cursor
*/
public
Cursor
rawQueryWithFactory
(
H2Database
.
CursorFactory
cursorFactory
,
String
sql
,
String
[]
selectionArgs
,
String
editTable
)
{
public
Cursor
rawQueryWithFactory
(
H2Database
.
CursorFactory
cursorFactory
,
String
sql
,
String
[]
selectionArgs
,
String
editTable
)
{
return
null
;
}
...
...
@@ -509,7 +519,8 @@ public class H2Database {
* @param initialValues the values
* @return TODO
*/
public
long
replace
(
String
table
,
String
nullColumnHack
,
ContentValues
initialValues
)
{
public
long
replace
(
String
table
,
String
nullColumnHack
,
ContentValues
initialValues
)
{
return
0
;
}
...
...
@@ -521,7 +532,8 @@ public class H2Database {
* @param initialValues the values
* @return TODO
*/
public
long
replaceOrThrow
(
String
table
,
String
nullColumnHack
,
ContentValues
initialValues
)
{
public
long
replaceOrThrow
(
String
table
,
String
nullColumnHack
,
ContentValues
initialValues
)
{
return
0
;
}
...
...
@@ -588,7 +600,8 @@ public class H2Database {
* @param whereArgs the parameter values
* @return the number of rows updated
*/
public
int
update
(
String
table
,
ContentValues
values
,
String
whereClause
,
String
[]
whereArgs
)
{
public
int
update
(
String
table
,
ContentValues
values
,
String
whereClause
,
String
[]
whereArgs
)
{
return
0
;
}
...
...
@@ -602,8 +615,8 @@ public class H2Database {
* @param conflictAlgorithm the conflict resolution option
* @return the number of rows updated
*/
public
int
updateWithOnConflict
(
String
table
,
ContentValues
values
,
String
whereClause
,
String
[]
whereArgs
,
int
conflictAlgorithm
)
{
public
int
updateWithOnConflict
(
String
table
,
ContentValues
values
,
String
whereClause
,
String
[]
whereArgs
,
int
conflictAlgorithm
)
{
return
0
;
}
...
...
@@ -650,7 +663,8 @@ public class H2Database {
* @param query TODO
* @return the cursor
*/
Cursor
newCursor
(
H2Database
db
,
H2CursorDriver
masterQuery
,
String
editTable
,
H2Query
query
);
Cursor
newCursor
(
H2Database
db
,
H2CursorDriver
masterQuery
,
String
editTable
,
H2Query
query
);
}
private
Prepared
prepare
(
String
sql
,
Object
[]
args
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/android/H2OpenHelper.java
浏览文件 @
e6fde6d9
...
...
@@ -22,7 +22,8 @@ public abstract class H2OpenHelper {
* @param factory the cursor factory to use
* @param version the expected database version
*/
H2OpenHelper
(
Context
context
,
String
name
,
H2Database
.
CursorFactory
factory
,
int
version
)
{
H2OpenHelper
(
Context
context
,
String
name
,
H2Database
.
CursorFactory
factory
,
int
version
)
{
// TODO
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/android/H2QueryBuilder.java
浏览文件 @
e6fde6d9
...
...
@@ -49,8 +49,9 @@ public class H2QueryBuilder {
* @param limit the limit or null
* @return the query
*/
static
String
buildQueryString
(
boolean
distinct
,
String
tables
,
String
[]
columns
,
String
where
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
static
String
buildQueryString
(
boolean
distinct
,
String
tables
,
String
[]
columns
,
String
where
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
StringBuilder
s
=
new
StringBuilder
();
s
.
append
(
"select "
);
if
(
distinct
)
{
...
...
@@ -106,7 +107,8 @@ public class H2QueryBuilder {
* @param limit the limit or null
* @return the query
*/
String
buildQuery
(
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
buildQuery
(
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
return
null
;
}
...
...
@@ -138,9 +140,11 @@ public class H2QueryBuilder {
* @param having the having condition or null
* @return the query
*/
String
buildUnionSubQuery
(
String
typeDiscriminatorColumn
,
String
[]
unionColumns
,
Set
<
String
>
columnsPresentInTable
,
int
computedColumnsOffset
,
String
typeDiscriminatorValue
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
)
{
String
buildUnionSubQuery
(
String
typeDiscriminatorColumn
,
String
[]
unionColumns
,
Set
<
String
>
columnsPresentInTable
,
int
computedColumnsOffset
,
String
typeDiscriminatorValue
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
)
{
return
null
;
}
...
...
@@ -166,8 +170,9 @@ public class H2QueryBuilder {
* @param orderBy the order by list or null
* @return the cursor
*/
Cursor
query
(
H2Database
db
,
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
)
{
Cursor
query
(
H2Database
db
,
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
)
{
return
null
;
}
...
...
@@ -184,8 +189,9 @@ public class H2QueryBuilder {
* @param limit the limit or null
* @return the cursor
*/
Cursor
query
(
H2Database
db
,
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
Cursor
query
(
H2Database
db
,
String
[]
projectionIn
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/android/H2Utils.java
浏览文件 @
e6fde6d9
...
...
@@ -19,7 +19,8 @@ public class H2Utils {
* @param factory the cursor factory to use
* @return the database connection
*/
public
static
H2Database
openOrCreateDatabase
(
String
name
,
int
mode
,
H2Database
.
CursorFactory
factory
)
{
public
static
H2Database
openOrCreateDatabase
(
String
name
,
int
mode
,
H2Database
.
CursorFactory
factory
)
{
return
H2Database
.
openOrCreateDatabase
(
name
,
factory
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/Build.java
浏览文件 @
e6fde6d9
差异被折叠。
点击展开。
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
e6fde6d9
...
...
@@ -130,7 +130,9 @@ public class BuildBase {
pattern
=
pattern
.
substring
(
1
);
}
if
(
pattern
.
indexOf
(
'*'
)
>=
0
)
{
throw
new
RuntimeException
(
"Unsupported pattern, may only start or end with *:"
+
pattern
);
throw
new
RuntimeException
(
"Unsupported pattern, may only start or end with *:"
+
pattern
);
}
// normalize / and \
pattern
=
BuildBase
.
replaceAll
(
pattern
,
"/"
,
File
.
separator
);
...
...
@@ -211,7 +213,8 @@ public class BuildBase {
private
void
runShell
()
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
String
last
=
""
,
line
;
System
.
out
.
println
(
"Shell mode. Type the target, then [Enter]. Just [Enter] repeats the last target."
);
System
.
out
.
println
(
"Shell mode. Type the target, then [Enter]. "
+
"Just [Enter] repeats the last target."
);
while
(
true
)
{
System
.
out
.
print
(
"build> "
);
try
{
...
...
@@ -283,7 +286,8 @@ public class BuildBase {
sysOut
.
println
(
"Targets:"
);
for
(
Method
m
:
methods
)
{
int
mod
=
m
.
getModifiers
();
if
(!
Modifier
.
isStatic
(
mod
)
&&
Modifier
.
isPublic
(
mod
)
&&
m
.
getParameterTypes
().
length
==
0
)
{
if
(!
Modifier
.
isStatic
(
mod
)
&&
Modifier
.
isPublic
(
mod
)
&&
m
.
getParameterTypes
().
length
==
0
)
{
sysOut
.
println
(
m
.
getName
());
}
}
...
...
@@ -374,7 +378,8 @@ public class BuildBase {
Field
field
=
clazz
.
getField
(
fieldName
);
return
field
.
get
(
null
).
toString
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Can not read field "
+
className
+
"."
+
fieldName
,
e
);
throw
new
RuntimeException
(
"Can not read field "
+
className
+
"."
+
fieldName
,
e
);
}
}
...
...
@@ -391,7 +396,8 @@ public class BuildBase {
Method
method
=
clazz
.
getMethod
(
methodName
);
return
method
.
invoke
(
null
).
toString
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Can not read value "
+
className
+
"."
+
methodName
+
"()"
,
e
);
throw
new
RuntimeException
(
"Can not read value "
+
className
+
"."
+
methodName
+
"()"
,
e
);
}
}
...
...
@@ -533,13 +539,15 @@ public class BuildBase {
* @param version the Maven version id
* @param sha1Checksum the SHA-1 checksum or null
*/
protected
void
downloadUsingMaven
(
String
target
,
String
group
,
String
artifact
,
String
version
,
String
sha1Checksum
)
{
protected
void
downloadUsingMaven
(
String
target
,
String
group
,
String
artifact
,
String
version
,
String
sha1Checksum
)
{
String
repoDir
=
"http://repo1.maven.org/maven2"
;
File
targetFile
=
new
File
(
target
);
if
(
targetFile
.
exists
())
{
return
;
}
String
repoFile
=
group
+
"/"
+
artifact
+
"/"
+
version
+
"/"
+
artifact
+
"-"
+
version
+
".jar"
;
String
repoFile
=
group
+
"/"
+
artifact
+
"/"
+
version
+
"/"
+
artifact
+
"-"
+
version
+
".jar"
;
mkdirs
(
targetFile
.
getAbsoluteFile
().
getParentFile
());
String
localMavenDir
=
getLocalMavenDir
();
if
(
new
File
(
localMavenDir
).
exists
())
{
...
...
@@ -758,7 +766,8 @@ public class BuildBase {
* @param storeOnly if the files should not be compressed
* @param sortBySuffix if the file should be sorted by the file suffix
*/
protected
void
zip
(
String
destFile
,
FileList
files
,
String
basePath
,
boolean
storeOnly
,
boolean
sortBySuffix
)
{
protected
void
zip
(
String
destFile
,
FileList
files
,
String
basePath
,
boolean
storeOnly
,
boolean
sortBySuffix
)
{
long
kb
=
zipOrJar
(
destFile
,
files
,
basePath
,
storeOnly
,
sortBySuffix
,
false
);
println
(
"Zip "
+
destFile
+
" ("
+
kb
+
" KB)"
);
}
...
...
@@ -785,7 +794,9 @@ public class BuildBase {
basePath
=
new
File
(
basePath
).
getPath
();
try
{
if
(
new
File
(
destFile
).
isDirectory
())
{
throw
new
IOException
(
"Can't create the file as a directory with this name already exists: "
+
destFile
);
throw
new
IOException
(
"Can't create the file as a directory with this name already exists: "
+
destFile
);
}
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
destFile
));
ZipOutputStream
zipOut
;
...
...
@@ -897,7 +908,8 @@ public class BuildBase {
File
f
=
new
File
(
dir
);
if
(
f
.
exists
())
{
if
(
f
.
isFile
())
{
throw
new
RuntimeException
(
"Can not create directory "
+
dir
+
" because a file with this name exists"
);
throw
new
RuntimeException
(
"Can not create directory "
+
dir
+
" because a file with this name exists"
);
}
}
else
{
mkdirs
(
f
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/code/CheckJavadoc.java
浏览文件 @
e6fde6d9
...
...
@@ -18,7 +18,7 @@ import java.io.RandomAccessFile;
public
class
CheckJavadoc
{
private
static
final
int
MAX_COMMENT_LINE_SIZE
=
80
;
private
static
final
int
MAX_SOURCE_LINE_SIZE
=
12
0
;
private
static
final
int
MAX_SOURCE_LINE_SIZE
=
8
0
;
private
int
errorCount
;
/**
...
...
@@ -55,7 +55,9 @@ public class CheckJavadoc {
}
}
if
(
foundJava
&&
!
foundPackageHtml
)
{
System
.
out
.
println
(
"No package.html file, but a Java file found at: "
+
file
.
getAbsolutePath
());
System
.
out
.
println
(
"No package.html file, but a Java file found at: "
+
file
.
getAbsolutePath
());
errorCount
++;
}
}
else
{
...
...
@@ -112,6 +114,7 @@ public class CheckJavadoc {
}
else
if
(!
inComment
&&
line
.
length
()
>
MAX_SOURCE_LINE_SIZE
)
{
System
.
out
.
println
(
"Long line: "
+
file
.
getAbsolutePath
()
+
" ("
+
file
.
getName
()
+
":"
+
lineNumber
+
")"
);
errorCount
++;
}
lineNumber
++;
pos
=
next
+
1
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/code/CheckTextFiles.java
浏览文件 @
e6fde6d9
...
...
@@ -19,13 +19,17 @@ import java.util.Arrays;
public
class
CheckTextFiles
{
// must contain "+" otherwise this here counts as well
private
static
final
String
COPYRIGHT
=
"Copyright 2004-2013 "
+
"H2 Group."
;
private
static
final
String
LICENSE
=
"Multiple-Licensed "
+
"under the H2 License"
;
private
static
final
String
COPYRIGHT
=
"Copyright 2004-2013 "
+
"H2 Group."
;
private
static
final
String
LICENSE
=
"Multiple-Licensed "
+
"under the H2 License"
;
private
static
final
String
[]
SUFFIX_CHECK
=
{
"html"
,
"jsp"
,
"js"
,
"css"
,
"bat"
,
"nsi"
,
"java"
,
"txt"
,
"properties"
,
"sql"
,
"xml"
,
"csv"
,
"Driver"
,
"prefs"
};
private
static
final
String
[]
SUFFIX_IGNORE
=
{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"layout"
,
"res"
,
"win"
,
"jar"
,
"task"
,
"svg"
,
"MF"
,
"mf"
,
"sh"
,
"DS_Store"
,
"prop"
};
private
static
final
String
[]
SUFFIX_CHECK
=
{
"html"
,
"jsp"
,
"js"
,
"css"
,
"bat"
,
"nsi"
,
"java"
,
"txt"
,
"properties"
,
"sql"
,
"xml"
,
"csv"
,
"Driver"
,
"prefs"
};
private
static
final
String
[]
SUFFIX_IGNORE
=
{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"layout"
,
"res"
,
"win"
,
"jar"
,
"task"
,
"svg"
,
"MF"
,
"mf"
,
"sh"
,
"DS_Store"
,
"prop"
};
private
static
final
String
[]
SUFFIX_CRLF
=
{
"bat"
};
private
static
final
boolean
ALLOW_TAB
=
false
;
...
...
@@ -86,7 +90,9 @@ public class CheckTextFiles {
// check = false;
// ignore = true;
// }
if
(
name
.
endsWith
(
".utf8.txt"
)
||
(
name
.
startsWith
(
"_docs_"
)
&&
name
.
endsWith
(
".properties"
)))
{
if
(
name
.
endsWith
(
".utf8.txt"
)
||
(
name
.
startsWith
(
"_docs_"
)
&&
name
.
endsWith
(
".properties"
)))
{
check
=
false
;
ignore
=
true
;
}
...
...
@@ -103,7 +109,8 @@ public class CheckTextFiles {
}
}
if
(
ignore
==
check
)
{
throw
new
RuntimeException
(
"Unknown suffix: "
+
suffix
+
" for file: "
+
file
.
getAbsolutePath
());
throw
new
RuntimeException
(
"Unknown suffix: "
+
suffix
+
" for file: "
+
file
.
getAbsolutePath
());
}
useCRLF
=
false
;
for
(
String
s
:
SUFFIX_CRLF
)
{
...
...
@@ -128,7 +135,8 @@ public class CheckTextFiles {
* @param fix automatically fix newline characters and trailing spaces
* @param checkLicense check the license and copyright
*/
public
void
checkOrFixFile
(
File
file
,
boolean
fix
,
boolean
checkLicense
)
throws
Exception
{
public
void
checkOrFixFile
(
File
file
,
boolean
fix
,
boolean
checkLicense
)
throws
Exception
{
RandomAccessFile
in
=
new
RandomAccessFile
(
file
,
"r"
);
byte
[]
data
=
new
byte
[(
int
)
file
.
length
()];
ByteArrayOutputStream
out
=
fix
?
new
ByteArrayOutputStream
()
:
null
;
...
...
@@ -161,7 +169,8 @@ public class CheckTextFiles {
char
ch
=
(
char
)
(
data
[
i
]
&
0xff
);
boolean
isWhitespace
=
Character
.
isWhitespace
(
ch
);
if
(
ch
>
127
)
{
fail
(
file
,
"contains character "
+
(
int
)
ch
+
" at "
+
new
String
(
data
,
i
-
10
,
20
),
line
);
fail
(
file
,
"contains character "
+
(
int
)
ch
+
" at "
+
new
String
(
data
,
i
-
10
,
20
),
line
);
return
;
}
else
if
(
ch
<
32
)
{
if
(
ch
==
'\n'
)
{
...
...
@@ -277,7 +286,8 @@ public class CheckTextFiles {
name
=
name
.
substring
(
idx
);
}
}
System
.
out
.
println
(
"FAIL at "
+
name
+
" "
+
error
+
" "
+
file
.
getAbsolutePath
());
System
.
out
.
println
(
"FAIL at "
+
name
+
" "
+
error
+
" "
+
file
.
getAbsolutePath
());
hasError
=
true
;
if
(
failOnError
)
{
throw
new
RuntimeException
(
"FAIL"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/code/SwitchSource.java
浏览文件 @
e6fde6d9
...
...
@@ -143,7 +143,8 @@ public class SwitchSource {
f
.
renameTo
(
fileBack
);
File
fileCopy
=
new
File
(
name
);
if
(!
fileNew
.
renameTo
(
fileCopy
))
{
throw
new
IOException
(
"Could not rename "
+
fileNew
.
getAbsolutePath
()
+
" to "
+
name
);
throw
new
IOException
(
"Could not rename "
+
fileNew
.
getAbsolutePath
()
+
" to "
+
name
);
}
if
(!
fileBack
.
delete
())
{
throw
new
IOException
(
"Could not delete "
+
fileBack
.
getAbsolutePath
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/BnfRailroad.java
浏览文件 @
e6fde6d9
...
...
@@ -39,7 +39,8 @@ public class BnfRailroad implements BnfVisitor {
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
s
:
syntaxList
)
{
bnf
.
visit
(
this
,
s
);
html
=
StringUtils
.
replaceAll
(
html
,
"</code></td><td class=\"d\"><code class=\"c\">"
,
" "
);
html
=
StringUtils
.
replaceAll
(
html
,
"</code></td>"
+
"<td class=\"d\"><code class=\"c\">"
,
" "
);
if
(
buff
.
length
()
>
0
)
{
buff
.
append
(
"<br />"
);
}
...
...
@@ -137,7 +138,8 @@ public class BnfRailroad implements BnfVisitor {
for
(
Rule
r
:
list
)
{
String
a
=
i
==
0
?
"t"
:
i
==
list
.
size
()
-
1
?
"l"
:
"k"
;
i
++;
buff
.
append
(
"<tr class=\"railroad\"><td class=\""
+
a
+
"s\"></td><td class=\"d\">"
);
buff
.
append
(
"<tr class=\"railroad\"><td class=\""
+
a
+
"s\"></td><td class=\"d\">"
);
r
.
accept
(
this
);
buff
.
append
(
html
);
buff
.
append
(
"</td><td class=\""
+
a
+
"e\"></td></tr>"
);
...
...
@@ -161,8 +163,10 @@ public class BnfRailroad implements BnfVisitor {
public
void
visitRuleOptional
(
Rule
rule
)
{
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"<table class=\"railroad\">"
);
buff
.
append
(
"<tr class=\"railroad\"><td class=\"ts\"></td><td class=\"d\"> </td><td class=\"te\"></td></tr>"
);
buff
.
append
(
"<tr class=\"railroad\"><td class=\"ls\"></td><td class=\"d\">"
);
buff
.
append
(
"<tr class=\"railroad\"><td class=\"ts\"></td>"
+
"<td class=\"d\"> </td><td class=\"te\"></td></tr>"
);
buff
.
append
(
"<tr class=\"railroad\">"
+
"<td class=\"ls\"></td><td class=\"d\">"
);
rule
.
accept
(
this
);
buff
.
append
(
html
);
buff
.
append
(
"</td><td class=\"le\"></td></tr></table>"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/FileConverter.java
浏览文件 @
e6fde6d9
...
...
@@ -43,7 +43,8 @@ public class FileConverter {
}
}
String
languageCode
=
Locale
.
KOREA
.
getLanguage
();
String
language
=
new
Locale
(
languageCode
).
getDisplayLanguage
(
new
Locale
(
languageCode
));
String
language
=
new
Locale
(
languageCode
)
.
getDisplayLanguage
(
new
Locale
(
languageCode
));
System
.
out
.
println
(
language
);
System
.
out
.
println
(
StringUtils
.
javaEncode
(
language
));
convert
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/GenerateDoc.java
浏览文件 @
e6fde6d9
...
...
@@ -36,7 +36,8 @@ public class GenerateDoc {
private
String
inDir
=
"src/docsrc/html"
;
private
String
outDir
=
"docs/html"
;
private
Connection
conn
;
private
final
HashMap
<
String
,
Object
>
session
=
new
HashMap
<
String
,
Object
>();
private
final
HashMap
<
String
,
Object
>
session
=
new
HashMap
<
String
,
Object
>();
private
Bnf
bnf
;
/**
...
...
@@ -68,22 +69,38 @@ public class GenerateDoc {
session
.
put
(
"stableVersion"
,
Constants
.
getVersionStable
());
session
.
put
(
"stableVersionDate"
,
Constants
.
BUILD_DATE_STABLE
);
// String help = "SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION";
String
help
=
"SELECT ROWNUM ID, * FROM CSVREAD('"
+
IN_HELP
+
"', NULL, 'lineComment=#') WHERE SECTION "
;
map
(
"commands"
,
help
+
"LIKE 'Commands%' ORDER BY ID"
,
true
);
map
(
"commandsDML"
,
help
+
"= 'Commands (DML)' ORDER BY ID"
,
false
);
map
(
"commandsDDL"
,
help
+
"= 'Commands (DDL)' ORDER BY ID"
,
false
);
map
(
"commandsOther"
,
help
+
"= 'Commands (Other)' ORDER BY ID"
,
false
);
map
(
"otherGrammar"
,
help
+
"= 'Other Grammar' ORDER BY ID"
,
true
);
map
(
"functionsAggregate"
,
help
+
"= 'Functions (Aggregate)' ORDER BY ID"
,
false
);
map
(
"functionsNumeric"
,
help
+
"= 'Functions (Numeric)' ORDER BY ID"
,
false
);
map
(
"functionsString"
,
help
+
"= 'Functions (String)' ORDER BY ID"
,
false
);
map
(
"functionsTimeDate"
,
help
+
"= 'Functions (Time and Date)' ORDER BY ID"
,
false
);
map
(
"functionsSystem"
,
help
+
"= 'Functions (System)' ORDER BY ID"
,
false
);
map
(
"functionsAll"
,
help
+
"LIKE 'Functions%' ORDER BY SECTION, ID"
,
true
);
map
(
"dataTypes"
,
help
+
"LIKE 'Data Types%' ORDER BY SECTION, ID"
,
true
);
map
(
"informationSchema"
,
"SELECT TABLE_NAME TOPIC, GROUP_CONCAT(COLUMN_NAME "
+
"ORDER BY ORDINAL_POSITION SEPARATOR ', ') SYNTAX FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_SCHEMA='INFORMATION_SCHEMA' GROUP BY TABLE_NAME ORDER BY TABLE_NAME"
,
false
);
String
help
=
"SELECT ROWNUM ID, * FROM CSVREAD('"
+
IN_HELP
+
"', NULL, 'lineComment=#') WHERE SECTION "
;
map
(
"commands"
,
help
+
"LIKE 'Commands%' ORDER BY ID"
,
true
);
map
(
"commandsDML"
,
help
+
"= 'Commands (DML)' ORDER BY ID"
,
false
);
map
(
"commandsDDL"
,
help
+
"= 'Commands (DDL)' ORDER BY ID"
,
false
);
map
(
"commandsOther"
,
help
+
"= 'Commands (Other)' ORDER BY ID"
,
false
);
map
(
"otherGrammar"
,
help
+
"= 'Other Grammar' ORDER BY ID"
,
true
);
map
(
"functionsAggregate"
,
help
+
"= 'Functions (Aggregate)' ORDER BY ID"
,
false
);
map
(
"functionsNumeric"
,
help
+
"= 'Functions (Numeric)' ORDER BY ID"
,
false
);
map
(
"functionsString"
,
help
+
"= 'Functions (String)' ORDER BY ID"
,
false
);
map
(
"functionsTimeDate"
,
help
+
"= 'Functions (Time and Date)' ORDER BY ID"
,
false
);
map
(
"functionsSystem"
,
help
+
"= 'Functions (System)' ORDER BY ID"
,
false
);
map
(
"functionsAll"
,
help
+
"LIKE 'Functions%' ORDER BY SECTION, ID"
,
true
);
map
(
"dataTypes"
,
help
+
"LIKE 'Data Types%' ORDER BY SECTION, ID"
,
true
);
map
(
"informationSchema"
,
"SELECT TABLE_NAME TOPIC, "
+
"GROUP_CONCAT(COLUMN_NAME "
+
"ORDER BY ORDINAL_POSITION SEPARATOR ', ') SYNTAX "
+
"FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_SCHEMA='INFORMATION_SCHEMA' "
+
"GROUP BY TABLE_NAME ORDER BY TABLE_NAME"
,
false
);
processAll
(
""
);
conn
.
close
();
}
...
...
@@ -118,13 +135,15 @@ public class GenerateDoc {
out
.
close
();
}
private
void
map
(
String
key
,
String
sql
,
boolean
railroads
)
throws
Exception
{
private
void
map
(
String
key
,
String
sql
,
boolean
railroads
)
throws
Exception
{
ResultSet
rs
=
null
;
Statement
stat
=
null
;
try
{
stat
=
conn
.
createStatement
();
rs
=
stat
.
executeQuery
(
sql
);
ArrayList
<
HashMap
<
String
,
String
>>
list
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
ArrayList
<
HashMap
<
String
,
String
>>
list
=
new
ArrayList
<
HashMap
<
String
,
String
>>();
while
(
rs
.
next
())
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
...
...
@@ -149,8 +168,10 @@ public class GenerateDoc {
String
text
=
map
.
get
(
"text"
);
if
(
text
!=
null
)
{
// text is enclosed in <p> .. </p> so this works.
text
=
StringUtils
.
replaceAll
(
text
,
"<br /><br />"
,
"</p><p>"
);
text
=
StringUtils
.
replaceAll
(
text
,
"<br />"
,
" "
);
text
=
StringUtils
.
replaceAll
(
text
,
"<br /><br />"
,
"</p><p>"
);
text
=
StringUtils
.
replaceAll
(
text
,
"<br />"
,
" "
);
text
=
addCode
(
text
);
map
.
put
(
"text"
,
text
);
}
...
...
@@ -167,7 +188,8 @@ public class GenerateDoc {
int
div
=
3
;
int
part
=
(
list
.
size
()
+
div
-
1
)
/
div
;
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
);
}
}
finally
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/GenerateHelp.java
浏览文件 @
e6fde6d9
...
...
@@ -52,7 +52,8 @@ public class GenerateHelp {
rs2
.
addRow
(
row
);
}
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
out
));
writer
.
write
(
"# Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,\n"
+
writer
.
write
(
"# Copyright 2004-2013 H2 Group. "
+
"Multiple-Licensed under the H2 License,\n"
+
"# Version 1.0, and under the Eclipse Public License, Version 1.0\n"
+
"# (http://h2database.com/html/license.html).\n"
+
"# Initial Developer: H2 Group)\n"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/MergeDocs.java
浏览文件 @
e6fde6d9
...
...
@@ -30,9 +30,10 @@ public class MergeDocs {
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
// the order of pages is important here
String
[]
pages
=
{
"quickstart.html"
,
"installation.html"
,
"tutorial.html"
,
"features.html"
,
"performance.html"
,
"advanced.html"
,
"grammar.html"
,
"functions.html"
,
"datatypes.html"
,
"build.html"
,
"history.html"
,
"faq.html"
};
String
[]
pages
=
{
"quickstart.html"
,
"installation.html"
,
"tutorial.html"
,
"features.html"
,
"performance.html"
,
"advanced.html"
,
"grammar.html"
,
"functions.html"
,
"datatypes.html"
,
"build.html"
,
"history.html"
,
"faq.html"
};
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
fileName
:
pages
)
{
String
text
=
getContent
(
fileName
);
...
...
@@ -46,9 +47,11 @@ public class MergeDocs {
String
finalText
=
buff
.
toString
();
File
output
=
new
File
(
BASE_DIR
,
"onePage.html"
);
PrintWriter
writer
=
new
PrintWriter
(
new
FileWriter
(
output
));
writer
.
println
(
"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>"
);
writer
.
println
(
"<html><head><meta http-equiv=\"Content-Type\" "
+
"content=\"text/html;charset=utf-8\" /><title>"
);
writer
.
println
(
"H2 Documentation"
);
writer
.
println
(
"</title><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheetPdf.css\" /></head><body>"
);
writer
.
println
(
"</title><link rel=\"stylesheet\" type=\"text/css\" "
+
"href=\"stylesheetPdf.css\" /></head><body>"
);
writer
.
println
(
"<h1>H2 Database Engine</h1>"
);
writer
.
println
(
"<p>Version "
+
Constants
.
getFullVersion
()
+
"</p>"
);
writer
.
println
(
finalText
);
...
...
@@ -57,10 +60,18 @@ public class MergeDocs {
}
private
static
String
disableRailroads
(
String
text
)
{
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- railroad-start -->"
,
"<!-- railroad-start "
);
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- railroad-end -->"
,
" railroad-end -->"
);
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- syntax-start"
,
"<!-- syntax-start -->"
);
text
=
StringUtils
.
replaceAll
(
text
,
"syntax-end -->"
,
"<!-- syntax-end -->"
);
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- railroad-start -->"
,
"<!-- railroad-start "
);
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- railroad-end -->"
,
" railroad-end -->"
);
text
=
StringUtils
.
replaceAll
(
text
,
"<!-- syntax-start"
,
"<!-- syntax-start -->"
);
text
=
StringUtils
.
replaceAll
(
text
,
"syntax-end -->"
,
"<!-- syntax-end -->"
);
return
text
;
}
...
...
@@ -69,7 +80,8 @@ public class MergeDocs {
// String end = "</body>";
String
start
=
"<!-- } -->"
;
String
end
=
"<!-- [close] { --></div></td></tr></table><!-- } --><!-- analytics --></body></html>"
;
String
end
=
"<!-- [close] { --></div></td></tr></table>"
+
"<!-- } --><!-- analytics --></body></html>"
;
int
idx
=
text
.
indexOf
(
end
);
if
(
idx
<
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/RailroadImages.java
浏览文件 @
e6fde6d9
...
...
@@ -48,7 +48,8 @@ public class RailroadImages {
BufferedImage
img
;
Graphics2D
g
;
img
=
new
BufferedImage
(
SIZE
*
64
,
SIZE
*
LINE_REPEAT
,
BufferedImage
.
TYPE_INT_ARGB
);
img
=
new
BufferedImage
(
SIZE
*
64
,
SIZE
*
LINE_REPEAT
,
BufferedImage
.
TYPE_INT_ARGB
);
g
=
img
.
createGraphics
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
setStroke
(
g
,
i
);
...
...
@@ -107,7 +108,8 @@ public class RailroadImages {
int
h
=
img
.
getHeight
();
BufferedImage
smaller
=
new
BufferedImage
(
w
/
DIV
,
h
/
DIV
,
img
.
getType
());
Graphics2D
g
=
smaller
.
createGraphics
();
g
.
setRenderingHint
(
RenderingHints
.
KEY_INTERPOLATION
,
RenderingHints
.
VALUE_INTERPOLATION_BILINEAR
);
g
.
setRenderingHint
(
RenderingHints
.
KEY_INTERPOLATION
,
RenderingHints
.
VALUE_INTERPOLATION_BILINEAR
);
g
.
drawImage
(
img
,
0
,
0
,
w
/
DIV
,
h
/
DIV
,
0
,
0
,
w
,
h
,
null
);
g
.
dispose
();
try
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/SpellChecker.java
浏览文件 @
e6fde6d9
...
...
@@ -25,13 +25,17 @@ import org.h2.util.Utils;
*/
public
class
SpellChecker
{
private
static
final
String
[]
SUFFIX
=
{
"html"
,
"java"
,
"sql"
,
"txt"
,
"xml"
,
"jsp"
,
"css"
,
"bat"
,
"csv"
,
"xml"
,
"js"
,
"Driver"
,
"properties"
,
"task"
,
"MF"
,
"mf"
,
"sh"
,
""
};
private
static
final
String
[]
IGNORE
=
{
"dev"
,
"nsi"
,
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"zip"
,
"bz2"
,
"rc"
,
"layout"
,
"res"
,
"dll"
,
"jar"
,
"svg"
,
"prefs"
,
"prop"
,
"iml"
};
private
static
final
String
DELIMITERS
=
" \n.();-\"=,*/{}_<>+\r:'@[]&\\!#|?$^%~`\t"
;
private
static
final
String
[]
SUFFIX
=
{
"html"
,
"java"
,
"sql"
,
"txt"
,
"xml"
,
"jsp"
,
"css"
,
"bat"
,
"csv"
,
"xml"
,
"js"
,
"Driver"
,
"properties"
,
"task"
,
"MF"
,
"mf"
,
"sh"
,
""
};
private
static
final
String
[]
IGNORE
=
{
"dev"
,
"nsi"
,
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"zip"
,
"bz2"
,
"rc"
,
"layout"
,
"res"
,
"dll"
,
"jar"
,
"svg"
,
"prefs"
,
"prop"
,
"iml"
};
private
static
final
String
DELIMITERS
=
" \n.();-\"=,*/{}_<>+\r:'@[]&\\!#|?$^%~`\t"
;
private
static
final
String
PREFIX_IGNORE
=
"abc"
;
private
static
final
String
[]
IGNORE_FILES
=
{
"mainWeb.html"
,
"pg_catalog.sql"
};
private
static
final
String
[]
IGNORE_FILES
=
{
"mainWeb.html"
,
"pg_catalog.sql"
};
// These are public so we can set them during development testing
...
...
@@ -45,9 +49,12 @@ public class SpellChecker {
*/
public
boolean
printDictionary
;
private
final
HashSet
<
String
>
dictionary
=
new
HashSet
<
String
>();
private
final
HashSet
<
String
>
used
=
new
HashSet
<
String
>();
private
final
HashMap
<
String
,
Integer
>
unknown
=
new
HashMap
<
String
,
Integer
>();
private
final
HashSet
<
String
>
dictionary
=
new
HashSet
<
String
>();
private
final
HashSet
<
String
>
used
=
new
HashSet
<
String
>();
private
final
HashMap
<
String
,
Integer
>
unknown
=
new
HashMap
<
String
,
Integer
>();
private
boolean
addToDictionary
;
private
int
errorCount
;
private
int
contextCount
;
...
...
@@ -140,7 +147,8 @@ public class SpellChecker {
}
}
if
(!
ok
)
{
throw
new
IOException
(
"Unsupported suffix: "
+
suffix
+
" for file: "
+
fileName
);
throw
new
IOException
(
"Unsupported suffix: "
+
suffix
+
" for file: "
+
fileName
);
}
String
text
=
new
String
(
BuildBase
.
readFile
(
file
));
if
(
fileName
.
endsWith
(
"dictionary.txt"
))
{
...
...
@@ -198,7 +206,8 @@ public class SpellChecker {
pos
+=
"http://"
.
length
();
while
(
true
)
{
char
c
=
text
.
charAt
(
pos
);
if
(!
Character
.
isJavaIdentifierPart
(
c
)
&&
".#/?&=%+_-:"
.
indexOf
(
c
)
<
0
)
{
if
(!
Character
.
isJavaIdentifierPart
(
c
)
&&
".#/?&=%+_-:"
.
indexOf
(
c
)
<
0
)
{
break
;
}
pos
++;
...
...
@@ -219,11 +228,13 @@ public class SpellChecker {
for
(
int
i
=
1
;
i
<
token
.
length
();
i
++)
{
char
charLeft
=
token
.
charAt
(
i
-
1
);
char
charRight
=
token
.
charAt
(
i
);
if
(
Character
.
isLowerCase
(
charLeft
)
&&
Character
.
isUpperCase
(
charRight
))
{
if
(
Character
.
isLowerCase
(
charLeft
)
&&
Character
.
isUpperCase
(
charRight
))
{
scanToken
(
notFound
,
token
.
substring
(
0
,
i
));
token
=
token
.
substring
(
i
);
i
=
1
;
}
else
if
(
Character
.
isUpperCase
(
charLeft
)
&&
Character
.
isLowerCase
(
charRight
))
{
}
else
if
(
Character
.
isUpperCase
(
charLeft
)
&&
Character
.
isLowerCase
(
charRight
))
{
scanToken
(
notFound
,
token
.
substring
(
0
,
i
-
1
));
token
=
token
.
substring
(
i
-
1
);
i
=
1
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/UploadBuild.java
浏览文件 @
e6fde6d9
...
...
@@ -53,7 +53,8 @@ public class UploadBuild {
boolean
coverage
=
new
File
(
"coverage/index.html"
).
exists
();
boolean
coverageFailed
;
if
(
coverage
)
{
byte
[]
data
=
IOUtils
.
readBytesAndClose
(
new
FileInputStream
(
"coverage/index.html"
),
-
1
);
byte
[]
data
=
IOUtils
.
readBytesAndClose
(
new
FileInputStream
(
"coverage/index.html"
),
-
1
);
String
index
=
new
String
(
data
,
"ISO-8859-1"
);
coverageFailed
=
index
.
indexOf
(
"CLASS=\"h\""
)
>=
0
;
while
(
true
)
{
...
...
@@ -87,7 +88,8 @@ public class UploadBuild {
String
testOutput
;
boolean
error
;
if
(
new
File
(
"docs/html/testOutput.html"
).
exists
())
{
testOutput
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
"docs/html/testOutput.html"
),
-
1
);
testOutput
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
"docs/html/testOutput.html"
),
-
1
);
error
=
testOutput
.
indexOf
(
OutputCatcher
.
START_ERROR
)
>=
0
;
}
else
if
(
new
File
(
"log.txt"
).
exists
())
{
testOutput
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
"log.txt"
),
-
1
);
...
...
@@ -103,7 +105,8 @@ public class UploadBuild {
if
(
ftp
.
exists
(
"/httpdocs/automated"
,
"history.sql"
))
{
buildSql
=
new
String
(
ftp
.
retrieve
(
"/httpdocs/automated/history.sql"
));
}
else
{
buildSql
=
"create table item(id identity, title varchar, issued timestamp, desc varchar);\n"
;
buildSql
=
"create table item(id identity, title varchar, "
+
"issued timestamp, desc varchar);\n"
;
}
String
ts
=
new
java
.
sql
.
Timestamp
(
System
.
currentTimeMillis
()).
toString
();
String
now
=
ts
.
substring
(
0
,
16
);
...
...
@@ -111,16 +114,22 @@ public class UploadBuild {
if
(
idx
>=
0
)
{
int
end
=
testOutput
.
indexOf
(
"<br />"
,
idx
);
if
(
end
>=
0
)
{
String
result
=
testOutput
.
substring
(
idx
+
"Statements per second: "
.
length
(),
end
);
String
result
=
testOutput
.
substring
(
idx
+
"Statements per second: "
.
length
(),
end
);
now
+=
" "
+
result
+
" op/s"
;
}
}
String
sql
=
"insert into item(title, issued, desc) values('Build "
+
now
+
String
sql
=
"insert into item(title, issued, desc) values('Build "
+
now
+
(
error
?
" FAILED"
:
""
)
+
(
coverageFailed
?
" COVERAGE"
:
""
)
+
"', '"
+
ts
+
"', '<a href=\"http://www.h2database.com/html/testOutput.html\">Output</a>"
+
" - <a href=\"http://www.h2database.com/coverage/overview.html\">Coverage</a>"
+
" - <a href=\"http://www.h2database.com/automated/h2-latest.jar\">Jar</a>');\n"
;
"', '"
+
ts
+
"', '<a href=\"http://www.h2database.com/"
+
"html/testOutput.html\">Output</a>"
+
" - <a href=\"http://www.h2database.com/"
+
"coverage/overview.html\">Coverage</a>"
+
" - <a href=\"http://www.h2database.com/"
+
"automated/h2-latest.jar\">Jar</a>');\n"
;
buildSql
+=
sql
;
Connection
conn
;
try
{
...
...
@@ -131,7 +140,8 @@ public class UploadBuild {
conn
=
DriverManager
.
getConnection
(
"jdbc:h2v1_1:mem:"
);
}
conn
.
createStatement
().
execute
(
buildSql
);
String
newsfeed
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
"src/tools/org/h2/build/doc/buildNewsfeed.sql"
),
-
1
);
String
newsfeed
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
"src/tools/org/h2/build/doc/buildNewsfeed.sql"
),
-
1
);
ScriptReader
r
=
new
ScriptReader
(
new
StringReader
(
newsfeed
));
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
null
;
...
...
@@ -147,22 +157,29 @@ public class UploadBuild {
rs
.
next
();
String
content
=
rs
.
getString
(
"content"
);
conn
.
close
();
ftp
.
store
(
"/httpdocs/automated/history.sql"
,
new
ByteArrayInputStream
(
buildSql
.
getBytes
()));
ftp
.
store
(
"/httpdocs/automated/news.xml"
,
new
ByteArrayInputStream
(
content
.
getBytes
()));
ftp
.
store
(
"/httpdocs/html/testOutput.html"
,
new
ByteArrayInputStream
(
testOutput
.
getBytes
()));
ftp
.
store
(
"/httpdocs/automated/history.sql"
,
new
ByteArrayInputStream
(
buildSql
.
getBytes
()));
ftp
.
store
(
"/httpdocs/automated/news.xml"
,
new
ByteArrayInputStream
(
content
.
getBytes
()));
ftp
.
store
(
"/httpdocs/html/testOutput.html"
,
new
ByteArrayInputStream
(
testOutput
.
getBytes
()));
String
jarFileName
=
"bin/h2-"
+
Constants
.
getVersion
()
+
".jar"
;
if
(
FileUtils
.
exists
(
jarFileName
))
{
ftp
.
store
(
"/httpdocs/automated/h2-latest.jar"
,
new
FileInputStream
(
jarFileName
));
ftp
.
store
(
"/httpdocs/automated/h2-latest.jar"
,
new
FileInputStream
(
jarFileName
));
}
if
(
coverage
)
{
ftp
.
store
(
"/httpdocs/coverage/overview.html"
,
new
FileInputStream
(
"coverage/overview.html"
));
ftp
.
store
(
"/httpdocs/coverage/coverage.zip"
,
new
FileInputStream
(
"coverage.zip"
));
ftp
.
store
(
"/httpdocs/coverage/overview.html"
,
new
FileInputStream
(
"coverage/overview.html"
));
ftp
.
store
(
"/httpdocs/coverage/coverage.zip"
,
new
FileInputStream
(
"coverage.zip"
));
FileUtils
.
delete
(
"coverage.zip"
);
}
ftp
.
close
();
}
private
static
void
zip
(
String
destFile
,
String
directory
,
boolean
storeOnly
)
throws
IOException
{
private
static
void
zip
(
String
destFile
,
String
directory
,
boolean
storeOnly
)
throws
IOException
{
OutputStream
out
=
new
FileOutputStream
(
destFile
);
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
out
);
if
(
storeOnly
)
{
...
...
@@ -174,7 +191,8 @@ public class UploadBuild {
zipOut
.
close
();
}
private
static
void
addFiles
(
File
base
,
File
file
,
ZipOutputStream
out
)
throws
IOException
{
private
static
void
addFiles
(
File
base
,
File
file
,
ZipOutputStream
out
)
throws
IOException
{
if
(
file
.
isDirectory
())
{
for
(
File
f
:
file
.
listFiles
())
{
addFiles
(
base
,
f
,
out
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/WebSite.java
浏览文件 @
e6fde6d9
...
...
@@ -26,7 +26,8 @@ public class WebSite {
private
static
final
String
ANALYTICS_TAG
=
"<!-- analytics -->"
;
private
static
final
String
ANALYTICS_SCRIPT
=
"<script src=\"http://www.google-analytics.com/ga.js\" type=\"text/javascript\"></script>\n"
+
"<script src=\"http://www.google-analytics.com/ga.js\" "
+
"type=\"text/javascript\"></script>\n"
+
"<script type=\"text/javascript\">"
+
"var pageTracker=_gat._getTracker(\"UA-2351060-1\");"
+
"pageTracker._initData();pageTracker._trackPageview();"
+
...
...
@@ -116,7 +117,8 @@ public class WebSite {
dir
.
delete
();
}
private
void
copy
(
File
source
,
File
target
,
boolean
replaceFragments
,
boolean
web
)
throws
IOException
{
private
void
copy
(
File
source
,
File
target
,
boolean
replaceFragments
,
boolean
web
)
throws
IOException
{
if
(
source
.
isDirectory
())
{
target
.
mkdirs
();
for
(
File
f
:
source
.
listFiles
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/XMLChecker.java
浏览文件 @
e6fde6d9
...
...
@@ -113,7 +113,8 @@ public class XMLChecker {
if
(
html
)
{
for
(
String
n
:
noClose
)
{
if
(
name
.
equals
(
n
))
{
throw
new
Exception
(
"Unnecessary closing element "
+
name
+
" at "
+
parser
.
getRemaining
());
throw
new
Exception
(
"Unnecessary closing element "
+
name
+
" at "
+
parser
.
getRemaining
());
}
}
}
...
...
@@ -137,7 +138,8 @@ public class XMLChecker {
// ignore
}
else
{
int
eventType
=
parser
.
getEventType
();
throw
new
Exception
(
"Unexpected event "
+
eventType
+
" at "
+
parser
.
getRemaining
());
throw
new
Exception
(
"Unexpected event "
+
eventType
+
" at "
+
parser
.
getRemaining
());
}
}
if
(
stack
.
size
()
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/XMLParser.java
浏览文件 @
e6fde6d9
...
...
@@ -119,7 +119,8 @@ public class XMLParser {
}
private
void
error
(
String
expected
)
{
throw
new
RuntimeException
(
"Expected: "
+
expected
+
" got: "
+
xml
.
substring
(
pos
,
Math
.
min
(
pos
+
1000
,
xml
.
length
())));
throw
new
RuntimeException
(
"Expected: "
+
expected
+
" got: "
+
xml
.
substring
(
pos
,
Math
.
min
(
pos
+
1000
,
xml
.
length
())));
}
private
void
read
(
String
chars
)
{
...
...
@@ -343,7 +344,8 @@ public class XMLParser {
if
(
localNameStart
==
start
)
{
addAttributeName
(
""
,
xml
.
substring
(
localNameStart
,
end
));
}
else
{
addAttributeName
(
xml
.
substring
(
start
,
localNameStart
-
1
),
xml
.
substring
(
localNameStart
,
end
));
addAttributeName
(
xml
.
substring
(
start
,
localNameStart
-
1
),
xml
.
substring
(
localNameStart
,
end
));
}
if
(
noValue
)
{
noValue
=
false
;
...
...
@@ -512,7 +514,8 @@ public class XMLParser {
* @return the full name
*/
public
String
getName
()
{
return
prefix
==
null
||
prefix
.
length
()
==
0
?
localName
:
prefix
+
":"
+
localName
;
return
prefix
==
null
||
prefix
.
length
()
==
0
?
localName
:
prefix
+
":"
+
localName
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doclet/Doclet.java
浏览文件 @
e6fde6d9
差异被折叠。
点击展开。
h2/src/tools/org/h2/build/doclet/ResourceDoclet.java
浏览文件 @
e6fde6d9
...
...
@@ -23,7 +23,8 @@ import com.sun.javadoc.Tag;
*/
public
class
ResourceDoclet
{
private
String
destFile
=
System
.
getProperty
(
"h2.javadocResourceFile"
,
"src/main/org/h2/res/javadoc.properties"
);
private
String
destFile
=
System
.
getProperty
(
"h2.javadocResourceFile"
,
"src/main/org/h2/res/javadoc.properties"
);
private
final
SortedProperties
resources
=
new
SortedProperties
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/i18n/PrepareTranslation.java
浏览文件 @
e6fde6d9
差异被折叠。
点击展开。
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
浏览文件 @
e6fde6d9
...
...
@@ -49,7 +49,8 @@ public class PropertiesToUTF8 {
* @param source the name of the properties file
* @param target the target file name
*/
static
void
propertiesToTextUTF8
(
String
source
,
String
target
)
throws
Exception
{
static
void
propertiesToTextUTF8
(
String
source
,
String
target
)
throws
Exception
{
if
(!
new
File
(
source
).
exists
())
{
return
;
}
...
...
@@ -73,11 +74,13 @@ public class PropertiesToUTF8 {
* @param source the source file name
* @param target the target file name
*/
static
void
textUTF8ToProperties
(
String
source
,
String
target
)
throws
Exception
{
static
void
textUTF8ToProperties
(
String
source
,
String
target
)
throws
Exception
{
if
(!
new
File
(
source
).
exists
())
{
return
;
}
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
"UTF-8"
));
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
"UTF-8"
));
try
{
SortedProperties
prop
=
new
SortedProperties
();
StringBuilder
buff
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论