public class DocumentWriter extends DocumentRecurser<Void>
DocumentWriter w=new DocumentWriter(writer); w.document(d);A DocumentWriter can be used only once.
| Constructor and Description |
|---|
DocumentWriter(Writer writer) |
| Modifier and Type | Method and Description |
|---|---|
protected DocumentWriter |
attribute(String key,
String value)
Writes " key=\"value\".
|
protected DocumentWriter |
cdata(String s)
Escapes a string for inclusion in cdata and writes it as CDATA section.
|
protected DocumentWriter |
close(Element e)
Writes an element's closing tag.
|
protected DocumentWriter |
comment(String s)
Escape a string for inclusion in a comment and writes it.
|
protected DocumentWriter |
doctype(DocumentType type)
Always writes the HTML5 doctype "<!DOCTYPE html>".
|
protected DocumentWriter |
element(Element e)
Processes an element.
|
protected boolean |
needClosingTag(String tag)
In html5 for common browsers,
does this tag need a separate closing tag,
even if the element is empty?
This methods return true for a, script, title, textarea.
|
protected DocumentWriter |
open(Element e)
Writes opening tag and the attributes.
|
protected String |
quote(String value)
Quotes a value so that it can be an attribute's value.
|
protected void |
script(Element element)
Writes a script element.
|
protected DocumentWriter |
text(String s)
Escapes & and gt; in a text and writes it.
|
String |
toString() |
protected DocumentWriter |
write(char c)
Writes a character directly to the writer, no escaping.
|
DocumentWriter |
write(String s)
Writes a string directly to the writer, no escaping.
|
protected DocumentWriter |
writeEscapeElement(String s)
Escapes a String for inserting in HTML elements.
|
protected DocumentWriter |
writeln()
Writes a new-line to the writer.
|
DocumentWriter |
writeln(char c)
Writes a string and new-line to the writer, no escaping.
|
DocumentWriter |
writeln(String s)
Writes a string and new-line to the writer, no escaping.
|
attribute, attributes, cdata, close, comment, document, documentURI, entity, entityReference, fragment, node, nodes, notation, open, processingInstruction, textpublic DocumentWriter(Writer writer)
writer - Writes to this writer.protected DocumentWriter write(char c) throws IOException
c - the charIOException - something wrongpublic DocumentWriter write(String s) throws IOException
s - the stringIOException - something wrongpublic DocumentWriter writeln(String s) throws IOException
s - the stringIOException - something wrongpublic DocumentWriter writeln(char c) throws IOException
c - the charIOException - something wrongprotected DocumentWriter writeln() throws IOException
IOException - something wrongprotected DocumentWriter doctype(DocumentType type) throws IOException
doctype in class DocumentRecurser<Void>type - Ignored.IOException - something wrongprotected DocumentWriter element(Element e) throws Exception
element in class DocumentRecurser<Void>e - the elementException - something wrongprotected void script(Element element) throws Exception
element - Must be script and must have no children
other than text.Exception - something wrongprotected DocumentWriter open(Element e) throws Exception
open in class DocumentRecurser<Void>e - the elementException - something wrongprotected DocumentWriter attribute(String key, String value) throws Exception
attribute in class DocumentRecurser<Void>key - the keyvalue - the valueException - something wrongprotected DocumentWriter text(String s) throws Exception
text in class DocumentRecurser<Void>s - the textException - something wrongprotected DocumentWriter close(Element e) throws IOException
close in class DocumentRecurser<Void>e - the elementIOException - something wrongprotected DocumentWriter cdata(String s) throws Exception
cdata in class DocumentRecurser<Void>s - the CData stringIOException - something wrongException - something wrongprotected DocumentWriter comment(String s) throws Exception
comment in class DocumentRecurser<Void>s - the comment as stringException - something wrongprotected DocumentWriter writeEscapeElement(String s) throws IOException
| i | c | escapeElement(c) | length(escapeElement(c)) |
|---|---|---|---|
| 38 | & | & | 5 |
| 60 | < | < | 4 |
s - The string to escape.IOException - something wrongprotected boolean needClosingTag(String tag)
tag - the tagprotected String quote(String value)
value - string to quoteCopyright © 2017. All rights reserved.