<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>
| Modifier and Type | Field and Description |
|---|---|
| private static final int | BOLD
These static finals are used to tweak and query the fontMask about which of these tags need to be generated or terminated. |
| private static final CSS | |
| pack-priv int | |
| private AttributeSet | fontAttributes
Stores the attributes of the previous run. |
| private int | |
| private static final int | |
| pack-priv int | |
| private Hashtable | styleNameMapping
Maps from style name as held by the Document, to the archived style name (style name written out). |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MinimalHTMLWriter(Writer
Writer w, StyledDocument StyledDocument doc, int The location in the document to fetch the
content. pos, int The amount to write out. len)Creates a new MinimalHTMLWriter. |
| Modifier and Type | Method and Description |
|---|---|
| private String | |
| protected void | |
| private void | |
| protected boolean | Returns: true if we are currently in a <font> tag.Returns true if we are currently in a <font> tag. |
| protected boolean | |
| private boolean | |
| private String | |
| private void | setFontMask(AttributeSet attr)
Tweaks the appropriate bits of fontMask to reflect whether the text is to be displayed in bold, italic, and/or with an underline. |
| protected void | |
| private void | |
| protected void | |
| public void | write()
Implements abstract javax. Generates HTML output from a StyledDocument. |
| protected void | writeAttributes(AttributeSet attr)
Overrides javax. Writes out all the attributes for the following types: StyleConstants.ParagraphConstants, StyleConstants.CharacterConstants, StyleConstants.FontConstants, StyleConstants.ColorConstants. |
| protected void | writeBody()
Iterates over the elements in the document and processes elements based on whether they are branch elements or leaf elements. |
| protected void | writeComponent(Element
an element of type StyleConstants.ComponentElementName elem)Responsible for handling Component Elements; deliberately unimplemented. |
| protected void | writeContent(Element
an element elem, boolean indentation will be added if needsIndenting)needsIndenting is trueWrites out the attribute set in an HTML-compliant manner. |
| private void | |
| protected void | |
| protected void | |
| protected void | writeHeader()
Writes 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 void | writeHTMLTags(AttributeSet
a set of attributes attr)Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings. |
| protected void | writeImage(Element
an element of type StyleConstants.IconElementName elem)Responsible for handling Icon Elements; deliberately unimplemented. |
| protected void | |
| protected void | writeNonHTMLAttributes(AttributeSet
a set of attributes attr)Writes out the remaining character-level attributes (attributes other than bold, italic, and underline) in an HTML-compliant way. |
| private void | |
| protected void | |
| protected void | |
| protected void |
| BOLD | back to summary |
|---|---|
| private static final int BOLD These static finals are used to tweak and query the fontMask about which of these tags need to be generated or terminated. | |
| css | back to summary |
|---|---|
| private static final CSS css | |
| endOffset | back to summary |
|---|---|
| pack-priv int endOffset | |
| fontAttributes | back to summary |
|---|---|
| private AttributeSet fontAttributes Stores the attributes of the previous run. Used to compare with the current run's attributeset. If identical, then a <span> tag is not emitted. | |
| fontMask | back to summary |
|---|---|
| private int fontMask | |
| ITALIC | back to summary |
|---|---|
| private static final int ITALIC | |
| startOffset | back to summary |
|---|---|
| pack-priv int startOffset | |
| styleNameMapping | back to summary |
|---|---|
| private Hashtable<String, String> styleNameMapping Maps from style name as held by the Document, to the archived style name (style name written out). These may differ. | |
| UNDERLINE | back to summary |
|---|---|
| private static final int UNDERLINE | |
| MinimalHTMLWriter | back to summary |
|---|---|
| public MinimalHTMLWriter(Writer w, StyledDocument doc) Creates a new MinimalHTMLWriter.
| |
| MinimalHTMLWriter | back to summary |
|---|---|
| public MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len) Creates a new MinimalHTMLWriter.
| |
| addStyleName | back to summary |
|---|---|
| private String addStyleName(String style) Adds the style named | |
| endFontTag | back to summary |
|---|---|
| protected void endFontTag() throws IOException This is no longer used, instead <span> will be written out. Writes out an end tag for the <font> tag.
| |
| endSpanTag | back to summary |
|---|---|
| private void endSpanTag() throws IOException Writes out an end tag for the <span> tag.
| |
| inFontTag | back to summary |
|---|---|
| protected boolean inFontTag() Returns true if we are currently in a <font> tag.
| |
| isText | back to summary |
|---|---|
| protected boolean isText(Element elem) Returns true if the element is a text element.
| |
| isValidCharacter | back to summary |
|---|---|
| private boolean isValidCharacter(char character) | |
| mapStyleName | back to summary |
|---|---|
| private String mapStyleName(String style) Returns the mapped style name corresponding to | |
| setFontMask | back to summary |
|---|---|
| private void setFontMask(AttributeSet attr) Tweaks the appropriate bits of fontMask to reflect whether the text is to be displayed in bold, italic, and/or with an underline. | |
| startFontTag | back to summary |
|---|---|
| protected void startFontTag(String style) throws IOException This 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.
| |
| startSpanTag | back to summary |
|---|---|
| private void startSpanTag(String style) throws IOException 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.
| |
| text | back to summary |
|---|---|
| protected void text(Element elem) throws IOException, BadLocationException Overrides javax. Writes out text.
| |
| write | back to summary |
|---|---|
| public void write() throws IOException, BadLocationException Implements abstract javax. Generates HTML output from a StyledDocument.
| |
| writeAttributes | back to summary |
|---|---|
| protected void writeAttributes(AttributeSet attr) throws IOException Overrides javax. Writes 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.
| |
| writeBody | back to summary |
|---|---|
| protected void writeBody() throws IOException, BadLocationException Iterates 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.
| |
| writeComponent | back to summary |
|---|---|
| protected void writeComponent(Element elem) throws IOException Responsible for handling Component Elements; deliberately unimplemented. How this method is implemented is a matter of policy.
| |
| writeContent | back to summary |
|---|---|
| protected void writeContent(Element elem, boolean needsIndenting) throws IOException, BadLocationException Writes out the attribute set in an HTML-compliant manner.
| |
| writeEndMask | back to summary |
|---|---|
| private void writeEndMask(int mask) throws IOException Writes out end tags for <u>, <i>, and <b> based on the mask settings.
| |
| writeEndParagraph | back to summary |
|---|---|
| protected void writeEndParagraph() throws IOException Emits 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.
| |
| writeEndTag | back to summary |
|---|---|
| protected void writeEndTag(String endTag) throws IOException Writes out an end tag appropriately indented. Also decrements the indent level.
| |
| writeHeader | back to summary |
|---|---|
| protected void writeHeader() throws IOException Writes 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.
| |
| writeHTMLTags | back to summary |
|---|---|
| protected void writeHTMLTags(AttributeSet attr) throws IOException Generates bold <b>, italic <i>, and <u> tags for the text based on its attribute settings.
| |
| writeImage | back to summary |
|---|---|
| protected void writeImage(Element elem) throws IOException Responsible 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.
| |
| writeLeaf | back to summary |
|---|---|
| protected void writeLeaf(Element elem) throws IOException Responsible for writing out other non-text leaf elements.
| |
| writeNonHTMLAttributes | back to summary |
|---|---|
| protected void writeNonHTMLAttributes(AttributeSet attr) throws IOException Writes 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.
| |
| writeStartMask | back to summary |
|---|---|
| private void writeStartMask(int mask) throws IOException Writes out start tags <u>, <i>, and <b> based on the mask settings.
| |
| writeStartParagraph | back to summary |
|---|---|
| protected void writeStartParagraph(Element elem) throws IOException Emits 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.
| |
| writeStartTag | back to summary |
|---|---|
| protected void writeStartTag(String tag) throws IOException Writes out a start tag appropriately indented. Also increments the indent level.
| |
| writeStyles | back to summary |
|---|---|
| protected void writeStyles() throws IOException Writes out all the named styles as the content of the <style> tag.
| |