| java.lang.Object java.io.Writer java.io.PrintWriter org.obe.util.FormattingPrintWriter
FormattingPrintWriter | public class FormattingPrintWriter extends PrintWriter (Code) | | A PrintWriter class that supports tab stops and programmable indentation.
The writer interprets tab characters in the usual way, by emitting spaces to
align the following characters at the next tab stop to the right of the
current print position. The default tab stops are at every 8 characters,
that is, in columns 9, 17, 25, ... 81. The
FormattingPrintWriter.setTabs method allows
custom tab stops to be specified. Indentation can be controlled via the
FormattingPrintWriter.pushIndent() ,
FormattingPrintWriter.pushIndent(int) and
FormattingPrintWriter.popIndent() methods.
The writer scans all arguments for newline characters, and achieves the
desired indentation level by inserting a corresponding number of spaces into
the output before continuing with the characters following the newline.
Indentation settings are held internally on a stack so that cancelling the
current setting automatically restores the previous one.
author: Adrian Price |
Method Summary | |
public void | clearTabs() Restores the default tab stops. | public int | getIndent() Returns the current indentation level. | public int | getPosition() Returns the current output position (zero-based). | public int[] | getTabs() Returns unity-based tab stop positions, as an ascending sequence of
positive integers. | public void | popIndent() Restores the previous indentation level. | public void | print(boolean b) | public void | print(char c) | public void | print(int i) | public void | print(long l) | public void | print(float f) | public void | print(double d) | public void | print(char[] ca) | public void | print(String s) | public void | print(Object obj) | public void | println() | public void | println(boolean b) | public void | println(char c) | public void | println(int i) | public void | println(long l) | public void | println(float f) | public void | println(double d) | public void | println(char[] c) | public void | println(String s) | public void | println(Object obj) | public void | pushIndent(int i) Increases the indentation level by the specified amount. | public void | pushIndent() Increases the indentation level to the next tab stop past the current
output position. | public void | setTabs(int[] tabs) Sets custom tab stops. | public void | write(int c) | public void | write(char[] buf, int off, int len) | public void | write(char[] buf) | public void | write(String s, int off, int len) | public void | write(String s) |
FormattingPrintWriter | public FormattingPrintWriter(Writer out)(Code) | | Constructs a new FormattingPrintWriter, without automatic line flushing.
Parameters: out - A character-output stream. |
FormattingPrintWriter | public FormattingPrintWriter(Writer out, boolean autoFlush)(Code) | | Constructs a new FormattingPrintWriter.
Parameters: out - A character-output stream. Parameters: autoFlush - If true , the println() methods will flushthe output buffer. |
FormattingPrintWriter | public FormattingPrintWriter(OutputStream out)(Code) | | Constructs a new PrintWriter, without automatic line flushing, from an
existing OutputStream. This convenience constructor creates the necessary
intermediate OutputStreamWriter, which will convert characters into bytes
using the default character encoding.
Parameters: out - An output stream. |
FormattingPrintWriter | public FormattingPrintWriter(OutputStream out, boolean autoFlush)(Code) | | Constructs a new PrintWriter from an existing OutputStream. This
convenience constructor creates the necessary intermediate
OutputStreamWriter, which will convert characters into bytes using the
default character encoding.
Parameters: out - An output stream. Parameters: autoFlush - if true , the println() methods will flushthe output buffer. |
clearTabs | public void clearTabs()(Code) | | Restores the default tab stops.
|
getIndent | public int getIndent()(Code) | | Returns the current indentation level.
Indentation level as a character count. |
getPosition | public int getPosition()(Code) | | Returns the current output position (zero-based).
The output position. |
getTabs | public int[] getTabs()(Code) | | Returns unity-based tab stop positions, as an ascending sequence of
positive integers.
Current tab stops. |
popIndent | public void popIndent()(Code) | | Restores the previous indentation level.
throws: IllegalStateException - if the current indentation level is 0. |
print | public void print(boolean b)(Code) | | |
print | public void print(char c)(Code) | | |
print | public void print(int i)(Code) | | |
print | public void print(long l)(Code) | | |
print | public void print(float f)(Code) | | |
print | public void print(double d)(Code) | | |
print | public void print(char[] ca)(Code) | | |
println | public void println()(Code) | | |
println | public void println(boolean b)(Code) | | |
println | public void println(char c)(Code) | | |
println | public void println(int i)(Code) | | |
println | public void println(long l)(Code) | | |
println | public void println(float f)(Code) | | |
println | public void println(double d)(Code) | | |
println | public void println(char[] c)(Code) | | |
pushIndent | public void pushIndent(int i)(Code) | | Increases the indentation level by the specified amount.
Parameters: i - Number of columns by which to increase indentation. |
pushIndent | public void pushIndent()(Code) | | Increases the indentation level to the next tab stop past the current
output position.
|
setTabs | public void setTabs(int[] tabs)(Code) | | Sets custom tab stops. At output positions past the rightmost tab stop,
tab characters are converted into single spaces.
Parameters: tabs - Unity-based tab stop positions, as an ascending sequence ofpositive integers. |
write | public void write(int c)(Code) | | |
write | public void write(char[] buf, int off, int len)(Code) | | |
write | public void write(char[] buf)(Code) | | |
Methods inherited from java.io.PrintWriter | public PrintWriter append(CharSequence csq)(Code)(Java Doc) public PrintWriter append(CharSequence csq, int start, int end)(Code)(Java Doc) public PrintWriter append(char c)(Code)(Java Doc) public boolean checkError()(Code)(Java Doc) protected void clearError()(Code)(Java Doc) public void close()(Code)(Java Doc) public void flush()(Code)(Java Doc) public PrintWriter format(String format, Object... args)(Code)(Java Doc) public PrintWriter format(Locale l, String format, Object... args)(Code)(Java Doc) public void print(boolean b)(Code)(Java Doc) public void print(char c)(Code)(Java Doc) public void print(int i)(Code)(Java Doc) public void print(long l)(Code)(Java Doc) public void print(float f)(Code)(Java Doc) public void print(double d)(Code)(Java Doc) public void print(char s)(Code)(Java Doc) public void print(String s)(Code)(Java Doc) public void print(Object obj)(Code)(Java Doc) public PrintWriter printf(String format, Object... args)(Code)(Java Doc) public PrintWriter printf(Locale l, String format, Object... args)(Code)(Java Doc) public void println()(Code)(Java Doc) public void println(boolean x)(Code)(Java Doc) public void println(char x)(Code)(Java Doc) public void println(int x)(Code)(Java Doc) public void println(long x)(Code)(Java Doc) public void println(float x)(Code)(Java Doc) public void println(double x)(Code)(Java Doc) public void println(char x)(Code)(Java Doc) public void println(String x)(Code)(Java Doc) public void println(Object x)(Code)(Java Doc) protected void setError()(Code)(Java Doc) public void write(int c)(Code)(Java Doc) public void write(char buf, int off, int len)(Code)(Java Doc) public void write(char buf)(Code)(Java Doc) public void write(String s, int off, int len)(Code)(Java Doc) public void write(String s)(Code)(Java Doc)
|
|
|