Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
06fdb283
提交
06fdb283
authored
3月 27, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The build converts the javadocs to a resource.
上级
13085ffb
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
177 行增加
和
55 行删除
+177
-55
Build.java
h2/src/tools/org/h2/build/Build.java
+7
-1
Doclet.java
h2/src/tools/org/h2/build/doclet/Doclet.java
+22
-11
ResourceDoclet.java
h2/src/tools/org/h2/build/doclet/ResourceDoclet.java
+137
-0
PrepareTranslation.java
h2/src/tools/org/h2/build/i18n/PrepareTranslation.java
+8
-8
PropertiesToUTF8.java
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
+2
-34
FileViewer.java
h2/src/tools/org/h2/dev/util/FileViewer.java
+1
-1
没有找到文件。
h2/src/tools/org/h2/build/Build.java
浏览文件 @
06fdb283
...
...
@@ -104,7 +104,6 @@ public class Build extends BuildBase {
switchSource
();
clean
();
mkdir
(
"temp"
);
resources
(
clientOnly
,
basicResourcesOnly
);
download
();
String
classpath
=
"temp"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
...
...
@@ -139,6 +138,7 @@ public class Build extends BuildBase {
exclude
(
"*/package.html"
);
copy
(
"temp"
,
files
,
"src/test"
);
}
resources
(
clientOnly
,
basicResourcesOnly
);
}
private
void
filter
(
String
source
,
String
target
,
String
old
,
String
replacement
)
{
...
...
@@ -332,6 +332,7 @@ public class Build extends BuildBase {
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-noindex"
,
"-tag"
,
"h2.resource"
,
"-d"
,
"docs/javadocImpl2"
,
"-classpath"
,
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
+
...
...
@@ -412,6 +413,10 @@ public class Build extends BuildBase {
}
private
void
resources
(
boolean
clientOnly
,
boolean
basicOnly
)
{
if
(!
clientOnly
)
{
javadoc
(
new
String
[]
{
"-sourcepath"
,
"src/main"
,
"org.h2.tools"
,
"-doclet"
,
"org.h2.build.doclet.ResourceDoclet"
});
}
FileList
files
=
getFiles
(
"src/main"
).
exclude
(
"*.MF"
).
exclude
(
"*.java"
).
...
...
@@ -421,6 +426,7 @@ public class Build extends BuildBase {
files
=
files
.
keep
(
"src/main/org/h2/res/_messages_en.*"
);
}
if
(
clientOnly
)
{
files
=
files
.
exclude
(
"src/main/org/h2/res/javadoc.properties"
);
files
=
files
.
exclude
(
"src/main/org/h2/server/*"
);
}
zip
(
"temp/org/h2/util/data.zip"
,
files
,
"src/main"
,
true
,
false
);
...
...
h2/src/tools/org/h2/build/doclet/Doclet.java
浏览文件 @
06fdb283
...
...
@@ -11,12 +11,11 @@ import java.io.File;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
org.h2.util.StringUtils
;
import
com.sun.javadoc.ClassDoc
;
import
com.sun.javadoc.FieldDoc
;
import
com.sun.javadoc.MethodDoc
;
...
...
@@ -34,6 +33,7 @@ import com.sun.javadoc.Type;
public
class
Doclet
{
private
static
final
boolean
INTERFACES_ONLY
=
Boolean
.
getBoolean
(
"h2.interfacesOnly"
);
private
String
destDir
=
System
.
getProperty
(
"h2.destDir"
,
"docs/javadoc"
);
private
int
errorCount
;
private
HashSet
errors
=
new
HashSet
();
...
...
@@ -51,7 +51,6 @@ public class Doclet {
private
boolean
startDoc
(
RootDoc
root
)
throws
IOException
{
ClassDoc
[]
classes
=
root
.
classes
();
String
[][]
options
=
root
.
options
();
String
destDir
=
System
.
getProperty
(
"h2.destDir"
,
"docs/javadoc"
);
for
(
int
i
=
0
;
i
<
options
.
length
;
i
++)
{
if
(
options
[
i
][
0
].
equals
(
"destdir"
))
{
destDir
=
options
[
i
][
1
];
...
...
@@ -59,7 +58,7 @@ public class Doclet {
}
for
(
int
i
=
0
;
i
<
classes
.
length
;
++
i
)
{
ClassDoc
clazz
=
classes
[
i
];
processClass
(
destDir
,
clazz
);
processClass
(
clazz
);
}
if
(
errorCount
>
0
)
{
throw
new
IOException
(
"FAILED: "
+
errorCount
+
" errors found"
);
...
...
@@ -75,7 +74,7 @@ public class Doclet {
return
name
;
}
private
void
processClass
(
String
destDir
,
ClassDoc
clazz
)
throws
IOException
{
private
void
processClass
(
ClassDoc
clazz
)
throws
IOException
{
String
packageName
=
clazz
.
containingPackage
().
name
();
String
dir
=
destDir
+
"/"
+
packageName
.
replace
(
'.'
,
'/'
);
(
new
File
(
dir
)).
mkdirs
();
...
...
@@ -102,6 +101,7 @@ public class Doclet {
return
((
MethodDoc
)
a
).
name
().
compareTo
(((
MethodDoc
)
b
).
name
());
}
});
ArrayList
signatures
=
new
ArrayList
();
boolean
hasMethods
=
false
;
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
MethodDoc
method
=
methods
[
i
];
...
...
@@ -117,20 +117,31 @@ public class Doclet {
writer
.
println
(
"<tr><td class=\"return\">"
+
type
+
"</td><td class=\"method\">"
);
Parameter
[]
params
=
method
.
parameters
();
StringBuffer
buff
=
new
StringBuffer
();
StringBuffer
buffSignature
=
new
StringBuffer
(
name
);
buffSignature
.
append
(
'('
);
buff
.
append
(
'('
);
for
(
int
j
=
0
;
j
<
params
.
length
;
j
++)
{
if
(
j
>
0
)
{
buff
.
append
(
", "
);
buffSignature
.
append
(
','
);
}
buff
.
append
(
getTypeName
(
false
,
params
[
j
].
type
()));
String
typeName
=
getTypeName
(
false
,
params
[
j
].
type
());
buff
.
append
(
typeName
);
buffSignature
.
append
(
typeName
);
buff
.
append
(
' '
);
buff
.
append
(
params
[
j
].
name
());
}
buff
.
append
(
')'
);
buffSignature
.
append
(
')'
);
if
(
isDeprecated
(
method
))
{
name
=
"<span class=\"deprecated\">"
+
name
+
"</span>"
;
}
writer
.
println
(
"<a href=\"#r"
+
i
+
"\">"
+
name
+
"</a>"
+
buff
.
toString
());
String
signature
=
buffSignature
.
toString
();
while
(
signatures
.
size
()
<
i
)
{
signatures
.
add
(
null
);
}
signatures
.
add
(
i
,
signature
);
writer
.
println
(
"<a href=\"#"
+
signature
+
"\">"
+
name
+
"</a>"
+
buff
.
toString
());
String
firstSentence
=
getFirstSentence
(
method
.
firstSentenceTags
());
if
(
firstSentence
!=
null
)
{
writer
.
println
(
"<div class=\"methodText\">"
+
formatText
(
firstSentence
)
+
"</div>"
);
...
...
@@ -195,7 +206,8 @@ public class Doclet {
continue
;
}
String
type
=
getTypeName
(
method
.
isStatic
(),
method
.
returnType
());
writer
.
println
(
"<a name=\"r"
+
i
+
"\"></a>"
);
String
signature
=
(
String
)
signatures
.
get
(
i
);
writer
.
println
(
"<a name=\""
+
signature
+
"\"></a>"
);
Parameter
[]
params
=
method
.
parameters
();
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
'('
);
...
...
@@ -452,13 +464,12 @@ public class Doclet {
private
static
boolean
isDeprecated
(
MethodDoc
method
)
{
Tag
[]
tags
=
method
.
tags
();
boolean
deprecated
=
false
;
for
(
int
j
=
0
;
j
<
tags
.
length
;
j
++)
{
Tag
t
=
tags
[
j
];
if
(
t
.
kind
().
equals
(
"@deprecated"
))
{
deprecated
=
true
;
return
true
;
}
}
return
deprecated
;
return
false
;
}
}
h2/src/tools/org/h2/build/doclet/ResourceDoclet.java
0 → 100644
浏览文件 @
06fdb283
/*
* Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
build
.
doclet
;
import
java.io.IOException
;
import
org.h2.build.doc.XMLParser
;
import
org.h2.build.indexer.HtmlConverter
;
import
org.h2.util.SortedProperties
;
import
com.sun.javadoc.ClassDoc
;
import
com.sun.javadoc.Doc
;
import
com.sun.javadoc.MethodDoc
;
import
com.sun.javadoc.RootDoc
;
import
com.sun.javadoc.Tag
;
/**
* This custom doclet generates resources from javadoc comments.
* Only comments that contain 'at resource' are included.
* Only class level and method level comments are supported.
*/
public
class
ResourceDoclet
{
private
String
destFile
=
System
.
getProperty
(
"h2.destDir"
,
"src/main/org/h2/res/javadoc.properties"
);
private
SortedProperties
resources
=
new
SortedProperties
();
/**
* This method is called by the javadoc framework and is required for all
* doclets.
*
* @param root the root
* @return true if successful
*/
public
static
boolean
start
(
RootDoc
root
)
throws
IOException
{
return
new
ResourceDoclet
().
startDoc
(
root
);
}
private
boolean
startDoc
(
RootDoc
root
)
throws
IOException
{
ClassDoc
[]
classes
=
root
.
classes
();
String
[][]
options
=
root
.
options
();
for
(
int
i
=
0
;
i
<
options
.
length
;
i
++)
{
if
(
options
[
i
][
0
].
equals
(
"dest"
))
{
destFile
=
options
[
i
][
1
];
}
}
for
(
int
i
=
0
;
i
<
classes
.
length
;
++
i
)
{
ClassDoc
clazz
=
classes
[
i
];
processClass
(
clazz
);
}
resources
.
store
(
destFile
);
return
true
;
}
private
void
processClass
(
ClassDoc
clazz
)
throws
IOException
{
String
packageName
=
clazz
.
containingPackage
().
name
();
String
className
=
clazz
.
name
();
addResource
(
packageName
+
"."
+
className
,
clazz
);
MethodDoc
[]
methods
=
clazz
.
methods
();
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
MethodDoc
method
=
methods
[
i
];
String
name
=
method
.
name
();
addResource
(
packageName
+
"."
+
className
+
"."
+
name
,
method
);
}
}
private
void
addResource
(
String
key
,
Doc
doc
)
{
if
(!
isResource
(
doc
))
{
return
;
}
String
xhtml
=
doc
.
commentText
();
XMLParser
p
=
new
XMLParser
(
xhtml
);
StringBuffer
buff
=
new
StringBuffer
();
int
column
=
0
;
int
firstColumnSize
=
0
;
boolean
inColumn
=
false
;
while
(
p
.
hasNext
())
{
String
s
;
switch
(
p
.
next
())
{
case
XMLParser
.
END_ELEMENT
:
s
=
p
.
getName
();
if
(
"p"
.
equals
(
s
)
||
"tr"
.
equals
(
s
)
||
"br"
.
equals
(
s
))
{
buff
.
append
(
'\n'
);
}
break
;
case
XMLParser
.
START_ELEMENT
:
s
=
p
.
getName
();
if
(
"table"
.
equals
(
s
))
{
buff
.
append
(
'\n'
);
}
else
if
(
"tr"
.
equals
(
s
))
{
column
=
0
;
}
else
if
(
"td"
.
equals
(
s
))
{
inColumn
=
true
;
column
++;
if
(
column
==
2
)
{
buff
.
append
(
'\t'
);
}
}
break
;
case
XMLParser
.
CHARACTERS
:
s
=
HtmlConverter
.
convertHtmlToString
(
p
.
getText
().
trim
());
if
(
inColumn
&&
column
==
1
)
{
firstColumnSize
=
Math
.
max
(
s
.
length
(),
firstColumnSize
);
}
buff
.
append
(
s
);
break
;
}
}
for
(
int
i
=
0
;
i
<
buff
.
length
();
i
++)
{
if
(
buff
.
charAt
(
i
)
==
'\t'
)
{
buff
.
deleteCharAt
(
i
);
int
length
=
i
-
buff
.
lastIndexOf
(
"\n"
,
i
-
1
);
for
(
int
k
=
length
;
k
<
firstColumnSize
+
3
;
k
++)
{
buff
.
insert
(
i
,
' '
);
}
}
}
String
text
=
buff
.
toString
().
trim
();
resources
.
setProperty
(
key
,
text
);
}
private
static
boolean
isResource
(
Doc
doc
)
{
Tag
[]
tags
=
doc
.
tags
();
for
(
int
j
=
0
;
j
<
tags
.
length
;
j
++)
{
Tag
t
=
tags
[
j
];
if
(
t
.
kind
().
equals
(
"@h2.resource"
))
{
return
true
;
}
}
return
false
;
}
}
h2/src/tools/org/h2/build/i18n/PrepareTranslation.java
浏览文件 @
06fdb283
...
...
@@ -239,7 +239,7 @@ public class PrepareTranslation {
String
xml
=
IOUtils
.
readStringAndClose
(
new
InputStreamReader
(
new
FileInputStream
(
f
),
"UTF-8"
),
-
1
);
StringBuffer
template
=
new
StringBuffer
(
xml
.
length
());
int
id
=
0
;
Properties
prop
=
new
SortedProperties
();
Sorted
Properties
prop
=
new
SortedProperties
();
XMLParser
parser
=
new
XMLParser
(
xml
);
StringBuffer
buff
=
new
StringBuffer
();
Stack
stack
=
new
Stack
();
...
...
@@ -370,7 +370,7 @@ public class PrepareTranslation {
String
propFileName
=
target
+
"/_docs_"
+
MAIN_LANGUAGE
+
".properties"
;
Properties
old
=
SortedProperties
.
loadProperties
(
propFileName
);
prop
.
putAll
(
old
);
PropertiesToUTF8
.
storeProperties
(
prop
,
propFileName
);
prop
.
store
(
propFileName
);
String
t
=
template
.
toString
();
if
(
templateIsCopy
&&
!
t
.
equals
(
xml
))
{
for
(
int
i
=
0
;
i
<
Math
.
min
(
t
.
length
(),
xml
.
length
());
i
++)
{
...
...
@@ -413,7 +413,7 @@ public class PrepareTranslation {
ArrayList
translations
=
new
ArrayList
();
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
length
;
i
++)
{
File
f
=
list
[
i
];
if
(
f
.
getName
().
endsWith
(
".properties"
))
{
if
(
f
.
getName
().
endsWith
(
".properties"
)
&&
f
.
getName
().
indexOf
(
'_'
)
>=
0
)
{
if
(
f
.
getName
().
endsWith
(
"_"
+
MAIN_LANGUAGE
+
".properties"
))
{
main
=
f
;
}
else
{
...
...
@@ -421,20 +421,20 @@ public class PrepareTranslation {
}
}
}
Properties
p
=
SortedProperties
.
loadProperties
(
main
.
getAbsolutePath
());
Sorted
Properties
p
=
SortedProperties
.
loadProperties
(
main
.
getAbsolutePath
());
Properties
base
=
SortedProperties
.
loadProperties
(
baseDir
+
"/"
+
main
.
getName
());
PropertiesToUTF8
.
storeProperties
(
p
,
main
.
getAbsolutePath
());
p
.
store
(
main
.
getAbsolutePath
());
for
(
int
i
=
0
;
i
<
translations
.
size
();
i
++)
{
File
trans
=
(
File
)
translations
.
get
(
i
);
String
language
=
trans
.
getName
();
language
=
language
.
substring
(
language
.
lastIndexOf
(
'_'
)
+
1
,
language
.
lastIndexOf
(
'.'
));
prepare
(
p
,
base
,
trans
,
language
);
}
PropertiesToUTF8
.
storeProperties
(
p
,
baseDir
+
"/"
+
main
.
getName
());
p
.
store
(
baseDir
+
"/"
+
main
.
getName
());
}
private
void
prepare
(
Properties
main
,
Properties
base
,
File
trans
,
String
language
)
throws
IOException
{
Properties
p
=
SortedProperties
.
loadProperties
(
trans
.
getAbsolutePath
());
Sorted
Properties
p
=
SortedProperties
.
loadProperties
(
trans
.
getAbsolutePath
());
Properties
oldTranslations
=
new
Properties
();
for
(
Iterator
it
=
base
.
keySet
().
iterator
();
it
.
hasNext
();)
{
String
key
=
(
String
)
it
.
next
();
...
...
@@ -526,7 +526,7 @@ public class PrepareTranslation {
p
.
remove
(
key
);
}
}
PropertiesToUTF8
.
storeProperties
(
p
,
trans
.
getAbsolutePath
());
p
.
store
(
trans
.
getAbsolutePath
());
}
private
Map
autoTranslate
(
Set
toTranslate
,
String
sourceLanguage
,
String
targetLanguage
)
{
...
...
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
浏览文件 @
06fdb283
...
...
@@ -6,14 +6,9 @@
*/
package
org
.
h2
.
build
.
i18n
;
import
java.io.BufferedWriter
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.io.OutputStreamWriter
;
...
...
@@ -21,7 +16,6 @@ import java.io.PrintWriter;
import
java.io.RandomAccessFile
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
org.h2.build.code.CheckTextFiles
;
import
org.h2.build.indexer.HtmlConverter
;
import
org.h2.util.IOUtils
;
...
...
@@ -86,7 +80,7 @@ public class PropertiesToUTF8 {
}
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
"UTF-8"
));
try
{
Properties
prop
=
new
SortedProperties
();
Sorted
Properties
prop
=
new
SortedProperties
();
StringBuffer
buff
=
new
StringBuffer
();
String
key
=
null
;
boolean
found
=
false
;
...
...
@@ -116,7 +110,7 @@ public class PropertiesToUTF8 {
if
(
found
)
{
prop
.
setProperty
(
key
,
buff
.
toString
());
}
storeProperties
(
prop
,
target
);
prop
.
store
(
target
);
}
finally
{
reader
.
close
();
}
...
...
@@ -164,30 +158,4 @@ public class PropertiesToUTF8 {
}
}
/**
* Store a properties file.
*
* @param p the properties
* @param fileName the file name
*/
static
void
storeProperties
(
Properties
p
,
String
fileName
)
throws
IOException
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
p
.
store
(
out
,
null
);
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
InputStreamReader
reader
=
new
InputStreamReader
(
in
,
"ISO8859-1"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
FileWriter
w
=
new
FileWriter
(
fileName
);
PrintWriter
writer
=
new
PrintWriter
(
new
BufferedWriter
(
w
));
while
(
true
)
{
String
line
=
r
.
readLine
();
if
(
line
==
null
)
{
break
;
}
if
(!
line
.
startsWith
(
"#"
))
{
writer
.
println
(
line
);
}
}
writer
.
close
();
}
}
h2/src/tools/org/h2/dev/util/FileViewer.java
浏览文件 @
06fdb283
...
...
@@ -28,7 +28,7 @@ public class FileViewer extends Tool {
new
FileViewer
().
run
(
args
);
}
pr
ivate
void
showUsage
()
{
pr
otected
void
showUsage
()
{
out
.
println
(
"A text file viewer that support very large files."
);
out
.
println
(
"java "
+
getClass
().
getName
()
+
"\n"
+
" -file <file> The name of the file to view\n"
+
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论