public class PrettyWriter
extends java.io.Writer
| Modifier and Type | Field and Description |
|---|---|
char[] |
buffer
Holds all the text that has been output but not yet printed.
|
int |
bufferFillPointer
The index into BUFFER where more text should be put.
|
static ThreadLocation |
indentLoc |
static int |
initialBufferSize |
static ThreadLocation |
lineLengthLoc |
static ThreadLocation |
miserWidthLoc |
static int |
NEWLINE_FILL |
static int |
NEWLINE_LINEAR |
static int |
NEWLINE_LITERAL |
static int |
NEWLINE_MANDATORY |
static int |
NEWLINE_MISER |
static int |
NEWLINE_SPACE
A non-nested ' ' gets an implicit NEWLINE_SPACE.
|
protected java.io.Writer |
out |
int |
pendingBlocksCount
Number of startLogicalBlock - number of endLogicalBlock.
|
| Constructor and Description |
|---|
PrettyWriter(java.io.Writer out) |
PrettyWriter(java.io.Writer out,
boolean prettyPrintingMode) |
PrettyWriter(java.io.Writer out,
int lineLength) |
| Modifier and Type | Method and Description |
|---|---|
void |
addIndentation(int amount,
boolean current) |
void |
clearBuffer() |
void |
clearWordEnd() |
void |
close() |
void |
closeThis()
Flush and close this local Writer, but not underlying Writers.
|
void |
endLogicalBlock() |
void |
endLogicalBlock(java.lang.String suffix) |
int |
enqueue(int kind,
int size) |
int |
enqueueIndent(char kind,
int amount) |
void |
enqueueNewline(int kind) |
void |
flush() |
void |
forcePrettyOutput() |
int |
getColumnNumber()
Not meaningful if
prettyPrintingMode > 0. |
protected int |
getMiserWidth() |
int |
getPrettyPrintingMode()
Return pretty-printing mode.
|
boolean |
isPrettyPrinting()
Is pretty printing enabled?
|
void |
lineAbbreviationHappened() |
void |
setColumnNumber(int column) |
void |
setIndentation(int column) |
void |
setPrettyPrinting(boolean mode)
Turn pretty printing on or off.
|
void |
setPrettyPrintingMode(int mode)
Control pretty-printing mode.
|
void |
startLogicalBlock(java.lang.String prefix,
boolean perLine,
java.lang.String suffix) |
void |
write(char[] str) |
void |
write(char[] str,
int start,
int count) |
void |
write(int ch) |
void |
write(java.lang.String str) |
void |
write(java.lang.String str,
int start,
int count) |
void |
writeBreak(int kind) |
void |
writeWordEnd()
Note the end of a "word".
|
void |
writeWordStart()
Maybe write a word-separating space.
|
protected java.io.Writer out
public static ThreadLocation lineLengthLoc
public static ThreadLocation miserWidthLoc
public static ThreadLocation indentLoc
public static int initialBufferSize
public char[] buffer
public int bufferFillPointer
public int pendingBlocksCount
public static final int NEWLINE_LINEAR
public static final int NEWLINE_LITERAL
public static final int NEWLINE_FILL
public static final int NEWLINE_SPACE
public static final int NEWLINE_MISER
public static final int NEWLINE_MANDATORY
public PrettyWriter(java.io.Writer out)
public PrettyWriter(java.io.Writer out,
int lineLength)
public PrettyWriter(java.io.Writer out,
boolean prettyPrintingMode)
public void setPrettyPrintingMode(int mode)
mode - the value 0 disables pretty-printing;
the value 1 enables ecplicit pretty-printing;
the value 2 enables pretty-printing with auto-fill, which means that
spaces are treated like enqueing NEWLINE_SPACE (essentiall a 'fill').public int getPrettyPrintingMode()
setPrettyPrintingMode(int).public boolean isPrettyPrinting()
public void setPrettyPrinting(boolean mode)
setPrettyPrintingMode(mode?1:0).public void writeWordEnd()
writeWordStart().public void writeWordStart()
writeWordEnd(). Otherwise, do nothing.public void clearWordEnd()
public void write(int ch)
write in class java.io.Writerpublic void write(java.lang.String str)
write in class java.io.Writerpublic void write(java.lang.String str,
int start,
int count)
write in class java.io.Writerpublic void write(char[] str)
write in class java.io.Writerpublic void write(char[] str,
int start,
int count)
write in class java.io.Writerpublic void setIndentation(int column)
public int enqueue(int kind,
int size)
public void enqueueNewline(int kind)
public final void writeBreak(int kind)
public int enqueueIndent(char kind,
int amount)
public void addIndentation(int amount,
boolean current)
public void startLogicalBlock(java.lang.String prefix,
boolean perLine,
java.lang.String suffix)
public void endLogicalBlock()
public void endLogicalBlock(java.lang.String suffix)
protected int getMiserWidth()
public void lineAbbreviationHappened()
public void forcePrettyOutput()
throws java.io.IOException
java.io.IOExceptionpublic void flush()
flush in interface java.io.Flushableflush in class java.io.Writerpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionpublic void closeThis()
throws java.io.IOException
java.io.IOExceptionpublic int getColumnNumber()
prettyPrintingMode > 0.public void setColumnNumber(int column)
public void clearBuffer()