- java.lang.Object
-
- javax.swing.text.AbstractWriter
-
- javax.swing.text.html.HTMLWriter
-
public class HTMLWriter extends AbstractWriter
这是HTMLDocuments的编写者。
-
-
字段汇总
-
声明的属性在类 javax.swing.text.AbstractWriter
NEWLINE
-
-
构造方法摘要
构造方法 构造器 描述 HTMLWriter(Writer w, HTMLDocument doc)创建一个新的HTMLWriter。HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)创建一个新的HTMLWriter。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 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)重写此方法以映射任何字符实体,例如<to&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)写出Option表单元素的内容。-
声明方法的类 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- 一个AttributeSet - 异常
-
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 - 结果
- 如果tag是块标记,则返回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表单元素的内容。- 参数
-
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重写此方法以映射任何字符实体,例如<to&lt;。 将调用super.output来写入内容。- 重写:
-
output类AbstractWriter - 参数
-
chars- 要输出的字符 -
start- 起始索引 -
length- 输出长度 - 异常
-
IOException- 关于任何I / O错误 - 从以下版本开始:
- 1.3
-
-