public class HtmlStringWriter extends AbstractHtmlWriter
toString()
.
HtmlStringWriter htmlWriter = new HtmlStringWriter();
htmlWriter.writeEnclose("h1", "Heading text", "id='idh1'");
Other methods allow you to write a start tag, then write whatever content and then write an end tag.
All in all these methods are really low-level. In the example above you will have to quote the value of an attribute
yourself.
On the plus side, the low-level methods give you great flexibility regarding the generation of HTML code.
Instead of using the low-level methods provided by this class, you may instead want to investigate HtmlElement
,
which provides a way to construct HTML from objects which in turn can be converted to HTML output.Constructor and Description |
---|
HtmlStringWriter() |
Modifier and Type | Method and Description |
---|---|
String |
toString()
Gets the HTML code.
|
HtmlStringWriter |
write(Object text)
Writes the supplied text to the buffer.
|
writeAttributes, writeDocType, writeEnclose, writeEndTag, writeln, writeln, writeStartEndTag, writeStartTag
public HtmlStringWriter write(Object text)
write
in class AbstractHtmlWriter
text
- The text to write.
Copyright © 2008–2018. All rights reserved.