public class CodeWriter extends PrintWriter
out| Constructor and Description |
|---|
CodeWriter(Writer out) |
| Modifier and Type | Method and Description |
|---|---|
CodeWriter |
append(char c) |
CodeWriter |
append(CharSequence csq) |
CodeWriter |
append(CharSequence csq,
int start,
int end) |
CodeWriter |
code(String string)
Print the specified
string with an indent prefix. |
CodeWriter |
codeln(String line)
Print the specified
line with an indent prefix and end with a new line char. |
CodeWriter |
format(Locale l,
String format,
Object... args) |
CodeWriter |
format(String format,
Object... args) |
CodeWriter |
indent()
Increment the current indentation.
|
String |
indentation() |
CodeWriter |
indented(Runnable block) |
int |
indentSize() |
CodeWriter |
indentSize(int size)
Set the current indentation size, this can only be done when the current indentation is
0. |
CodeWriter |
javaImport(String name)
Append the
name as a java package import. |
CodeWriter |
newLine()
Print a new line char.
|
void |
println() |
CodeWriter |
stmt(String statement)
This function prints an indentation before the
statement and a semicolon followed by a newline
after. |
CodeWriter |
unindent()
Decrement the current indentation.
|
void |
write(int c) |
void |
write(String s,
int off,
int len) |
Writer |
writer() |
CodeWriter |
writeSeq(Stream<String> sequence,
String delimiter)
Write a
sequence delimited by a delimiter. |
public CodeWriter(Writer out)
public Writer writer()
public int indentSize()
public CodeWriter indentSize(int size)
0.size - the new sizepublic String indentation()
public CodeWriter indent()
public CodeWriter unindent()
public CodeWriter indented(Runnable block)
public CodeWriter javaImport(String name)
name as a java package import.public CodeWriter code(String string)
string with an indent prefix.
This method forces the writer to be the first linestring - the string to printpublic CodeWriter codeln(String line)
line with an indent prefix and end with a new line char.line - the line to printpublic CodeWriter stmt(String statement)
statement and a semicolon followed by a newline
after.statement - the statementpublic CodeWriter newLine()
public CodeWriter writeSeq(Stream<String> sequence, String delimiter)
sequence delimited by a delimiter.public void println()
println in class PrintWriterpublic void write(String s, int off, int len)
write in class PrintWriterpublic void write(int c)
write in class PrintWriterpublic CodeWriter append(CharSequence csq)
append in interface Appendableappend in class PrintWriterpublic CodeWriter append(CharSequence csq, int start, int end)
append in interface Appendableappend in class PrintWriterpublic CodeWriter append(char c)
append in interface Appendableappend in class PrintWriterpublic CodeWriter format(String format, Object... args)
format in class PrintWriterpublic CodeWriter format(Locale l, String format, Object... args)
format in class PrintWriterCopyright © 2020. All rights reserved.