- java.lang.Object
-
- javax.swing.text.AbstractWriter
-
- javax.swing.text.html.HTMLWriter
-
public class HTMLWriter extends AbstractWriter
这是HTMLDocuments的作者。
-
-
Field Summary
-
Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
-
-
构造方法摘要
构造方法 Constructor 描述 HTMLWriter(Writer w, HTMLDocument doc)创建一个新的HTMLWriter。HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)创建一个新的HTMLWriter。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected voidcloseOutUnwantedEmbeddedTags(AttributeSet attr)搜索属性集和存储在标签向量中的每个标签。protected voidcomment(Element elem)写出评论。protected voidemptyTag(Element elem)写出所有空的元素(所有没有相应的结束标签的标签)。protected voidendTag(Element elem)写出元素的结束标签。protected booleanisBlockTag(AttributeSet attr)确定与元素关联的HTML.Tag是否是块标记。protected booleanmatchNameAttribute(AttributeSet attr, HTML.Tag tag)如果StyleConstants.NameAttribute等于作为参数传入的标签,则返回true。protected voidoutput(char[] chars, int start, int length)该方法被覆盖以映射任何字符实体,例如<到&lt;。protected voidselectContent(AttributeSet attr)写出SELECT表单元素的内容。protected voidstartTag(Element elem)写出元素的开始标签。protected booleansynthesizedElement(Element elem)如果元素是合成元素,则返回true。protected voidtext(Element elem)写出文字。protected voidtextAreaContent(AttributeSet attr)写出TEXTAREA表单元素中包含的文本。voidwrite()迭代元素树,并控制所有标签及其属性的写入。protected voidwriteAttributes(AttributeSet attr)写出属性集。protected voidwriteEmbeddedTags(AttributeSet attr)在AttributeSet中搜索嵌入式标签并将其写入。protected voidwriteLineSeparator()写行分隔符。protected voidwriteOption(Option option)写出选项表单元素的内容。-
Methods inherited from class javax.swing.text.AbstractWriter
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write
-
-
-
-
构造方法详细信息
-
HTMLWriter
public HTMLWriter(Writer w, HTMLDocument doc)
创建一个新的HTMLWriter。- 参数
-
w- 作家 -
doc- 一个HTMLDocument
-
HTMLWriter
public HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)
创建一个新的HTMLWriter。- 参数
-
w- 作家 -
doc- 一个HTMLDocument -
pos- 从中获取内容的文档位置 -
len- 写出的金额
-
-
方法详细信息
-
write
public void write() throws IOException, BadLocationException迭代元素树,并控制所有标签及其属性的写入。- Specified by:
-
write在AbstractWriter - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
writeAttributes
protected void writeAttributes(AttributeSet attr) throws IOException
写出属性集。 使用类型为HTML.Tag的键忽略所有属性,具有StyleConstants类型的键的属性,以及具有类型为HTML.Attribute.ENDTAG的键的属性。- 重写:
-
writeAttributes在AbstractWriter - 参数
-
attr- 属性集 - 异常
-
IOException- 在任何I / O错误
-
emptyTag
protected void emptyTag(Element elem) throws BadLocationException, IOException
写出所有空的元素(所有没有相应的结束标签的标签)。- 参数
-
elem- 一个元素 - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
isBlockTag
protected boolean isBlockTag(AttributeSet attr)
确定与元素关联的HTML.Tag是否是块标记。- 参数
-
attr- 一个AttributeSet - 结果
- 如果标签是块标记,则为true,否则为false。
-
startTag
protected void startTag(Element elem) throws IOException, BadLocationException
写出元素的开始标签。 忽略所有合成元素。- 参数
-
elem- 一个元素 - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
textAreaContent
protected void textAreaContent(AttributeSet attr) throws BadLocationException, IOException
写出TEXTAREA表单元素中包含的文本。- 参数
-
attr- 一个AttributeSet - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
text
protected void text(Element elem) throws BadLocationException, IOException
写出文字。 如果在调用构造函数时指定了一个范围,则只写出适当的文本范围。- 重写:
-
text类AbstractWriter - 参数
-
elem- 一个元素 - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
selectContent
protected void selectContent(AttributeSet attr) throws IOException
写出SELECT表单元素的内容。- 参数
-
attr- 与表单元素关联的AttributeSet - 异常
-
IOException- 任何I / O错误
-
writeOption
protected void writeOption(Option option) throws IOException
写出选项表单元素的内容。- 参数
-
option- 一个选项 - 异常
-
IOException- 在任何I / O错误
-
endTag
protected void endTag(Element elem) throws IOException
写出元素的结束标签。- 参数
-
elem- 一个元素 - 异常
-
IOException- 在任何I / O错误
-
comment
protected void comment(Element elem) throws BadLocationException, IOException
写出评论。- 参数
-
elem- 一个元素 - 异常
-
IOException- 在任何I / O错误 -
BadLocationException- 如果pos表示文档中的无效位置。
-
synthesizedElement
protected boolean synthesizedElement(Element elem)
如果元素是合成元素,则返回true。 目前,我们只是测试了p-implied标签。- 参数
-
elem- 一个元素 - 结果
-
true如果元素是一个合成元素。
-
matchNameAttribute
protected boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag)
如果StyleConstants.NameAttribute等于作为参数传入的标签,则返回true。- 参数
-
attr- 一组属性 -
tag- 一个HTML标签 - 结果
-
true如果StyleConstants.NameAttribute等于传递作为参数的标记。
-
writeEmbeddedTags
protected void writeEmbeddedTags(AttributeSet attr) throws IOException
在AttributeSet中搜索嵌入式标签并将其写入。 它还将这些标签存储在一个向量中,以便在适当的时候可以写出相应的结束标签。- 参数
-
attr- 一组属性 - 异常
-
IOException- 任何I / O错误
-
closeOutUnwantedEmbeddedTags
protected void closeOutUnwantedEmbeddedTags(AttributeSet attr) throws IOException
搜索属性集和存储在标签向量中的每个标签。 如果没有找到标签,则从矢量中删除标签,并写出相应的结束标签。- 参数
-
attr- 一组属性 - 异常
-
IOException- 任何I / O错误
-
writeLineSeparator
protected void writeLineSeparator() throws IOException写行分隔符。 这是覆盖的,以确保我们不会替换换行符,因为它不在正常的ascii之外。- 重写:
-
writeLineSeparator在AbstractWriter - 异常
-
IOException- 任何I / O错误 - 从以下版本开始:
- 1.3
-
output
protected void output(char[] chars, int start, int length) throws IOException该方法被覆盖以映射任何字符实体,例如<到&lt;。super.output将被调用来写入内容。- 重写:
-
output在AbstractWriter - 参数
-
chars- 要输出的字符 -
start- 起始索引 -
length- 输出长度 - 异常
-
IOException- 在任何I / O错误 - 从以下版本开始:
- 1.3
-
-