IndentPrinter

Adapted from groovy.util.IndentPrinter (published under ASL 2.0).

API

IndentPrinter.java
class IndentPrinter {
  IndentPrinter()     (1)
  IndentPrinter(Writer out)     (2)
  IndentPrinter(Writer out, String indent)     (3)
  IndentPrinter(Writer out, String indent, boolean addNewlines)     (4)
  void println(String text)     (5)
  void print(String text)     (6)
  void print(char c)     (7)
  void printIndent()     (8)
  void println()     (9)
  void incrementIndent()
  void decrementIndent()
  int getIndentLevel()
  void setIndentLevel(int indentLevel)
  void flush()
}
1 IndentPrinter()

Creates an IndentPrinter backed by a PrintWriter pointing to System.out, with an indent of two spaces.

2 IndentPrinter(Writer)

Creates an IndentPrinter backed by the supplied Writer, with an indent of two spaces.

3 IndentPrinter(Writer, String)

Creates an IndentPrinter backed by the supplied Writer, with a user-supplied String to be used for indenting.

4 IndentPrinter(Writer, String, boolean)

Creates an IndentPrinter backed by the supplied Writer, with a user-supplied String to be used for indenting and the ability to override newline handling.

5 println(String)

Prints a string followed by an end of line character.

6 print(String)

Prints a string.

7 print(char)

Prints a character.

8 printIndent()

Prints the current indent level.

9 println()

Prints an end-of-line character (if enabled via addNewLines property). Defaults to outputting a single '\n' character but by using a custom Writer, e.g. PlatformLineWriter, you can get platform-specific end-of-line characters.

Members

IndentPrinter()

Creates an IndentPrinter backed by a PrintWriter pointing to System.out, with an indent of two spaces.

IndentPrinter(Writer)

Creates an IndentPrinter backed by the supplied Writer, with an indent of two spaces.

IndentPrinter(Writer, String)

Creates an IndentPrinter backed by the supplied Writer, with a user-supplied String to be used for indenting.

IndentPrinter(Writer, String, boolean)

Creates an IndentPrinter backed by the supplied Writer, with a user-supplied String to be used for indenting and the ability to override newline handling.

println(String)

Prints a string followed by an end of line character.

Prints a string.

Prints a character.

printIndent()

Prints the current indent level.

println()

Prints an end-of-line character (if enabled via addNewLines property). Defaults to outputting a single '\n' character but by using a custom Writer, e.g. PlatformLineWriter, you can get platform-specific end-of-line characters.