2023-08-18 15:55:31 +08:00
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
|
|
|
public class CKIndentHelper {
|
|
|
|
public CKIndentHelper(OutputStreamWriter writer) {
|
|
|
|
mIndent = 0;
|
2023-08-19 00:03:00 +08:00
|
|
|
mWriter = writer;
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private int mIndent;
|
|
|
|
private OutputStreamWriter mWriter;
|
|
|
|
|
|
|
|
public void inc() {
|
|
|
|
++mIndent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void dec() {
|
|
|
|
--mIndent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void indent() throws Exception {
|
|
|
|
mWriter.write("\n");
|
|
|
|
for (int i = 0; i < mIndent; ++i) {
|
|
|
|
mWriter.write("\t");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void puts(String data) throws Exception {
|
|
|
|
indent();
|
|
|
|
mWriter.write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void printf(String fmt, Object... args) throws Exception {
|
|
|
|
indent();
|
|
|
|
mWriter.write(String.format(fmt, args));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void briefComment(String fmt) throws Exception {
|
|
|
|
if (fmt == null) return;
|
2023-08-19 00:03:00 +08:00
|
|
|
puts("/**");
|
|
|
|
puts(fmt);
|
|
|
|
puts(" */");
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void afterMemberComment(String fmt) throws Exception {
|
|
|
|
if (fmt == null) return;
|
2023-08-19 00:03:00 +08:00
|
|
|
mWriter.write(String.format("\t/**< %s */", CKCommonHelper.removeEol(fmt)));
|
2023-08-18 15:55:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|