Class IndentationPrintWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class IndentationPrintWriter
    extends java.io.PrintWriter
    A print writer with indentation.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String indentation  
      private java.lang.String indentationStep  
      • Fields inherited from class java.io.PrintWriter

        out
      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      IndentationPrintWriter​(java.io.Writer writer)
      Creates an indentation print writer with default indentation (4 whitespaces).
      IndentationPrintWriter​(java.io.Writer writer, java.lang.String indentationStep)
      Creates an indentation print writer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void decreaseIndentation()
      Decreases the indentation.
      void increaseIndentation()
      Increases the indentation.
      void printIndentation()
      Emits the indentation.
      • 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, println, setError, write, write, write, write, write
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • indentationStep

        private java.lang.String indentationStep
      • indentation

        private java.lang.String indentation
    • Constructor Detail

      • IndentationPrintWriter

        public IndentationPrintWriter​(java.io.Writer writer)
        Creates an indentation print writer with default indentation (4 whitespaces).
        Parameters:
        writer - the writer to write to
      • IndentationPrintWriter

        public IndentationPrintWriter​(java.io.Writer writer,
                                      java.lang.String indentationStep)
        Creates an indentation print writer.
        Parameters:
        writer - the writer to write to
        indentationStep - the indentation step (appended in increaseIndentation())
    • Method Detail

      • increaseIndentation

        public void increaseIndentation()
        Increases the indentation.
      • printIndentation

        public void printIndentation()
        Emits the indentation.
      • decreaseIndentation

        public void decreaseIndentation()
        Decreases the indentation.