com.quiotix.html.parser
Class HtmlFormatter
java.lang.Object
|
+--com.quiotix.html.parser.HtmlVisitor
|
+--com.quiotix.html.parser.HtmlFormatter
- public class HtmlFormatter
- extends HtmlVisitor
HtmlFormatter is a Visitor which traverses an HtmlDocument, dumping the
contents of the document to a specified output stream. It assumes that
the documents has been preprocessed by HtmlCollector (which matches up
beginning and end tags) and by HtmlScrubber (which formats tags in a
consistent way). In particular, HtmlScrubber should be invoked with the
TRIM_SPACES option to remove trailing spaces, which can confuse the
formatting algorithm.
The right margin and indent increment can be specified as properties.
- Author:
- Brian Goetz, Quiotix
- See Also:
com.quiotix.html.HtmlVisitor
,
com.quiotix.html.HtmlCollector
,
com.quiotix.html.HtmlScrubber
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
out
protected com.quiotix.html.parser.MarginWriter out
rightMargin
protected int rightMargin
indentSize
protected int indentSize
tagsIndentBlock
protected static java.util.Hashtable tagsIndentBlock
tagsNewlineBefore
protected static java.util.Hashtable tagsNewlineBefore
tagsPreformatted
protected static java.util.Hashtable tagsPreformatted
tagsTryMatch
protected static java.util.Hashtable tagsTryMatch
tagsIndentStrings
protected static final java.lang.String[] tagsIndentStrings
tagsNewlineBeforeStrings
protected static final java.lang.String[] tagsNewlineBeforeStrings
tagsPreformattedStrings
protected static final java.lang.String[] tagsPreformattedStrings
tagsTryMatchStrings
protected static final java.lang.String[] tagsTryMatchStrings
blockRenderer
protected com.quiotix.html.parser.TagBlockRenderer blockRenderer
previousElement
protected HtmlDocument.HtmlElement previousElement
inPreBlock
protected boolean inPreBlock
HtmlFormatter
public HtmlFormatter(java.io.OutputStream os)
throws java.lang.Exception
setRightMargin
public void setRightMargin(int margin)
setIndent
public void setIndent(int indent)
visit
public void visit(HtmlDocument.TagBlock block)
- Overrides:
visit
in class HtmlVisitor
visit
public void visit(HtmlDocument.Tag t)
- Overrides:
visit
in class HtmlVisitor
visit
public void visit(HtmlDocument.EndTag t)
- Overrides:
visit
in class HtmlVisitor
visit
public void visit(HtmlDocument.Comment c)
- Overrides:
visit
in class HtmlVisitor
visit
public void visit(HtmlDocument.Text t)
- Overrides:
visit
in class HtmlVisitor
visit
public void visit(HtmlDocument.Newline n)
- Overrides:
visit
in class HtmlVisitor
start
public void start()
- Overrides:
start
in class HtmlVisitor
finish
public void finish()
- Overrides:
finish
in class HtmlVisitor
main
public static void main(java.lang.String[] args)
throws java.lang.Exception