public class HTMLDocument.HTMLReader extends HTMLEditorKit.ParserCallback
读者可以通过注册行为配置(类型HTMLDocument.HTMLReader.TagAction)描述如何处理动作。提供的行动背后的想法是,最自然的文本编辑操作,可以提供,如果元素结构归结为一段,在他们的某种风格的运行。有些东西在结构上是比较自然的,所以在段落的上方应该允许任意的结构,但需要用结构的动作来编辑。也就是说一些在流解析指定的HTML元素将坍塌为属性,并在某些情况下,将合成的段落。当HTML元素都被转换为属性,该属性的关键将是类型的HTML。标签和值将attributeset型,没有信息丢失。这使得许多现有的行动,以便用户可以输入,按回车键,退格键,删除,等有一个合理的结果。可以创建选择,应用或删除的属性,等等。这在头脑中,读者所做的工作可以分为以下几种任务:
目前, <程序> 、 <参数> , 参数> 程序>
的行为描述的分配如下表所示为HTML.Tag定义的标签。
| Tag | Action |
|---|---|
HTML.Tag.A |
CharacterAction |
HTML.Tag.ADDRESS |
CharacterAction |
HTML.Tag.APPLET |
HiddenAction |
HTML.Tag.AREA |
AreaAction |
HTML.Tag.B |
CharacterAction |
HTML.Tag.BASE |
BaseAction |
HTML.Tag.BASEFONT |
CharacterAction |
HTML.Tag.BIG |
CharacterAction |
HTML.Tag.BLOCKQUOTE |
BlockAction |
HTML.Tag.BODY |
BlockAction |
HTML.Tag.BR |
SpecialAction |
HTML.Tag.CAPTION |
BlockAction |
HTML.Tag.CENTER |
BlockAction |
HTML.Tag.CITE |
CharacterAction |
HTML.Tag.CODE |
CharacterAction |
HTML.Tag.DD |
BlockAction |
HTML.Tag.DFN |
CharacterAction |
HTML.Tag.DIR |
BlockAction |
HTML.Tag.DIV |
BlockAction |
HTML.Tag.DL |
BlockAction |
HTML.Tag.DT |
ParagraphAction |
HTML.Tag.EM |
CharacterAction |
HTML.Tag.FONT |
CharacterAction |
HTML.Tag.FORM |
As of 1.4 a BlockAction |
HTML.Tag.FRAME |
SpecialAction |
HTML.Tag.FRAMESET |
BlockAction |
HTML.Tag.H1 |
ParagraphAction |
HTML.Tag.H2 |
ParagraphAction |
HTML.Tag.H3 |
ParagraphAction |
HTML.Tag.H4 |
ParagraphAction |
HTML.Tag.H5 |
ParagraphAction |
HTML.Tag.H6 |
ParagraphAction |
HTML.Tag.HEAD |
HeadAction |
HTML.Tag.HR |
SpecialAction |
HTML.Tag.HTML |
BlockAction |
HTML.Tag.I |
CharacterAction |
HTML.Tag.IMG |
SpecialAction |
HTML.Tag.INPUT |
FormAction |
HTML.Tag.ISINDEX |
IsndexAction |
HTML.Tag.KBD |
CharacterAction |
HTML.Tag.LI |
BlockAction |
HTML.Tag.LINK |
LinkAction |
HTML.Tag.MAP |
MapAction |
HTML.Tag.MENU |
BlockAction |
HTML.Tag.META |
MetaAction |
HTML.Tag.NOFRAMES |
BlockAction |
HTML.Tag.OBJECT |
SpecialAction |
HTML.Tag.OL |
BlockAction |
HTML.Tag.OPTION |
FormAction |
HTML.Tag.P |
ParagraphAction |
HTML.Tag.PARAM |
HiddenAction |
HTML.Tag.PRE |
PreAction |
HTML.Tag.SAMP |
CharacterAction |
HTML.Tag.SCRIPT |
HiddenAction |
HTML.Tag.SELECT |
FormAction |
HTML.Tag.SMALL |
CharacterAction |
HTML.Tag.STRIKE |
CharacterAction |
HTML.Tag.S |
CharacterAction |
HTML.Tag.STRONG |
CharacterAction |
HTML.Tag.STYLE |
StyleAction |
HTML.Tag.SUB |
CharacterAction |
HTML.Tag.SUP |
CharacterAction |
HTML.Tag.TABLE |
BlockAction |
HTML.Tag.TD |
BlockAction |
HTML.Tag.TEXTAREA |
FormAction |
HTML.Tag.TH |
BlockAction |
HTML.Tag.TITLE |
TitleAction |
HTML.Tag.TR |
BlockAction |
HTML.Tag.TT |
CharacterAction |
HTML.Tag.U |
CharacterAction |
HTML.Tag.UL |
BlockAction |
HTML.Tag.VAR |
CharacterAction |
一旦遇到< / HTML >,动作不再通知。
| Modifier and Type | Class and Description |
|---|---|
class |
HTMLDocument.HTMLReader.BlockAction |
class |
HTMLDocument.HTMLReader.CharacterAction |
class |
HTMLDocument.HTMLReader.FormAction
通过建立用于表示窗体控件的所有元素的形式来支持窗体的作用。
|
class |
HTMLDocument.HTMLReader.HiddenAction |
class |
HTMLDocument.HTMLReader.IsindexAction |
class |
HTMLDocument.HTMLReader.ParagraphAction |
class |
HTMLDocument.HTMLReader.PreAction |
class |
HTMLDocument.HTMLReader.SpecialAction |
class |
HTMLDocument.HTMLReader.TagAction
响应解析标签的动作要执行的操作。
|
| Modifier and Type | Field and Description |
|---|---|
protected MutableAttributeSet |
charAttr |
protected Vector<DefaultStyledDocument.ElementSpec> |
parseBuffer |
IMPLIED| Constructor and Description |
|---|
HTMLReader(int offset) |
HTMLReader(int offset, int popDepth, int pushDepth, HTML.Tag insertTag) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addContent(char[] data, int offs, int length)
添加了一些当前字符属性的文本。
|
protected void |
addContent(char[] data, int offs, int length, boolean generateImpliedPIfNecessary)
添加了一些当前字符属性的文本。
|
protected void |
addSpecialElement(HTML.Tag t, MutableAttributeSet a)
添加基本上完全在属性集中指定的内容。
|
protected void |
blockClose(HTML.Tag t)
向解析缓冲区添加一个指令,以关闭给定类型的块元素。
|
protected void |
blockOpen(HTML.Tag t, MutableAttributeSet attr)
向解析缓冲区添加一个指令,以创建给定属性的块元素。
|
void |
flush()
最后一种方法调用阅读器。
|
void |
handleComment(char[] data, int pos) |
void |
handleEndOfLineString(String eol)
这是调用后流解析完毕,但在
flush。
|
void |
handleEndTag(HTML.Tag t, int pos)
从解析器回调。
|
void |
handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
从解析器回调。
|
void |
handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
从解析器回调。
|
void |
handleText(char[] data, int pos)
由解析器调用来表示遇到了一个文本块。
|
protected void |
popCharacterStyle()
弹出一个以前推的字符样式关闭堆栈返回到以前的样式。
|
protected void |
preContent(char[] data)
添加在预元素中遇到的给定内容。
|
protected void |
pushCharacterStyle()
将当前的字符样式推到堆栈上,以形成一个新的嵌套字符样式。
|
protected void |
registerTag(HTML.Tag t, HTMLDocument.HTMLReader.TagAction a)
为给定的标签注册一个处理程序。
|
protected void |
textAreaContent(char[] data)
由于增加了内容的文本文件。
|
handleErrorprotected Vector<DefaultStyledDocument.ElementSpec> parseBuffer
protected MutableAttributeSet charAttr
public HTMLReader(int offset)
public HTMLReader(int offset,
int popDepth,
int pushDepth,
HTML.Tag insertTag) public void flush()
throws BadLocationException
flush 方法重写,继承类
HTMLEditorKit.ParserCallback
BadLocationException
public void handleText(char[] data,
int pos)
handleText 方法重写,继承类
HTMLEditorKit.ParserCallback
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
handleStartTag 方法重写,继承类
HTMLEditorKit.ParserCallback
public void handleComment(char[] data,
int pos)
handleComment 方法重写,继承类
HTMLEditorKit.ParserCallback
public void handleEndTag(HTML.Tag t, int pos)
handleEndTag 方法重写,继承类
HTMLEditorKit.ParserCallback
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
handleSimpleTag 方法重写,继承类
HTMLEditorKit.ParserCallback
public void handleEndOfLineString(String eol)
flush。
eol将其中n、R或\r\n,这曾经是遇到的最在解析流。
handleEndOfLineString 方法重写,继承类
HTMLEditorKit.ParserCallback
protected void registerTag(HTML.Tag t, HTMLDocument.HTMLReader.TagAction a)
protected void pushCharacterStyle()
protected void popCharacterStyle()
protected void textAreaContent(char[] data)
protected void preContent(char[] data)
protected void blockOpen(HTML.Tag t, MutableAttributeSet attr)
protected void blockClose(HTML.Tag t)
protected void addContent(char[] data,
int offs,
int length)
data -添加内容
offs -
length -长度
protected void addContent(char[] data,
int offs,
int length,
boolean generateImpliedPIfNecessary)
data -添加内容
offs -初始偏移
length -长度
generateImpliedPIfNecessary -是否产生暗示的段落
protected void addSpecialElement(HTML.Tag t, MutableAttributeSet a)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.