| Modifier and Type | Field and Description |
|---|---|
private Backend |
back
Back-end for the pretty-printed output
|
private static int |
BREAK_MASK
Mask for break type flags.
|
private static int |
CONSISTENT
Flag to indicate this block will be broken consistently
|
private static int |
FITS
Flag to indicate this block fits into the current line
|
private static int |
INCONSISTENT
Flag to indicate this block will be broken inconsistently
|
private int |
lineWidth
total line length available
|
private ArrayList<Integer> |
marginStack
stack to remember value of
pos in nested blocks |
private int |
pos
position in current line.
|
private static String |
spaces
a String containing
SPACES spaces |
private static int |
SPACES
how many spaces
|
| Constructor and Description |
|---|
Printer(Backend back)
Create a printer.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
close()
Close the output stream.
|
(package private) void |
closeBlock()
end a block
|
(package private) void |
flush()
Flush the output stream.
|
(package private) void |
indent(int width,
int offset) |
(package private) int |
lineWidth()
Return the line width of this Printer.
|
(package private) void |
mark(Object o) |
private void |
newLine()
Start a new line and indent according to
pos |
(package private) void |
openBlock(boolean consistent,
int indent,
int followingLength)
begin a block
|
private void |
pop()
Pop one element from the space stack.
|
(package private) void |
print(String s)
write the String
s to out |
(package private) void |
printBreak(int width,
int offset,
int followingLength)
write a break.
|
private void |
push(int n,
int breaks) |
(package private) int |
space()
Return the amount of space currently left on this line.
|
private int |
top()
return the topmost element of the space stack without popping it.
|
private int |
topBreak() |
private int |
topMargin() |
private void |
writeSpaces(int n) |
private static final int BREAK_MASK
private static final int FITS
private static final int CONSISTENT
private static final int INCONSISTENT
private final int lineWidth
private int pos
private Backend back
private static final int SPACES
private static final String spaces
SPACES spacesPrinter(Backend back)
writer.
Lines have a maximum width of lineWidth.void print(String s) throws IOException
s to outIOExceptionvoid openBlock(boolean consistent,
int indent,
int followingLength)
void closeBlock()
void printBreak(int width,
int offset,
int followingLength)
throws IOException
followingLength should be the
space needed by the material up to the next corresponding
closeBlock() or printBreak(), and is used to decide whether the
current line is continues, or a new (indented) line is begun.IOExceptionvoid mark(Object o)
void indent(int width,
int offset)
throws IOException
IOExceptionvoid close()
throws IOException
IOExceptionvoid flush()
throws IOException
IOExceptionint space()
int lineWidth()
private void push(int n,
int breaks)
private void pop()
private int top()
private int topMargin()
private int topBreak()
private void newLine()
throws IOException
posIOExceptionprivate void writeSpaces(int n)
throws IOException
IOException