public class HTMLDocument.HTMLReader extends HTMLEditorKit.ParserCallback
 可以通过注册描述如何处理操作的操作(类型HTMLDocument.HTMLReader.TagAction )来配置读取器。 所提供的动作背后的想法是,如果元素结构归结为具有某种风格的段落的段落,则可以提供最自然的文本编辑操作。 有些事情在结构上更自然地指定,所以任意结构应该允许在段落之上,但是需要用结构性的操作进行编辑。 这意味着,要解析的流中指定的一些HTML元素将被折叠为属性,在某些情况下,段将被合成。 当HTML元素已转换为属性时,属性键将为HTML.Tag类型,该值将为AttributeSet类型,因此不会丢失任何信息。 这使得许多现有的动作能够工作,以便用户可以输入输入,按回车键,退格键,删除等等,并得到合理的结果。 可以创建选择,应用或删除属性等。考虑到这一点,读者完成的工作可以分为以下几种任务: 
目前,不支持<APPLET>,<PARAM>,<MAP>,<AREA>,<LINK>,<SCRIPT>和<STYLE>。
 对于HTML.Tag中定义的标签,下表列出了所描述的HTML.Tag 。 
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)
              添加在PRE元素中遇到的给定内容。 
             | 
| protected void | pushCharacterStyle()
              在堆栈中推送当前字符样式,以准备形成新的嵌套字符样式。 
             | 
| protected void | registerTag(HTML.Tag t, HTMLDocument.HTMLReader.TagAction a)
              注册给定标签的处理程序。 
             | 
| protected void | textAreaContent(char[] data)
              将给定的内容添加到textarea文档。 
             | 
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 
          public void handleText(char[] data,
                       int pos) 
          public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos)
public void handleComment(char[] data,
                          int pos) 
           public void handleEndTag(HTML.Tag t, int pos)
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
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.