public class DocumentParser extends Parser
这将消息为所有有效的标签的回调,以及隐含的标签,但没有明确指定。例如,HTML字符串(
等等)只有一个标签定义。回调将看到以下方法:
HTMLEditorKit.ParserCallback.IMPLIED
Boolean.TRUE
。
HTML属性定义类型安全枚举HTML属性。如果一个标签的属性主要是定义在HTML属性,HTML属性将作为重点,否则一个字符串将被使用。例如< P foo =杆类=整洁>有两个属性。foo中没有定义的HTML。属性,而阶级,因此attributeset将在这两个值,HTML.Attribute.CLASS和一个字符串值“整洁”和关键字符串foo和bar的字符串值。
位置参数将显示标签、注释或文本的开始位置。类似于数组,流中的第一个字符的位置为0。对于暗示该位置的标签将显示下一个遇到的标签的位置。在第一个例子中,隐含的启动主体和HTML标签将位置p标签一样,与隐含端P,HTML和体标记都有相同的位置。
为HTML跳过空白位置的文本将是第一个有效字符的位置,如字符串“\n \n\n nblah”文本“废话”将有一个位置3,换行符被跳过。
属性不具有价值,例如在HTML字符串的属性<foo blah>
blah
没有价值,有两个可能的值,将被放置在attributeset的价值:
HTML.NULL_ATTRIBUTE_VALUE
。<!ATTLIST OPTION selected (selected) #IMPLIED>
这个值从DTD(在这种情况下选择)将被使用。一旦流已被解析,则通知回调是最有可能的行字符串结束的。字符串的结尾将是一个\ n,R或R \ N,这是遇到最多的解析流。
ANY, CDATA, CONREF, CURRENT, DEFAULT, EMPTY, ENDTAG, ENTITIES, ENTITY, FIXED, GENERAL, ID, IDREF, IDREFS, IMPLIED, MD, MODEL, MS, NAME, NAMES, NMTOKEN, NMTOKENS, NOTATION, NUMBER, NUMBERS, NUTOKEN, NUTOKENS, PARAMETER, PI, PUBLIC, RCDATA, REQUIRED, SDATA, STARTTAG, SYSTEM
Constructor and Description |
---|
DocumentParser(DTD dtd) |
Modifier and Type | Method and Description |
---|---|
protected void |
handleComment(char[] text)
当一个HTML注释时。
|
protected void |
handleEmptyTag(TagElement tag)
处理空标签。
|
protected void |
handleEndTag(TagElement tag)
处理结束标签。
|
protected void |
handleError(int ln, String errorMsg)
发生了一个错误。
|
protected void |
handleStartTag(TagElement tag)
处理开始标签。
|
protected void |
handleText(char[] data)
处理文本。
|
void |
parse(Reader in, HTMLEditorKit.ParserCallback callback, boolean ignoreCharSet) |
endTag, error, error, error, error, flushAttributes, getAttributes, getCurrentLine, getCurrentPos, handleEOFInComment, handleTitle, makeTag, makeTag, markFirstTime, parse, parseDTDMarkup, parseMarkupDeclarations, startTag
public DocumentParser(DTD dtd)
public void parse(Reader in, HTMLEditorKit.ParserCallback callback, boolean ignoreCharSet) throws IOException
IOException
protected void handleStartTag(TagElement tag)
handleStartTag
方法重写,继承类
Parser
protected void handleComment(char[] text)
Parser
handleComment
方法重写,继承类
Parser
protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException
handleEmptyTag
方法重写,继承类
Parser
ChangedCharSetException
protected void handleEndTag(TagElement tag)
handleEndTag
方法重写,继承类
Parser
protected void handleText(char[] data)
handleText
方法重写,继承类
Parser
protected void handleError(int ln, String errorMsg)
Parser
handleError
方法重写,继承类
Parser
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.