java.lang.Object
javax.swing.text.AbstractWriter
javax.swing.text.html.MinimalHTMLWriter
MinimalHTMLWriter is a fallback writer used by the
 HTMLEditorKit to write out HTML for a document that
 is a not produced by the EditorKit.
 The format for the document is:
 
 <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>
 - 
Field SummaryFields declared in class javax.swing.text.AbstractWriterNEWLINE
- 
Constructor SummaryConstructorsConstructorDescriptionMinimalHTMLWriter(Writer w, StyledDocument doc) Creates a new MinimalHTMLWriter.MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len) Creates a new MinimalHTMLWriter.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidThis is no longer used, instead <span> will be written out.protected booleanReturns true if we are currently in a <font> tag.protected booleanReturns true if the element is a text element.protected voidstartFontTag(String style) This is no longer used, instead <span> will be written out.protected voidWrites out text.voidwrite()Generates HTML output from a StyledDocument.protected voidwriteAttributes(AttributeSet attr) Writes out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants.protected voidIterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements.protected voidwriteComponent(Element elem) Responsible for handling Component Elements; deliberately unimplemented.protected voidwriteContent(Element elem, boolean needsIndenting) Writes out the attribute set in an HTML-compliant manner.protected voidEmits an end tag for a <p> tag.protected voidwriteEndTag(String endTag) Writes out an end tag appropriately indented.protected voidWrites out the <head> and <style> tags, and then invokes writeStyles() to write out all the named styles as the content of the <style> tag.protected voidwriteHTMLTags(AttributeSet attr) Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.protected voidwriteImage(Element elem) Responsible for handling Icon Elements; deliberately unimplemented.protected voidResponsible for writing out other non-text leaf elements.protected voidWrites out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way.protected voidwriteStartParagraph(Element elem) Emits the start tag for a paragraph.protected voidwriteStartTag(String tag) Writes out a start tag appropriately indented.protected voidWrites out all the named styles as the content of the <style> tag.Methods declared in class javax.swing.text.AbstractWriterdecrIndent, 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
- 
Constructor Details- 
MinimalHTMLWriterCreates a new MinimalHTMLWriter.- Parameters:
- w- Writer
- doc- StyledDocument
 
- 
MinimalHTMLWriterCreates a new MinimalHTMLWriter.- Parameters:
- w- Writer
- doc- StyledDocument
- pos- The location in the document to fetch the content.
- len- The amount to write out.
 
 
- 
- 
Method Details- 
writeGenerates HTML output from a StyledDocument.- Specified by:
- writein class- AbstractWriter
- Throws:
- IOException- on any I/O error
- BadLocationException- if pos represents an invalid location within the document.
 
- 
writeAttributesWrites out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants. The attribute name and value are separated by a colon. Each pair is separated by a semicolon.- Overrides:
- writeAttributesin class- AbstractWriter
- Parameters:
- attr- an AttributeSet.
- Throws:
- IOException- on any I/O error
 
- 
textWrites out text.- Overrides:
- textin class- AbstractWriter
- Parameters:
- elem- an Element.
- Throws:
- IOException- on any I/O error
- BadLocationException- if pos represents an invalid location within the document.
 
- 
writeStartTagWrites out a start tag appropriately indented. Also increments the indent level.- Parameters:
- tag- a start tag
- Throws:
- IOException- on any I/O error
 
- 
writeEndTagWrites out an end tag appropriately indented. Also decrements the indent level.- Parameters:
- endTag- an end tag
- Throws:
- IOException- on any I/O error
 
- 
writeHeaderWrites out the <head> and <style> tags, and then invokes writeStyles() to write out all the named styles as the content of the <style> tag. The content is surrounded by valid HTML comment markers to ensure that the document is viewable in applications/browsers that do not support the tag.- Throws:
- IOException- on any I/O error
 
- 
writeStylesWrites out all the named styles as the content of the <style> tag.- Throws:
- IOException- on any I/O error
 
- 
writeBodyIterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements. This method specially handles leaf elements that are text.- Throws:
- IOException- on any I/O error
- BadLocationException- if we are in an invalid location within the document.
 
- 
writeEndParagraphEmits an end tag for a <p> tag. Before writing out the tag, this method ensures that all other tags that have been opened are appropriately closed off.- Throws:
- IOException- on any I/O error
 
- 
writeStartParagraphEmits the start tag for a paragraph. If the paragraph has a named style associated with it, then this method also generates a class attribute for the <p> tag and sets its value to be the name of the style.- Parameters:
- elem- an element
- Throws:
- IOException- on any I/O error
 
- 
writeLeafResponsible for writing out other non-text leaf elements.- Parameters:
- elem- an element
- Throws:
- IOException- on any I/O error
 
- 
writeImageResponsible for handling Icon Elements; deliberately unimplemented. How to implement this method is an issue of policy. For example, if you're generating an <img> tag, how should you represent the src attribute (the location of the image)? In certain cases it could be a URL, in others it could be read from a stream.- Parameters:
- elem- an element of type StyleConstants.IconElementName
- Throws:
- IOException- if I/O error occurred.
 
- 
writeComponentResponsible for handling Component Elements; deliberately unimplemented. How this method is implemented is a matter of policy.- Parameters:
- elem- an element of type StyleConstants.ComponentElementName
- Throws:
- IOException- if I/O error occurred.
 
- 
isTextReturns true if the element is a text element.- Parameters:
- elem- an element
- Returns:
- trueif the element is a text element.
 
- 
writeContentprotected void writeContent(Element elem, boolean needsIndenting) throws IOException, BadLocationException Writes out the attribute set in an HTML-compliant manner.- Parameters:
- elem- an element
- needsIndenting- indentation will be added if- needsIndentingis- true
- Throws:
- IOException- on any I/O error
- BadLocationException- if pos represents an invalid location within the document.
 
- 
writeHTMLTagsGenerates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.- Parameters:
- attr- a set of attributes
- Throws:
- IOException- on any I/O error
 
- 
writeNonHTMLAttributesWrites out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way. Given that attributes such as font family and font size have no direct mapping to HTML tags, a <span> tag is generated and its style attribute is set to contain the list of remaining attributes just like inline styles.- Parameters:
- attr- a set of attributes
- Throws:
- IOException- on any I/O error
 
- 
inFontTagprotected boolean inFontTag()Returns true if we are currently in a <font> tag.- Returns:
- trueif we are currently in a <font> tag.
 
- 
endFontTagThis is no longer used, instead <span> will be written out.Writes out an end tag for the <font> tag. - Throws:
- IOException- on any I/O error
 
- 
startFontTagThis is no longer used, instead <span> will be written out.Writes out a start tag for the <font> tag. Because font tags cannot be nested, this method closes out any enclosing font tag before writing out a new start tag. - Parameters:
- style- a font style
- Throws:
- IOException- on any I/O error
 
 
-