所有类


javax.swing.text.html
类 MinimalHTMLWriter

java.lang.Object
  继承者 javax.swing.text.AbstractWriter
      继承者 javax.swing.text.html.MinimalHTMLWriter

public class MinimalHTMLWriter
   
   
   
   
extends AbstractWriter

MinimalHTMLWriter 是一个回退 writer,HTMLEditorKit 使用它为非 EditorKit 生成的文档写出 HTML。 文档的格式为:

 <html>
   <head>
     <style>
        <!-- list of named styles
         p.normal {
            font-family: SansSerif;
              margin-height: 0;
              font-size: 14
           }
        -->
      </style>
   </head>
   <body>
    <p style=normal>
        Bold, italic, and underline attributes
        of the run are emitted as HTML tags.
        The remaining attributes are emitted as
        part of the style attribute of a <span> tag.
        The syntax is similar to inline styles.
</p>
   </body>
 </html>
 


字段摘要
 
从类 javax.swing.text.AbstractWriter 继承的字段
NEWLINE
 
构造方法摘要
MinimalHTMLWriter(Writer w, StyledDocument doc)
          创建一个新的 MinimalHTMLWriter。
MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len)
          创建一个新的 MinimalHTMLWriter。
 
方法摘要
protected  voidendFontTag()
          此方法已不再使用,而用写出 <span> 来替换。
protected  booleaninFontTag()
          如果我们当前正处在 <font> 标记中,则返回 true。
protected  booleanisText(Element elem)
          如果元素是文本元素,则返回 true。
protected  voidstartFontTag(String style)
          此方法已不再使用,而用写出 <span> 来替换。
protected  voidtext(Element elem)
          写出文本。
 voidwrite()
          从 StyledDocument 生成 HTML 输出。
protected  voidwriteAttributes(AttributeSet attr)
          写出以下类型的所有属性:StyleConstants.ParagraphConstants、StyleConstants.CharacterConstants、StyleConstants.FontConstants、StyleConstants.ColorConstants。
protected  voidwriteBody()
          对文档中的元素进行迭代,并基于元素是分支元素还是叶元素来处理它们。
protected  voidwriteComponent(Element elem)
          负责处理 Component Elements;有意不实现它。
protected  voidwriteContent(Element elem, boolean needsIndenting)
          以与 HTML 兼容的方式写出属性集。
protected  voidwriteEndParagraph()
          发出 <p> 标记的结束标记。
protected  voidwriteEndTag(String endTag)
          写出适当缩进的结束标记。
protected  voidwriteHeader()
          写出 <head> 和 <style> 标记,然后调用 writeStyles(),以写出所有命名的样式,这些样式作为 <style> 标记的内容。
protected  voidwriteHTMLTags(AttributeSet attr)
          基于文本的属性设置生成文本的 bold <b>、italic <i> 和 <u> 标记。
protected  voidwriteImage(Element elem)
          负责处理 Icon Elements;有意不实现它。
protected  voidwriteLeaf(Element elem)
          负责写出其他非文本叶元素。
protected  voidwriteNonHTMLAttributes(AttributeSet attr)
          以与 HTML 兼容的方式写出其余的字符级属性(bold、italic 和 underline 之外的属性)。
protected  voidwriteStartParagraph(Element elem)
          发出段落的开始标记。
protected  voidwriteStartTag(String tag)
          写出适当缩进的开始标记。
protected  voidwriteStyles()
          写出所有命名的样式,这些样式作为 <style> 标记的内容。
 
从类 javax.swing.text.AbstractWriter 继承的方法
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, output, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write, writeLineSeparator
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

MinimalHTMLWriter

public MinimalHTMLWriter(Writer w,
                         StyledDocument doc)
创建一个新的 MinimalHTMLWriter。

参数:
w - Writer
doc - StyledDocument

MinimalHTMLWriter

public MinimalHTMLWriter(Writer w,
                         StyledDocument doc,
                         int pos,
                         int len)
创建一个新的 MinimalHTMLWriter。

参数:
w - Writer
doc - StyledDocument
pos - 文档中要获取内容的位置。
len - 写出量。
方法详细信息

write

public void write()
           throws IOException,
                  BadLocationException
从 StyledDocument 生成 HTML 输出。

指定者:
AbstractWriter 中的 write
抛出:
IOException - 如果发生任何 I/O 错误
BadLocationException - 如果 pos 表示文档中的一个无效位置

writeAttributes

protected void writeAttributes(AttributeSet attr)
                        throws IOException
写出以下类型的所有属性:StyleConstants.ParagraphConstants、StyleConstants.CharacterConstants、StyleConstants.FontConstants、StyleConstants.ColorConstants。属性名称和值用冒号隔开。每个名称值对都用分号隔开。

覆盖:
AbstractWriter 中的 writeAttributes
参数:
attr - AttributeSet。
抛出:
IOException - 如果发生任何 I/O 错误

text

protected void text(Element elem)
             throws IOException,
                    BadLocationException
写出文本。

覆盖:
AbstractWriter 中的 text
参数:
elem - Element。
抛出:
IOException - 如果发生任何 I/O 错误
BadLocationException - 如果 pos 表示文档中的一个无效位置

writeStartTag

protected void writeStartTag(String tag)
                      throws IOException
写出适当缩进的开始标记。还可以增加缩进量。

抛出:
IOException - 如果发生任何 I/O 错误

writeEndTag

protected void writeEndTag(String endTag)
                    throws IOException
写出适当缩进的结束标记。还可以减少缩进量。

抛出:
IOException - 如果发生任何 I/O 错误

writeHeader

protected void writeHeader()
                    throws IOException
写出 <head> 和 <style> 标记,然后调用 writeStyles(),以写出所有命名的样式,这些样式作为 <style> 标记的内容。内容周围带有有效的 HTML 注释标记,以确保文档在不支持标记的应用程序/浏览器中能够被看到。

抛出:
IOException - 如果发生任何 I/O 错误