Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
dfade77f
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dfade77f
编写于
5月 14, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8012180: Speed up removeNonInlineHtmlTags
Reviewed-by: darcy
上级
d0d3e2f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
84 addition
and
73 deletion
+84
-73
src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
.../com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+44
-55
src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
...sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+1
-3
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
...es/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
+7
-5
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
...ses/com/sun/tools/doclets/internal/toolkit/util/Util.java
+32
-10
未找到文件。
src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
浏览文件 @
dfade77f
...
...
@@ -1620,14 +1620,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if
(
isFirstSentence
)
{
text
=
removeNonInlineHtmlTags
(
text
);
}
StringTokenizer
lines
=
new
StringTokenizer
(
text
,
"\r\n"
,
true
);
StringBuilder
textBuff
=
new
StringBuilder
();
while
(
lines
.
hasMoreTokens
())
{
StringBuilder
line
=
new
StringBuilder
(
lines
.
nextToken
());
Util
.
replaceTabs
(
configuration
,
line
);
textBuff
.
append
(
line
.
toString
());
}
result
.
addContent
(
new
RawHtml
(
textBuff
.
toString
()));
text
=
Util
.
replaceTabs
(
configuration
,
text
);
result
.
addContent
(
new
RawHtml
(
text
));
}
}
return
result
;
...
...
@@ -1732,60 +1726,55 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return
text
;
}
public
String
removeNonInlineHtmlTags
(
String
text
)
{
if
(
text
.
indexOf
(
'<'
)
<
0
)
{
return
text
;
static
Set
<
String
>
blockTags
=
new
HashSet
<>();
static
{
for
(
HtmlTag
t:
HtmlTag
.
values
())
{
if
(
t
.
blockType
==
HtmlTag
.
BlockType
.
BLOCK
)
blockTags
.
add
(
t
.
value
);
}
String
noninlinetags
[]
=
{
"<ul>"
,
"</ul>"
,
"<ol>"
,
"</ol>"
,
"<dl>"
,
"</dl>"
,
"<table>"
,
"</table>"
,
"<tr>"
,
"</tr>"
,
"<td>"
,
"</td>"
,
"<th>"
,
"</th>"
,
"<p>"
,
"</p>"
,
"<li>"
,
"</li>"
,
"<dd>"
,
"</dd>"
,
"<dir>"
,
"</dir>"
,
"<dt>"
,
"</dt>"
,
"<h1>"
,
"</h1>"
,
"<h2>"
,
"</h2>"
,
"<h3>"
,
"</h3>"
,
"<h4>"
,
"</h4>"
,
"<h5>"
,
"</h5>"
,
"<h6>"
,
"</h6>"
,
"<pre>"
,
"</pre>"
,
"<menu>"
,
"</menu>"
,
"<listing>"
,
"</listing>"
,
"<hr>"
,
"<blockquote>"
,
"</blockquote>"
,
"<center>"
,
"</center>"
,
"<UL>"
,
"</UL>"
,
"<OL>"
,
"</OL>"
,
"<DL>"
,
"</DL>"
,
"<TABLE>"
,
"</TABLE>"
,
"<TR>"
,
"</TR>"
,
"<TD>"
,
"</TD>"
,
"<TH>"
,
"</TH>"
,
"<P>"
,
"</P>"
,
"<LI>"
,
"</LI>"
,
"<DD>"
,
"</DD>"
,
"<DIR>"
,
"</DIR>"
,
"<DT>"
,
"</DT>"
,
"<H1>"
,
"</H1>"
,
"<H2>"
,
"</H2>"
,
"<H3>"
,
"</H3>"
,
"<H4>"
,
"</H4>"
,
"<H5>"
,
"</H5>"
,
"<H6>"
,
"</H6>"
,
"<PRE>"
,
"</PRE>"
,
"<MENU>"
,
"</MENU>"
,
"<LISTING>"
,
"</LISTING>"
,
"<HR>"
,
"<BLOCKQUOTE>"
,
"</BLOCKQUOTE>"
,
"<CENTER>"
,
"</CENTER>"
};
for
(
int
i
=
0
;
i
<
noninlinetags
.
length
;
i
++)
{
text
=
replace
(
text
,
noninlinetags
[
i
],
""
);
}
return
text
;
}
public
String
replace
(
String
text
,
String
tobe
,
String
by
)
{
while
(
true
)
{
int
startindex
=
text
.
indexOf
(
tobe
);
if
(
startindex
<
0
)
{
return
text
;
public
static
String
removeNonInlineHtmlTags
(
String
text
)
{
final
int
len
=
text
.
length
();
int
startPos
=
0
;
// start of text to copy
int
lessThanPos
=
text
.
indexOf
(
'<'
);
// position of latest '<'
if
(
lessThanPos
<
0
)
{
return
text
;
}
StringBuilder
result
=
new
StringBuilder
();
main:
while
(
lessThanPos
!=
-
1
)
{
int
currPos
=
lessThanPos
+
1
;
if
(
currPos
==
len
)
break
;
char
ch
=
text
.
charAt
(
currPos
);
if
(
ch
==
'/'
)
{
if
(++
currPos
==
len
)
break
;
ch
=
text
.
charAt
(
currPos
);
}
int
endindex
=
startindex
+
tobe
.
length
();
StringBuilder
replaced
=
new
StringBuilder
();
if
(
startindex
>
0
)
{
replaced
.
append
(
text
.
substring
(
0
,
startindex
));
int
tagPos
=
currPos
;
while
(
isHtmlTagLetterOrDigit
(
ch
))
{
if
(++
currPos
==
len
)
break
main
;
ch
=
text
.
charAt
(
currPos
);
}
replaced
.
append
(
by
);
if
(
text
.
length
()
>
endindex
)
{
replaced
.
append
(
text
.
substring
(
endindex
))
;
if
(
ch
==
'>'
&&
blockTags
.
contains
(
text
.
substring
(
tagPos
,
currPos
).
toLowerCase
()))
{
result
.
append
(
text
,
startPos
,
lessThanPos
);
startPos
=
currPos
+
1
;
}
text
=
replaced
.
toString
(
);
lessThanPos
=
text
.
indexOf
(
'<'
,
currPos
);
}
result
.
append
(
text
.
substring
(
startPos
));
return
result
.
toString
();
}
private
static
boolean
isHtmlTagLetterOrDigit
(
char
ch
)
{
return
(
'a'
<=
ch
&&
ch
<=
'z'
)
||
(
'A'
<=
ch
&&
ch
<=
'Z'
)
||
(
'1'
<=
ch
&&
ch
<=
'6'
);
}
/**
...
...
src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
浏览文件 @
dfade77f
...
...
@@ -269,9 +269,7 @@ public class SourceToHTMLConverter {
*/
private
void
addLine
(
Content
pre
,
String
line
,
int
currentLineNo
)
{
if
(
line
!=
null
)
{
StringBuilder
lineBuffer
=
new
StringBuilder
(
line
);
Util
.
replaceTabs
(
configuration
,
lineBuffer
);
pre
.
addContent
(
lineBuffer
.
toString
());
pre
.
addContent
(
Util
.
replaceTabs
(
configuration
,
line
));
Content
anchor
=
HtmlTree
.
A_NAME
(
"line."
+
Integer
.
toString
(
currentLineNo
));
pre
.
addContent
(
anchor
);
pre
.
addContent
(
NEW_LINE
);
...
...
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
浏览文件 @
dfade77f
...
...
@@ -44,6 +44,7 @@ public enum HtmlTag {
CENTER
,
CODE
(
BlockType
.
INLINE
,
EndTag
.
END
),
DD
,
DIR
,
DIV
,
DL
,
DT
,
...
...
@@ -63,6 +64,7 @@ public enum HtmlTag {
I
(
BlockType
.
INLINE
,
EndTag
.
END
),
IMG
(
BlockType
.
INLINE
,
EndTag
.
NOEND
),
LI
,
LISTING
,
LINK
(
BlockType
.
OTHER
,
EndTag
.
NOEND
),
MENU
,
META
(
BlockType
.
OTHER
,
EndTag
.
NOEND
),
...
...
@@ -85,14 +87,14 @@ public enum HtmlTag {
TT
(
BlockType
.
INLINE
,
EndTag
.
END
),
UL
;
p
rotected
final
BlockType
blockType
;
p
rotected
final
EndTag
endTag
;
p
rivate
final
String
value
;
p
ublic
final
BlockType
blockType
;
p
ublic
final
EndTag
endTag
;
p
ublic
final
String
value
;
/**
* Enum representing the type of HTML element.
*/
p
rotected
static
enum
BlockType
{
p
ublic
static
enum
BlockType
{
BLOCK
,
INLINE
,
OTHER
;
...
...
@@ -101,7 +103,7 @@ public enum HtmlTag {
/**
* Enum representing HTML end tag requirement.
*/
p
rotected
static
enum
EndTag
{
p
ublic
static
enum
EndTag
{
END
,
NOEND
;
}
...
...
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
浏览文件 @
dfade77f
...
...
@@ -593,20 +593,42 @@ public class Util {
}
/**
* Replace all tabs with the appropriate number of spaces.
* Replace all tabs in a string with the appropriate number of spaces.
* The string may be a multi-line string.
* @param configuration the doclet configuration defining the setting for the
* tab length.
* @param sb the StringBuilder in which to replace the tabs
* @param text the text for which the tabs should be expanded
* @return the text with all tabs expanded
*/
public
static
void
replaceTabs
(
Configuration
configuration
,
StringBuilder
sb
)
{
int
tabLength
=
configuration
.
sourcetab
;
String
whitespace
=
configuration
.
tabSpaces
;
int
index
=
0
;
while
((
index
=
sb
.
indexOf
(
"\t"
,
index
))
!=
-
1
)
{
int
spaceCount
=
tabLength
-
index
%
tabLength
;
sb
.
replace
(
index
,
index
+
1
,
whitespace
.
substring
(
0
,
spaceCount
));
index
+=
spaceCount
;
public
static
String
replaceTabs
(
Configuration
configuration
,
String
text
)
{
if
(
text
.
indexOf
(
"\t"
)
==
-
1
)
return
text
;
final
int
tabLength
=
configuration
.
sourcetab
;
final
String
whitespace
=
configuration
.
tabSpaces
;
final
int
textLength
=
text
.
length
();
StringBuilder
result
=
new
StringBuilder
(
textLength
);
int
pos
=
0
;
int
lineLength
=
0
;
for
(
int
i
=
0
;
i
<
textLength
;
i
++)
{
char
ch
=
text
.
charAt
(
i
);
switch
(
ch
)
{
case
'\n'
:
case
'\r'
:
lineLength
=
0
;
break
;
case
'\t'
:
result
.
append
(
text
,
pos
,
i
);
int
spaceCount
=
tabLength
-
lineLength
%
tabLength
;
result
.
append
(
whitespace
,
0
,
spaceCount
);
lineLength
+=
spaceCount
;
pos
=
i
+
1
;
break
;
default
:
lineLength
++;
}
}
result
.
append
(
text
,
pos
,
textLength
);
return
result
.
toString
();
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录