|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.quiotix.html.parser.HtmlVisitor com.quiotix.html.parser.HtmlFormatter
public class HtmlFormatter
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.
HtmlVisitor
,
HtmlCollector
,
HtmlScrubber
Field Summary | |
---|---|
protected com.quiotix.html.parser.TagBlockRenderer |
blockRenderer
|
protected int |
indentSize
|
protected boolean |
inPreBlock
|
protected com.quiotix.html.parser.MarginWriter |
out
|
protected HtmlDocument.HtmlElement |
previousElement
|
protected int |
rightMargin
|
protected static Set |
tagsIndentBlock
|
protected static String[] |
tagsIndentStrings
|
protected static Set |
tagsNewlineBefore
|
protected static String[] |
tagsNewlineBeforeStrings
|
protected static Set |
tagsPreformatted
|
protected static String[] |
tagsPreformattedStrings
|
protected static Set |
tagsTryMatch
|
protected static String[] |
tagsTryMatchStrings
|
Constructor Summary | |
---|---|
HtmlFormatter(OutputStream os)
Constructor. |
Method Summary | |
---|---|
void |
finish()
Finish. |
static void |
main(String[] args)
Runnable. |
void |
setIndent(int indent)
|
void |
setRightMargin(int margin)
|
void |
start()
Start. |
void |
visit(HtmlDocument.Comment c)
Visit a Comment. |
void |
visit(HtmlDocument.EndTag t)
Visit an EndTag. |
void |
visit(HtmlDocument.Newline n)
Visit a Newline. |
void |
visit(HtmlDocument.Tag t)
Visit a Tag. |
void |
visit(HtmlDocument.TagBlock block)
Visit a TagBlock. |
void |
visit(HtmlDocument.Text t)
Visit Text. |
Methods inherited from class com.quiotix.html.parser.HtmlVisitor |
---|
visit, visit, visit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected com.quiotix.html.parser.MarginWriter out
protected int rightMargin
protected int indentSize
protected static Set tagsIndentBlock
protected static Set tagsNewlineBefore
protected static Set tagsPreformatted
protected static Set tagsTryMatch
protected static final String[] tagsIndentStrings
protected static final String[] tagsNewlineBeforeStrings
protected static final String[] tagsPreformattedStrings
protected static final String[] tagsTryMatchStrings
protected com.quiotix.html.parser.TagBlockRenderer blockRenderer
protected HtmlDocument.HtmlElement previousElement
protected boolean inPreBlock
Constructor Detail |
---|
public HtmlFormatter(OutputStream os) throws Exception
Exception
Method Detail |
---|
public void setRightMargin(int margin)
margin
- the right margin column to wrap atpublic void setIndent(int indent)
indent
- the number of spaces to indent bypublic void visit(HtmlDocument.TagBlock block)
HtmlVisitor
visit
in class HtmlVisitor
public void visit(HtmlDocument.Tag t)
HtmlVisitor
visit
in class HtmlVisitor
public void visit(HtmlDocument.EndTag t)
HtmlVisitor
visit
in class HtmlVisitor
public void visit(HtmlDocument.Comment c)
HtmlVisitor
visit
in class HtmlVisitor
public void visit(HtmlDocument.Text t)
HtmlVisitor
visit
in class HtmlVisitor
public void visit(HtmlDocument.Newline n)
HtmlVisitor
visit
in class HtmlVisitor
public void start()
HtmlVisitor
start
in class HtmlVisitor
public void finish()
HtmlVisitor
finish
in class HtmlVisitor
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |