|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ppg.util.CodeWriter
public class CodeWriter
A CodeWriter
is a pretty-printing engine.
It formats structured text onto an output stream o
in the
minimum number of lines, while keeping the width of the output
within width
characters if possible.
Constructor Summary | |
---|---|
CodeWriter(java.io.OutputStream o,
int width_)
Create a CodeWriter object with output stream o
and width width_ . |
|
CodeWriter(java.io.Writer w,
int width_)
Create a CodeWriter object with output w and
width width_ . |
Method Summary | |
---|---|
void |
allowBreak(int n)
Allow a newline. |
void |
allowBreak(int n,
java.lang.String alt)
Allow a newline. |
void |
begin(int n)
Start a new block with a relative indentation of n
characters. |
void |
end()
Terminate the most recent outstanding begin . |
boolean |
flush()
Send out the current batch of text to be formatted. |
void |
newline()
Force a newline with no added indentation. |
void |
newline(int n)
Force a newline. |
void |
write(java.lang.String s)
Print the string s verbatim on the output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CodeWriter(java.io.OutputStream o, int width_)
o
and width width_
.
public CodeWriter(java.io.Writer w, int width_)
w
and
width width_
.
Method Detail |
---|
public void write(java.lang.String s)
s
verbatim on the output stream.
public void newline()
public void begin(int n)
n
characters.
newline
item in the block.allowBreak
will cause a line change, the first line
is printed at the current cursor position pos
,
all the following lines are printed at the position
pos+n
.
n
- the number of characters increased on indentation (relative
to the current position) for all lines in the block.public void end()
begin
.
public void allowBreak(int n)
n
- the amount of increase in indentation if
the newline is inserted.public void allowBreak(int n, java.lang.String alt)
n
- the amount of increase in indentation if
the newline is inserted.alt
- if no newline is inserted, the string alt
is
output instead.public void newline(int n)
allowBreak
is
preferable because forcing a newline also causes all breaks
in containing blocks to be broken.
n
- the amount of increase in indentation after the newline.public boolean flush() throws java.io.IOException
begin
's are closed and the current
indentation level is reset to 0. Returns true if formatting
was completely successful (the margins were obeyed).
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |