org.progeeks.util
Class IndentPrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by org.progeeks.util.IndentPrintWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
XmlPrintWriter

public class IndentPrintWriter
extends java.io.PrintWriter

PrintWriter implementation that keeps track of an indent state.

Version:
$Revision: 1.1 $
Author:
Paul Speed

Field Summary
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
IndentPrintWriter(java.io.Writer out)
           
 
Method Summary
 void endLine()
          Ends the current line and sets up for a new indent.
 java.lang.String getDefaultIndent()
          Returns the default indent string used by the no-arg pushIndent() method.
 boolean isNewLine()
          Returns true if this is a new line.
 void popIndent()
          Pops an indent off of the indent stack.
 void println()
          Resets the new line state and outputs a line separator.
 void pushIndent()
          Pushes another indent onto the indent stack.
 void pushIndent(java.lang.String indent)
          Pushes a custom indent onto the indent stack.
 void setDefaultIndent(java.lang.String s)
          Sets the default indent string used by the no-arg pushIndent() method.
 void setOverrideIndent(boolean override)
          Set to true to override the current indent.
 void write(char[] buff, int off, int len)
          Overridden to set the new line state to false and to write the indent level if newLine is true.
 void write(int c)
          Overridden to set the new line state to false and to write the indent level if newLine is true.
 void write(java.lang.String s, int off, int len)
          Overridden to set the new line state to false and to write the indent level if newLine is true.
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, 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, toString, wait, wait, wait
 

Constructor Detail

IndentPrintWriter

public IndentPrintWriter(java.io.Writer out)
Method Detail

setDefaultIndent

public void setDefaultIndent(java.lang.String s)
Sets the default indent string used by the no-arg pushIndent() method.


getDefaultIndent

public java.lang.String getDefaultIndent()
Returns the default indent string used by the no-arg pushIndent() method.


pushIndent

public void pushIndent()
Pushes another indent onto the indent stack.


pushIndent

public void pushIndent(java.lang.String indent)
Pushes a custom indent onto the indent stack.


popIndent

public void popIndent()
Pops an indent off of the indent stack.


setOverrideIndent

public void setOverrideIndent(boolean override)
Set to true to override the current indent. Indent level will still be tracked, it just won't be output.


write

public void write(int c)
Overridden to set the new line state to false and to write the indent level if newLine is true.

Overrides:
write in class java.io.PrintWriter

write

public void write(char[] buff,
                  int off,
                  int len)
Overridden to set the new line state to false and to write the indent level if newLine is true.

Overrides:
write in class java.io.PrintWriter

write

public void write(java.lang.String s,
                  int off,
                  int len)
Overridden to set the new line state to false and to write the indent level if newLine is true.

Overrides:
write in class java.io.PrintWriter

println

public void println()
Resets the new line state and outputs a line separator.

Overrides:
println in class java.io.PrintWriter

endLine

public void endLine()
Ends the current line and sets up for a new indent. This will only generate a line feed if the new line state is false.


isNewLine

public boolean isNewLine()
Returns true if this is a new line.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.