dsto.dfc.util
Class IndentPrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by dsto.dfc.util.IndentPrintWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class IndentPrintWriter
extends PrintWriter

Extension of PrintWriter that provides auto-indent.

Author:
mpp

Field Summary
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
IndentPrintWriter(Writer writer)
           
 
Method Summary
 int getIndent()
          Get the current indent level.
 int getIndentIncr()
          Get the amount of spaces to increment the indent level by when using indent().
 void indent()
          Increment the indent level by getIndentIncr() spaces.
 void indent(int spaces)
           
 void indentln()
          Increment indent and start a new line.
 void println()
           
 void setIndent(int indent)
          Set the current indent level.
 void setIndentIncr(int newValue)
          Set the amount of spaces to increment the indent level by when using indent().
 String toString()
          Make it easier for StringWriter users.
 void unindent()
          Reverse the effect of an indent().
 void unindent(int spaces)
           
 void write(char[] buf, int off, int len)
           
 void write(int c)
           
 void write(String s, int off, int len)
           
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndentPrintWriter

public IndentPrintWriter(Writer writer)
Method Detail

toString

public String toString()
Make it easier for StringWriter users.

Overrides:
toString in class Object

setIndentIncr

public void setIndentIncr(int newValue)
Set the amount of spaces to increment the indent level by when using indent().


getIndentIncr

public int getIndentIncr()
Get the amount of spaces to increment the indent level by when using indent().


setIndent

public void setIndent(int indent)
Set the current indent level. You probably want to use indent() and unindent() instead.


getIndent

public int getIndent()
Get the current indent level.


indentln

public void indentln()
Increment indent and start a new line.


indent

public void indent()
Increment the indent level by getIndentIncr() spaces.

See Also:
unindent(), setIndentIncr(int)

unindent

public void unindent()
Reverse the effect of an indent().


indent

public void indent(int spaces)

unindent

public void unindent(int spaces)

write

public void write(int c)
Overrides:
write in class PrintWriter

write

public void write(char[] buf,
                  int off,
                  int len)
Overrides:
write in class PrintWriter

write

public void write(String s,
                  int off,
                  int len)
Overrides:
write in class PrintWriter

println

public void println()
Overrides:
println in class PrintWriter


Copyright © 2008 Commonwealth of Australia