Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3da434bd
提交
3da434bd
authored
18 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
976bc8b3
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.1.x
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
全部展开
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
1707 行增加
和
0 行删除
+1707
-0
CheckTextFiles.java
h2/src/tools/org/h2/tools/code/CheckTextFiles.java
+177
-0
CodeSwitch.java
h2/src/tools/org/h2/tools/code/CodeSwitch.java
+307
-0
PropertiesToUTF8.java
h2/src/tools/org/h2/tools/code/PropertiesToUTF8.java
+60
-0
GenerateDoc.java
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
+101
-0
LinkChecker.java
h2/src/tools/org/h2/tools/doc/LinkChecker.java
+175
-0
MergeDocs.java
h2/src/tools/org/h2/tools/doc/MergeDocs.java
+87
-0
Doclet.java
h2/src/tools/org/h2/tools/doclet/Doclet.java
+265
-0
HtmlConverter.java
h2/src/tools/org/h2/tools/indexer/HtmlConverter.java
+115
-0
Indexer.java
h2/src/tools/org/h2/tools/indexer/Indexer.java
+341
-0
Page.java
h2/src/tools/org/h2/tools/indexer/Page.java
+23
-0
Weight.java
h2/src/tools/org/h2/tools/indexer/Weight.java
+11
-0
Word.java
h2/src/tools/org/h2/tools/indexer/Word.java
+45
-0
没有找到文件。
h2/src/tools/org/h2/tools/code/CheckTextFiles.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
code
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.RandomAccessFile
;
import
org.h2.util.ByteUtils
;
public
class
CheckTextFiles
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
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
[]
suffixIgnore
=
new
String
[]{
"gif"
,
"png"
,
"odg"
,
"ico"
,
"sxd"
,
"layout"
,
"res"
,
"win"
,
"dll"
,
"jar"
};
boolean
failOnError
;
boolean
allowTab
,
allowCR
=
true
,
allowTrailingSpaces
=
true
;
int
spacesPerTab
=
4
;
boolean
autoFix
=
true
;
boolean
useCRLF
=
true
;
// must contain "+" otherwise this here counts as well
String
copyrightLicense
=
"Copyright 2004-2006 H2 Group. "
+
"Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html)."
;
String
[]
suffixIgnoreLicense
=
new
String
[]{
"bat"
,
"nsi"
,
"txt"
,
"properties"
,
"def"
,
"rc"
,
"dev"
,
"xml"
,
"_private.h"
,
"java.sql.Driver"
};
boolean
hasError
;
void
run
()
throws
Exception
{
String
baseDir
=
"src"
;
check
(
new
File
(
baseDir
));
if
(
hasError
)
{
throw
new
Exception
(
"Errors found"
);
}
}
private
void
check
(
File
file
)
throws
Exception
{
String
name
=
file
.
getName
();
if
(
file
.
isDirectory
())
{
if
(
name
.
equals
(
"CVS"
)
||
name
.
equals
(
".svn"
))
{
return
;
}
File
[]
list
=
file
.
listFiles
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
check
(
list
[
i
]);
}
}
else
{
String
suffix
=
""
;
int
lastDot
=
name
.
lastIndexOf
(
'.'
);
if
(
lastDot
>=
0
)
{
suffix
=
name
.
substring
(
lastDot
+
1
);
}
boolean
check
=
false
,
ignore
=
false
;
for
(
int
i
=
0
;
i
<
suffixCheck
.
length
;
i
++)
{
if
(
suffix
.
equals
(
suffixCheck
[
i
]))
{
check
=
true
;
}
}
for
(
int
i
=
0
;
i
<
suffixIgnore
.
length
;
i
++)
{
if
(
suffix
.
equals
(
suffixIgnore
[
i
]))
{
ignore
=
true
;
}
}
boolean
checkLicense
=
true
;
for
(
int
i
=
0
;
i
<
suffixIgnoreLicense
.
length
;
i
++)
{
String
ig
=
suffixIgnoreLicense
[
i
];
if
(
suffix
.
equals
(
ig
)
||
name
.
endsWith
(
ig
))
{
checkLicense
=
false
;
break
;
}
}
if
(
ignore
==
check
)
{
throw
new
Error
(
"Unknown suffix: "
+
suffix
+
" for file: "
+
name
);
}
if
(
check
)
{
checkOrFixFile
(
file
,
autoFix
,
checkLicense
);
}
}
}
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
;
in
.
readFully
(
data
);
in
.
close
();
if
(
checkLicense
)
{
if
(
data
.
length
>
copyrightLicense
.
length
())
{
// don't check tiny files
String
text
=
new
String
(
data
);
if
(
text
.
indexOf
(
copyrightLicense
)
<
0
)
{
fail
(
file
,
"license is missing"
,
0
);
}
}
}
int
line
=
1
;
boolean
lastWasWhitespace
=
false
;
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
char
ch
=
(
char
)
(
data
[
i
]
&
0xff
);
if
(
ch
>
127
)
{
fail
(
file
,
"contains character "
+
ch
,
line
);
return
;
}
else
if
(
ch
<
32
)
{
if
(
ch
==
'\n'
)
{
if
(
lastWasWhitespace
&&
!
allowTrailingSpaces
)
{
fail
(
file
,
"contains trailing white space"
,
line
);
return
;
}
if
(
fix
)
{
if
(
useCRLF
)
{
out
.
write
(
'\r'
);
}
out
.
write
(
ch
);
}
lastWasWhitespace
=
false
;
line
++;
}
else
if
(
ch
==
'\r'
)
{
if
(!
allowCR
)
{
fail
(
file
,
"contains CR"
,
line
);
return
;
}
if
(
lastWasWhitespace
&&
!
allowTrailingSpaces
)
{
fail
(
file
,
"contains trailing white space"
,
line
);
return
;
}
lastWasWhitespace
=
false
;
// ok
}
else
if
(
ch
==
'\t'
)
{
if
(
fix
)
{
for
(
int
j
=
0
;
j
<
spacesPerTab
;
j
++)
{
out
.
write
(
' '
);
}
}
else
{
if
(!
allowTab
)
{
fail
(
file
,
"contains TAB"
,
line
);
return
;
}
}
lastWasWhitespace
=
true
;
// ok
}
else
{
fail
(
file
,
"contains character "
+(
int
)
ch
,
line
);
return
;
}
}
else
{
if
(
fix
)
{
out
.
write
(
ch
);
}
lastWasWhitespace
=
Character
.
isWhitespace
(
ch
);
}
}
if
(
lastWasWhitespace
&&
!
allowTrailingSpaces
)
{
fail
(
file
,
"contains trailing white space at the very end"
,
line
);
return
;
}
if
(
fix
)
{
byte
[]
changed
=
out
.
toByteArray
();
if
(
ByteUtils
.
compareNotNull
(
data
,
changed
)
!=
0
)
{
RandomAccessFile
f
=
new
RandomAccessFile
(
file
,
"rw"
);
f
.
write
(
changed
);
f
.
setLength
(
changed
.
length
);
f
.
close
();
System
.
out
.
println
(
"CHANGED: File "
+
file
.
getName
());
}
}
}
private
void
fail
(
File
file
,
String
error
,
int
line
)
{
System
.
out
.
println
(
"FAIL: File "
+
file
.
getAbsolutePath
()
+
" "
+
error
+
" at line "
+
line
);
hasError
=
true
;
if
(
failOnError
)
{
throw
new
Error
(
"FAIL"
);
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/code/CodeSwitch.java
0 → 100644
浏览文件 @
3da434bd
差异被折叠。
点击展开。
h2/src/tools/org/h2/tools/code/PropertiesToUTF8.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
code
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.RandomAccessFile
;
import
org.h2.server.web.PageParser
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
public
class
PropertiesToUTF8
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
[]
list
=
new
File
(
"bin/org/h2/web/res"
).
listFiles
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
File
f
=
list
[
i
];
if
(!
f
.
getName
().
endsWith
(
".properties"
))
{
continue
;
}
FileInputStream
in
=
new
FileInputStream
(
f
);
InputStreamReader
r
=
new
InputStreamReader
(
in
,
"UTF-8"
);
String
s
=
IOUtils
.
readStringAndClose
(
r
,
-
1
);
in
.
close
();
String
name
=
f
.
getName
();
if
(
name
.
startsWith
(
"utf8"
))
{
s
=
PageParser
.
escapeHtml
(
s
,
false
);
RandomAccessFile
out
=
new
RandomAccessFile
(
name
.
substring
(
4
),
"rw"
);
out
.
write
(
s
.
getBytes
());
out
.
close
();
}
else
{
new
CheckTextFiles
().
checkOrFixFile
(
f
,
false
,
false
);
s
=
unescapeHtml
(
s
);
s
=
StringUtils
.
javaDecode
(
s
);
FileOutputStream
out
=
new
FileOutputStream
(
"utf8"
+
f
.
getName
());
OutputStreamWriter
w
=
new
OutputStreamWriter
(
out
,
"UTF-8"
);
w
.
write
(
s
);
w
.
close
();
out
.
close
();
}
}
}
private
static
String
unescapeHtml
(
String
s
)
{
String
codes
=
"< < & & > > Ä \u00c4 Ö \u00d6 Ü \u00dc ä \u00e4 ö \u00f6 ü \u00fc ñ \u00f1 ó \u00f3 Í \u00cd ç \u00e7 &eagrave; \u00e8 ê \u00ea Ú \u00da á \u00e1 ú \u00fa é \u00e9 è \u00e8 î \u00ee"
;
String
[]
list
=
StringUtils
.
arraySplit
(
codes
,
' '
,
false
);
for
(
int
i
=
0
;
i
<
list
.
length
;
i
+=
2
)
{
s
=
StringUtils
.
replaceAll
(
s
,
list
[
i
],
list
[
i
+
1
]);
}
if
(
s
.
indexOf
(
"&"
)
>=
0
)
{
throw
new
Error
(
"??? "
+
s
);
}
return
s
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
doc
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
org.h2.bnf.Bnf
;
import
org.h2.server.web.PageParser
;
import
org.h2.tools.indexer.Indexer
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
public
class
GenerateDoc
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
GenerateDoc
().
run
(
args
);
}
String
inDir
=
"src/docsrc/html"
;
String
outDir
=
"docs/html"
;
Connection
conn
;
HashMap
session
=
new
HashMap
();
Bnf
bnf
;
void
run
(
String
[]
args
)
throws
Exception
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
].
equals
(
"-in"
))
{
inDir
=
args
[++
i
];
}
else
if
(
args
[
i
].
equals
(
"-out"
))
{
outDir
=
args
[++
i
];
}
}
Class
.
forName
(
"org.h2.Driver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:."
);
new
File
(
outDir
).
mkdirs
();
bnf
=
Bnf
.
getInstance
(
null
);
map
(
"commands"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION LIKE 'Commands%' ORDER BY ID"
);
map
(
"commandsDML"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION='Commands (DML)' ORDER BY ID"
);
map
(
"commandsDDL"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION='Commands (DDL)' ORDER BY ID"
);
map
(
"commandsOther"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION='Commands (Other)' ORDER BY ID"
);
map
(
"otherGrammar"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION='Other Grammar' ORDER BY ID"
);
map
(
"functionsAggregate"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION = 'Functions (Aggregate)' ORDER BY ID"
);
map
(
"functionsNumeric"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION = 'Functions (Numeric)' ORDER BY ID"
);
map
(
"functionsString"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION = 'Functions (String)' ORDER BY ID"
);
map
(
"functionsTimeDate"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION = 'Functions (Time and Date)' ORDER BY ID"
);
map
(
"functionsSystem"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION = 'Functions (System)' ORDER BY ID"
);
map
(
"functionsAll"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION LIKE 'Functions%' ORDER BY SECTION, ID"
);
map
(
"dataTypes"
,
"SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION LIKE 'Data Types%' ORDER BY SECTION, ID"
);
process
(
"grammar"
);
process
(
"functions"
);
process
(
"datatypes"
);
conn
.
close
();
Indexer
.
main
(
new
String
[
0
]);
}
void
process
(
String
fileName
)
throws
Exception
{
FileOutputStream
fout
=
new
FileOutputStream
(
outDir
+
"/"
+
fileName
+
".html"
);
FileInputStream
fin
=
new
FileInputStream
(
inDir
+
"/"
+
fileName
+
".jsp"
);
byte
[]
bytes
=
IOUtils
.
readBytesAndClose
(
fin
,
0
);
String
page
=
new
String
(
bytes
);
page
=
PageParser
.
parse
(
null
,
page
,
session
);
fout
.
write
(
page
.
getBytes
());
fout
.
close
();
}
void
map
(
String
key
,
String
sql
)
throws
Exception
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
ArrayList
list
=
new
ArrayList
();
while
(
rs
.
next
())
{
HashMap
map
=
new
HashMap
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
for
(
int
i
=
0
;
i
<
meta
.
getColumnCount
();
i
++)
{
String
k
=
StringUtils
.
toLowerEnglish
(
meta
.
getColumnLabel
(
i
+
1
));
String
value
=
rs
.
getString
(
i
+
1
);
map
.
put
(
k
,
PageParser
.
escapeHtml
(
value
));
}
String
topic
=
rs
.
getString
(
"TOPIC"
);
String
syntax
=
rs
.
getString
(
"SYNTAX"
);
syntax
=
bnf
.
getSyntax
(
topic
,
syntax
);
map
.
put
(
"syntax"
,
syntax
);
list
.
add
(
map
);
}
session
.
put
(
key
,
list
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/doc/LinkChecker.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
doc
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StartBrowser
;
import
org.h2.util.StringUtils
;
public
class
LinkChecker
{
private
static
final
boolean
OPEN_EXTERNAL_LINKS
=
false
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
LinkChecker
().
run
(
args
);
}
private
HashMap
targets
=
new
HashMap
();
private
HashMap
links
=
new
HashMap
();
private
void
run
(
String
[]
args
)
throws
Exception
{
String
dir
=
"src/docsrc"
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
"-dir"
.
equals
(
args
[
i
]))
{
dir
=
args
[++
i
];
}
}
process
(
dir
);
listExternalLinks
();
listBadLinks
();
}
void
listExternalLinks
()
{
for
(
Iterator
it
=
links
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
String
link
=
(
String
)
it
.
next
();
if
(
link
.
startsWith
(
"http"
))
{
if
(
link
.
indexOf
(
"//localhost"
)>
0
)
{
continue
;
}
if
(
OPEN_EXTERNAL_LINKS
)
{
StartBrowser
.
openURL
(
link
);
}
System
.
out
.
println
(
"External Link: "
+
link
);
}
}
}
void
listBadLinks
()
throws
Exception
{
ArrayList
errors
=
new
ArrayList
();
for
(
Iterator
it
=
links
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
String
link
=
(
String
)
it
.
next
();
if
(!
link
.
startsWith
(
"http"
)
&&
!
link
.
endsWith
(
"h2.pdf"
))
{
if
(
targets
.
get
(
link
)
==
null
)
{
errors
.
add
(
links
.
get
(
link
)
+
": missing link "
+
link
);
}
}
}
for
(
Iterator
it
=
links
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
String
link
=
(
String
)
it
.
next
();
if
(!
link
.
startsWith
(
"http"
))
{
targets
.
remove
(
link
);
}
}
for
(
Iterator
it
=
targets
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
String
name
=
(
String
)
it
.
next
();
if
(
targets
.
get
(
name
).
equals
(
"name"
))
{
errors
.
add
(
"No link to "
+
name
);
}
}
Collections
.
sort
(
errors
);
for
(
int
i
=
0
;
i
<
errors
.
size
();
i
++)
{
System
.
out
.
println
(
errors
.
get
(
i
));
}
if
(
errors
.
size
()
>
0
)
{
throw
new
Exception
(
"Problems where found by the Link Checker"
);
}
}
void
process
(
String
path
)
throws
Exception
{
if
(
path
.
endsWith
(
"/CVS"
))
{
return
;
}
File
file
=
new
File
(
path
);
if
(
file
.
isDirectory
())
{
String
[]
list
=
file
.
list
();
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
{
process
(
path
+
"/"
+
list
[
i
]);
}
}
else
{
processFile
(
path
);
}
}
void
processFile
(
String
path
)
throws
Exception
{
targets
.
put
(
path
,
"file"
);
String
lower
=
StringUtils
.
toLowerEnglish
(
path
);
if
(!
lower
.
endsWith
(
".html"
)
&&
!
lower
.
endsWith
(
".htm"
))
{
return
;
}
String
fileName
=
new
File
(
path
).
getName
();
String
parent
=
path
.
substring
(
0
,
path
.
lastIndexOf
(
'/'
));
String
html
=
IOUtils
.
readStringAndClose
(
new
FileReader
(
path
),
-
1
);
int
idx
=
-
1
;
while
(
true
)
{
idx
=
html
.
indexOf
(
" id=\""
,
idx
+
1
);
if
(
idx
<
0
)
{
break
;
}
int
start
=
idx
+
4
;
int
end
=
html
.
indexOf
(
"\""
,
start
+
1
);
if
(
end
<
0
)
{
error
(
fileName
,
"expected \" after id= "
+
html
.
substring
(
idx
,
idx
+
100
));
}
String
ref
=
html
.
substring
(
start
+
1
,
end
);
targets
.
put
(
path
+
"#"
+
ref
,
"id"
);
}
idx
=
-
1
;
while
(
true
)
{
idx
=
html
.
indexOf
(
"<a "
,
idx
+
1
);
if
(
idx
<
0
)
{
break
;
}
int
equals
=
html
.
indexOf
(
"="
,
idx
);
if
(
equals
<
0
)
{
error
(
fileName
,
"expected = after <a at "
+
html
.
substring
(
idx
,
idx
+
100
));
}
String
type
=
html
.
substring
(
idx
+
2
,
equals
).
trim
();
int
start
=
html
.
indexOf
(
"\""
,
idx
);
if
(
start
<
0
)
{
error
(
fileName
,
"expected \" after <a at "
+
html
.
substring
(
idx
,
idx
+
100
));
}
int
end
=
html
.
indexOf
(
"\""
,
start
+
1
);
if
(
end
<
0
)
{
error
(
fileName
,
"expected \" after <a at "
+
html
.
substring
(
idx
,
idx
+
100
));
}
String
ref
=
html
.
substring
(
start
+
1
,
end
);
if
(
type
.
equals
(
"href"
))
{
if
(
ref
.
startsWith
(
"http:"
)
||
ref
.
startsWith
(
"https:"
))
{
// ok
}
else
if
(
ref
.
startsWith
(
"#"
))
{
ref
=
path
+
ref
;
}
else
{
String
p
=
parent
;
while
(
ref
.
startsWith
(
"."
))
{
if
(
ref
.
startsWith
(
"./"
))
{
ref
=
ref
.
substring
(
2
);
}
else
if
(
ref
.
startsWith
(
"../"
))
{
ref
=
ref
.
substring
(
3
);
p
=
p
.
substring
(
0
,
p
.
lastIndexOf
(
'/'
));
}
}
ref
=
p
+
"/"
+
ref
;
}
links
.
put
(
ref
,
path
);
}
else
if
(
type
.
equals
(
"name"
))
{
targets
.
put
(
path
+
"#"
+
ref
,
"name"
);
}
else
{
error
(
fileName
,
"unsupported <a xxx: "
+
html
.
substring
(
idx
,
idx
+
100
));
}
}
}
private
void
error
(
String
fileName
,
String
string
)
{
System
.
out
.
println
(
"ERROR with "
+
fileName
+
": "
+
string
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/doc/MergeDocs.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
doc
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
import
org.h2.util.StringUtils
;
public
class
MergeDocs
{
String
baseDir
=
"docs/html"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
MergeDocs
().
run
(
args
);
}
private
void
run
(
String
[]
args
)
throws
Exception
{
String
[]
pages
=
{
"quickstartText.html"
,
"installation.html"
,
"tutorial.html"
,
"features.html"
,
"performance.html"
,
"advanced.html"
,
"grammar.html"
,
"functions.html"
,
"datatypes.html"
,
"build.html"
,
"history.html"
,
"faq.html"
,
"license.html"
};
String
finalText
=
""
;
for
(
int
i
=
0
;
i
<
pages
.
length
;
i
++)
{
String
text
=
getContent
(
pages
[
i
]);
for
(
int
j
=
0
;
j
<
pages
.
length
;
j
++)
{
text
=
StringUtils
.
replaceAll
(
text
,
pages
[
j
]
+
"#"
,
"#"
);
}
text
=
removeHeaderFooter
(
text
);
finalText
+=
text
;
}
File
output
=
new
File
(
baseDir
,
"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
(
"H2 Documentation"
);
writer
.
println
(
"</title><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheetPdf.css\"></head><body>"
);
writer
.
println
(
finalText
);
writer
.
println
(
"</body></html>"
);
writer
.
close
();
}
private
String
removeHeaderFooter
(
String
text
)
{
// String start = "<body";
// String end = "</body>";
String
start
=
"<div class=\"contentDiv\""
;
String
end
=
"</div></td></tr></table></body></html>"
;
int
idx
=
text
.
indexOf
(
end
);
text
=
text
.
substring
(
0
,
idx
);
idx
=
text
.
indexOf
(
start
);
idx
=
text
.
indexOf
(
'>'
,
idx
);
text
=
text
.
substring
(
idx
+
1
);
return
text
;
}
String
getContent
(
String
fileName
)
throws
Exception
{
File
file
=
new
File
(
baseDir
,
fileName
);
int
length
=
(
int
)
file
.
length
();
char
[]
data
=
new
char
[
length
];
FileReader
reader
=
new
FileReader
(
file
);
int
off
=
0
;
while
(
length
>
0
)
{
int
len
=
reader
.
read
(
data
,
off
,
length
);
off
+=
len
;
length
-=
len
;
}
reader
.
close
();
String
s
=
new
String
(
data
);
return
s
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/doclet/Doclet.java
0 → 100644
浏览文件 @
3da434bd
差异被折叠。
点击展开。
h2/src/tools/org/h2/tools/indexer/HtmlConverter.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
indexer
;
import
java.util.HashMap
;
public
class
HtmlConverter
{
private
static
HashMap
charMap
=
new
HashMap
();
private
static
final
String
[]
CHARS
=
{
"quot:34"
,
"amp:38"
,
"lt:60"
,
"gt:62"
,
"nbsp:160"
,
"iexcl:161"
,
"cent:162"
,
"pound:163"
,
"curren:164"
,
"yen:165"
,
"brvbar:166"
,
"sect:167"
,
"uml:168"
,
"copy:169"
,
"ordf:170"
,
"laquo:171"
,
"not:172"
,
"shy:173"
,
"reg:174"
,
"macr:175"
,
"deg:176"
,
"plusmn:177"
,
"sup2:178"
,
"sup3:179"
,
"acute:180"
,
"micro:181"
,
"para:182"
,
"middot:183"
,
"cedil:184"
,
"sup1:185"
,
"ordm:186"
,
"raquo:187"
,
"frac14:188"
,
"frac12:189"
,
"frac34:190"
,
"iquest:191"
,
"Agrave:192"
,
"Aacute:193"
,
"Acirc:194"
,
"Atilde:195"
,
"Auml:196"
,
"Aring:197"
,
"AElig:198"
,
"Ccedil:199"
,
"Egrave:200"
,
"Eacute:201"
,
"Ecirc:202"
,
"Euml:203"
,
"Igrave:204"
,
"Iacute:205"
,
"Icirc:206"
,
"Iuml:207"
,
"ETH:208"
,
"Ntilde:209"
,
"Ograve:210"
,
"Oacute:211"
,
"Ocirc:212"
,
"Otilde:213"
,
"Ouml:214"
,
"times:215"
,
"Oslash:216"
,
"Ugrave:217"
,
"Uacute:218"
,
"Ucirc:219"
,
"Uuml:220"
,
"Yacute:221"
,
"THORN:222"
,
"szlig:223"
,
"agrave:224"
,
"aacute:225"
,
"acirc:226"
,
"atilde:227"
,
"auml:228"
,
"aring:229"
,
"aelig:230"
,
"ccedil:231"
,
"egrave:232"
,
"eacute:233"
,
"ecirc:234"
,
"euml:235"
,
"igrave:236"
,
"iacute:237"
,
"icirc:238"
,
"iuml:239"
,
"eth:240"
,
"ntilde:241"
,
"ograve:242"
,
"oacute:243"
,
"ocirc:244"
,
"otilde:245"
,
"ouml:246"
,
"divide:247"
,
"oslash:248"
,
"ugrave:249"
,
"uacute:250"
,
"ucirc:251"
,
"uuml:252"
,
"yacute:253"
,
"thorn:254"
,
"yuml:255"
,
"Alpha:913"
,
"alpha:945"
,
"Beta:914"
,
"beta:946"
,
"Gamma:915"
,
"gamma:947"
,
"Delta:916"
,
"delta:948"
,
"Epsilon:917"
,
"epsilon:949"
,
"Zeta:918"
,
"zeta:950"
,
"Eta:919"
,
"eta:951"
,
"Theta:920"
,
"theta:952"
,
"Iota:921"
,
"iota:953"
,
"Kappa:922"
,
"kappa:954"
,
"Lambda:923"
,
"lambda:955"
,
"Mu:924"
,
"mu:956"
,
"Nu:925"
,
"nu:957"
,
"Xi:926"
,
"xi:958"
,
"Omicron:927"
,
"omicron:959"
,
"Pi:928"
,
"pi:960"
,
"Rho:929"
,
"rho:961"
,
"Sigma:931"
,
"sigmaf:962"
,
"sigma:963"
,
"Tau:932"
,
"tau:964"
,
"Upsilon:933"
,
"upsilon:965"
,
"Phi:934"
,
"phi:966"
,
"Chi:935"
,
"chi:967"
,
"Psi:936"
,
"psi:968"
,
"Omega:937"
,
"omega:969"
,
"thetasym:977"
,
"upsih:978"
,
"piv:982"
,
"forall:8704"
,
"part:8706"
,
"exist:8707"
,
"empty:8709"
,
"nabla:8711"
,
"isin:8712"
,
"notin:8713"
,
"ni:8715"
,
"prod:8719"
,
"sum:8721"
,
"minus:8722"
,
"lowast:8727"
,
"radic:8730"
,
"prop:8733"
,
"infin:8734"
,
"ang:8736"
,
"and:8743"
,
"or:8744"
,
"cap:8745"
,
"cup:8746"
,
"int:8747"
,
"there4:8756"
,
"sim:8764"
,
"cong:8773"
,
"asymp:8776"
,
"ne:8800"
,
"equiv:8801"
,
"le:8804"
,
"ge:8805"
,
"sub:8834"
,
"sup:8835"
,
"nsub:8836"
,
"sube:8838"
,
"supe:8839"
,
"oplus:8853"
,
"otimes:8855"
,
"perp:8869"
,
"sdot:8901"
,
"loz:9674"
,
"lceil:8968"
,
"rceil:8969"
,
"lfloor:8970"
,
"rfloor:8971"
,
"lang:9001"
,
"rang:9002"
,
"larr:8592"
,
"uarr:8593"
,
"rarr:8594"
,
"darr:8595"
,
"harr:8596"
,
"crarr:8629"
,
"lArr:8656"
,
"uArr:8657"
,
"rArr:8658"
,
"dArr:8659"
,
"hArr:8660"
,
"bull:8226"
,
"prime:8242"
,
"oline:8254"
,
"frasl:8260"
,
"weierp:8472"
,
"image:8465"
,
"real:8476"
,
"trade:8482"
,
"euro:8364"
,
"alefsym:8501"
,
"spades:9824"
,
"clubs:9827"
,
"hearts:9829"
,
"diams:9830"
,
"ensp:8194"
,
"emsp:8195"
,
"thinsp:8201"
,
"zwnj:8204"
,
"zwj:8205"
,
"lrm:8206"
,
"rlm:8207"
,
"ndash:8211"
,
"mdash:8212"
,
"lsquo:8216"
,
"rsquo:8217"
,
"sbquo:8218"
,
"ldquo:8220"
,
"rdquo:8221"
,
"bdquo:8222"
,
"dagger:8224"
,
"Dagger:8225"
,
"hellip:8230"
,
"permil:8240"
,
"lsaquo:8249"
,
"rsaquo:8250"
};
static
{
for
(
int
i
=
0
;
i
<
CHARS
.
length
;
i
++)
{
String
token
=
CHARS
[
i
];
int
idx
=
token
.
indexOf
(
':'
);
String
key
=
token
.
substring
(
0
,
idx
);
int
ch
=
Integer
.
parseInt
(
token
.
substring
(
idx
+
1
));
charMap
.
put
(
key
,
new
Character
((
char
)
ch
));
}
}
public
static
String
convertHtml
(
String
html
)
{
if
(
html
==
null
)
{
return
null
;
}
if
(
html
.
length
()
==
0
)
{
return
html
;
}
if
(
html
.
indexOf
(
'&'
)
<
0
)
{
return
html
;
}
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
html
.
length
();
i
++)
{
char
ch
=
html
.
charAt
(
i
);
if
(
ch
!=
'&'
)
{
buff
.
append
(
ch
);
continue
;
}
int
idx
=
html
.
indexOf
(
';'
,
i
+
1
);
if
(
idx
<
0
)
{
buff
.
append
(
"???"
);
continue
;
}
String
key
=
html
.
substring
(
i
+
1
,
idx
);
Character
repl
;
if
(
key
.
startsWith
(
"#"
))
{
try
{
int
code
=
Integer
.
parseInt
(
key
.
substring
(
1
));
if
(
code
<
0
||
code
>
0xffff
)
{
repl
=
null
;
}
else
{
repl
=
new
Character
((
char
)
code
);
}
}
catch
(
NumberFormatException
e
)
{
repl
=
null
;
}
}
else
{
repl
=
(
Character
)
charMap
.
get
(
key
);
}
if
(
repl
==
null
)
{
buff
.
append
(
"???"
+
key
+
"???"
);
continue
;
}
else
{
buff
.
append
(
repl
.
charValue
());
}
i
=
idx
;
}
return
buff
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/indexer/Indexer.java
0 → 100644
浏览文件 @
3da434bd
差异被折叠。
点击展开。
h2/src/tools/org/h2/tools/indexer/Page.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
indexer
;
public
class
Page
{
int
id
;
String
fileName
;
String
name
;
String
title
;
// TODO page.totalWeight is currently not used
int
totalWeight
;
int
relations
;
Page
(
int
id
,
String
fileName
,
String
name
)
{
this
.
id
=
id
;
this
.
fileName
=
fileName
;
this
.
name
=
name
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/indexer/Weight.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
indexer
;
public
class
Weight
{
static
final
int
TITLE
=
10000
,
HEADER
=
100
,
PARAGRAPH
=
1
;
Page
page
;
int
value
;
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/indexer/Word.java
0 → 100644
浏览文件 @
3da434bd
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
tools
.
indexer
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
public
class
Word
{
String
name
;
HashMap
pages
=
new
HashMap
();
ArrayList
weightList
;
Word
(
String
name
)
{
this
.
name
=
name
;
}
void
addPage
(
Page
page
,
int
weight
)
{
Weight
w
=
(
Weight
)
pages
.
get
(
page
);
if
(
w
==
null
)
{
w
=
new
Weight
();
w
.
page
=
page
;
pages
.
put
(
page
,
w
);
}
w
.
value
+=
weight
;
page
.
relations
++;
}
ArrayList
getSortedWeights
()
{
if
(
weightList
==
null
)
{
weightList
=
new
ArrayList
(
pages
.
values
());
Collections
.
sort
(
weightList
,
new
Comparator
()
{
public
int
compare
(
Object
o0
,
Object
o1
)
{
Weight
w0
=
(
Weight
)
o0
;
Weight
w1
=
(
Weight
)
o1
;
return
w0
.
value
<
w1
.
value
?
1
:
w0
.
value
==
w1
.
value
?
0
:
-
1
;
}
});
}
return
weightList
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论