public class HtmlCode extends Object
This is open source software released under the Apache 2.0 License
| Modifier and Type | Field and Description |
|---|---|
private StringBuilder |
html |
private String |
indent |
| Constructor and Description |
|---|
HtmlCode()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
File |
browse()
Writes the HTML code in this buffer to a temp file and opens it in default browser
|
File |
browse(File file)
Writes the HTML code in this buffer to the output file and opens it in default browser
|
static String |
createHtml(Consumer<HtmlCode> consumer)
Convenience method to generate an HTML string given a writer
|
void |
flush(File file)
Flushes the contents of the buffer to a file
|
HtmlCode |
indent(int count)
Increases the indentation for the current line by a certain number of spaces
|
static void |
main(String[] args)
Quick test to check output
|
HtmlCode |
newElement(String name,
Consumer<HtmlElement> consumer)
Creates a new element with the name specified
|
HtmlCode |
newLine()
Starts a new line and indents the new line based on current indentation
|
String |
toString() |
HtmlCode |
unident(int count)
Removes spaces from the current indentation
|
HtmlCode |
write(String line,
Object... args)
Writes formatted code string to the output buffer
|
private String indent
private StringBuilder html
public static String createHtml(Consumer<HtmlCode> consumer)
consumer - the consumer to call on the writerpublic HtmlCode indent(int count)
count - the number of spaces to indent bypublic HtmlCode unident(int count)
count - the number of spaces to removepublic HtmlCode newLine()
public HtmlCode write(String line, Object... args)
line - the formatted code String (see String.format() for details)args - the arguments for the formatted code stringpublic HtmlCode newElement(String name, Consumer<HtmlElement> consumer)
name - the HTML element nameconsumer - the consumer used to configure the elementpublic void flush(File file) throws IOException
file - the file to flush the HTML buffer toIOException - if there is an IO Exceptionpublic File browse() throws IOException
IOException - if there is an IO Exceptionpublic File browse(File file) throws IOException
file - the file to write HTML buffer toIOException - if there is an IO Exceptionpublic static void main(String[] args)
args - Copyright 2014-2017, Xavier Witdouck