|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lightdev.app.shtm.SHTMLWriter
public class SHTMLWriter
A writer for documents of application SimplyHTML.
SHTMLWriter
implements an own approach to
clean writing of HTML produced by application SimplyHTML.
To keep it simple, SHTMLWriter
only writes HTML and CSS content application SimplyHTML
'understands'. Documents not produced by SimplyHTML might or
might not work with this writer.
With stage 9 the mode property has been added as a workaround for bug id 4765271 (see http://developer.java.sun.com/developer/bugParade/bugs/4765271.html). By passing MODE_HTML, font-size attribute contents are written as is, with MODE_JAVA, values of attribute font-size are adjusted to (wrong) sizes expected in Java.
With release 2 of stage 9 this writer is used only when the user selects not to write HTML 3.2. The standard HTMLWriter with a fix for writing font sizes inside content is used when HTML 3.2 is to be written.
Nested Class Summary | |
---|---|
class |
SHTMLWriter.PropertiesMissingException
inner class for signaling that properties were missing for proper execution. |
Field Summary | |
---|---|
static char |
cssAttributeSeparator
|
static char |
cssAttributeTerminator
|
static char |
htmlAttributeSeparator
|
static char |
htmlAttributeStartEnd
|
static char |
htmlAttributeTerminator
|
static char |
htmlEndTagIndicator
|
static char |
htmlTagEnd
|
static char |
htmlTagStart
|
static int |
MODE_HTML
indicator for writing 'normal' HTML |
static int |
MODE_JAVA
indicator for writing 'adjusted Java HTML' |
Constructor Summary | |
---|---|
SHTMLWriter(java.io.Writer w)
construct an uninitialized SHTMLWriter |
|
SHTMLWriter(java.io.Writer w,
javax.swing.text.html.HTMLDocument doc)
construct a new SHTMLWriter to generate HTML for a given document |
|
SHTMLWriter(java.io.Writer w,
javax.swing.text.html.HTMLDocument doc,
int mode)
construct a new SHTMLWriter to generate HTML for a given document |
|
SHTMLWriter(java.io.Writer w,
javax.swing.text.html.HTMLDocument doc,
int pos,
int len)
construct a new SHTMLWriter to generate HTML for a given part of a document |
|
SHTMLWriter(java.io.Writer w,
javax.swing.text.html.HTMLDocument doc,
int pos,
int len,
int mode)
construct a new SHTMLWriter to generate HTML for a given part of a document |
Method Summary | |
---|---|
void |
endTag(java.lang.String name)
write out an end tag for a given tag name |
void |
setDocument(SHTMLDocument doc)
set the document to write from |
void |
setWriteSegment(int pos,
int len)
specify the text segment of the document to be written |
void |
startTag(java.lang.String name,
javax.swing.text.AttributeSet a)
write out a start tag for a given tag name including tag attributes (if any) |
void |
write()
invoke HTML creation for the document or part of document given in the constructor of this SHTMLWriter |
void |
write(javax.swing.text.Element e)
invoke HTML creation for a given element and all its children |
void |
write(javax.swing.text.Element start,
javax.swing.text.Element end)
write elements and their children starting at a given element until a given element is reached. |
void |
writeChildElements(javax.swing.text.Element elem)
invoke HTML creation for all children of a given element. |
void |
writeElementsUntil(javax.swing.text.Element e,
javax.swing.text.Element end)
write an element and all its children. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MODE_HTML
This is built in as a workaround for bug id 4765271 (see http://developer.java.sun.com/developer/bugParade/bugs/4765271.html)
public static final int MODE_JAVA
This is built in as a workaround for bug id 4765271 (see http://developer.java.sun.com/developer/bugParade/bugs/4765271.html)
public static final char htmlTagStart
public static final char htmlTagEnd
public static final char htmlEndTagIndicator
public static final char htmlAttributeSeparator
public static final char htmlAttributeTerminator
public static final char htmlAttributeStartEnd
public static final char cssAttributeTerminator
public static final char cssAttributeSeparator
Constructor Detail |
---|
public SHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc, int pos, int len, int mode)
w
- the writer for HTML outputdoc
- the document to generate HTML frompos
- the start position of the part of the document
to generate HTML forlen
- the length of the part of the document to
generate HTML formode
- the writing mode, one of MODE_HTML and MODE_JAVApublic SHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc, int pos, int len)
w
- the writer for HTML outputdoc
- the document to generate HTML frompos
- the start position of the part of the document
to generate HTML forlen
- the length of the part of the document to
generate HTML forpublic SHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc, int mode)
w
- the writer for HTML outputdoc
- the document to generate HTML frommode
- the writing mode, one of MODE_HTML and MODE_JAVApublic SHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc)
w
- the writer for HTML outputdoc
- the document to generate HTML frompublic SHTMLWriter(java.io.Writer w)
This can be used for snythesizing HTML instead of reading it from the element structure of a document.
If a SHTMLWriter was constructed with this constructor which shall be used for writing a document, the document and writeSegment properties of the SHTMLWriter need to be set before calling its write() methods.
w
- the writer to write toMethod Detail |
---|
public void setDocument(SHTMLDocument doc)
doc
- the document to write frompublic void setWriteSegment(int pos, int len)
pos
- the start position of the text segmentlen
- the length of the text segmentpublic void write() throws java.io.IOException, javax.swing.text.BadLocationException, SHTMLWriter.PropertiesMissingException
java.io.IOException
- on any i/o error
javax.swing.text.BadLocationException
- if text retrieval via doc.getText is
passed an invalid location within the document
SHTMLWriter.PropertiesMissingException
- if the document is not set prior
to calling this methodpublic void write(javax.swing.text.Element e) throws java.io.IOException, javax.swing.text.BadLocationException
This iterates through the element structure below the given element by calling itself recursively for each branch element found.
e
- the element to generate HTML for
java.io.IOException
- on any i/o error
javax.swing.text.BadLocationException
- if text retrieval via doc.getText is
passed an invalid location within the documentpublic void writeElementsUntil(javax.swing.text.Element e, javax.swing.text.Element end) throws java.io.IOException, javax.swing.text.BadLocationException
e
- the element to write including its children (if any)end
- the last leaf element to write or the branch element
to stop writing at (whatever applies)
java.io.IOException
javax.swing.text.BadLocationException
public void write(javax.swing.text.Element start, javax.swing.text.Element end) throws java.io.IOException, javax.swing.text.BadLocationException
start
- the element to start writing withend
- the last element to write
java.io.IOException
javax.swing.text.BadLocationException
public void writeChildElements(javax.swing.text.Element elem) throws java.io.IOException, javax.swing.text.BadLocationException, SHTMLWriter.PropertiesMissingException
elem
- the element which children are to be written as HTML
java.io.IOException
javax.swing.text.BadLocationException
SHTMLWriter.PropertiesMissingException
public void startTag(java.lang.String name, javax.swing.text.AttributeSet a) throws java.io.IOException
name
- the name of the tag to generatea
- the set of attributes to generate in tag or null if none
java.io.IOException
- on any i/o errorpublic void endTag(java.lang.String name) throws java.io.IOException
name
- the name of the tag to generate an end tag for
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |