|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
java.io.PrintWriter
org.dellroad.jc.cgen.CodeWriter
Extension of PrintWriter that contains methods
useful for generating and formatting C source files. Basically you
can set an indentation level (see indent()) that
persists for subsequent lines until you unset it
(see undent()).
| Field Summary | |
protected int |
indent
|
protected int |
indentLevel
|
protected boolean |
needIndent
|
protected Writer |
w
|
| Fields inherited from class java.io.PrintWriter |
out |
| Fields inherited from class java.io.Writer |
lock |
| Constructor Summary | |
CodeWriter(Writer w)
Constructor. |
|
CodeWriter(Writer w,
int indent)
Constructor. |
|
| Method Summary | |
protected void |
doIndent()
Output enough tabs and spaces to achieve current indentation. |
int |
getIndent()
Get the current indentation level. |
void |
indent()
Increase the current indentation level by one. |
void |
println()
|
void |
setIndent(int level)
Set indentation level to an absolute number of indents. |
void |
undent()
Decrease the current indentation level by one. |
void |
write(char[] buf)
|
void |
write(char[] buf,
int off,
int len)
|
void |
write(int ch)
|
void |
write(String s)
|
void |
write(String s,
int off,
int len)
|
| Methods inherited from class java.io.PrintWriter |
checkError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, setError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected final Writer w
protected final int indent
protected int indentLevel
protected boolean needIndent
| Constructor Detail |
public CodeWriter(Writer w)
w - underlying output
public CodeWriter(Writer w,
int indent)
w - underlying outputindent - number of spaces for each indentation level| Method Detail |
public void setIndent(int level)
level - Non-negative indentation levelpublic int getIndent()
public void indent()
public void undent()
public void println()
protected void doIndent()
public void write(int ch)
public void write(char[] buf)
public void write(char[] buf,
int off,
int len)
public void write(String s)
public void write(String s,
int off,
int len)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||