Class AutoIndentWriter

  • All Implemented Interfaces:
    STWriter
    Direct Known Subclasses:
    NoIndentWriter

    public class AutoIndentWriter
    extends Object
    implements STWriter
    Essentially a char filter that knows how to auto-indent output by maintaining a stack of indent levels.

    The indent stack is a stack of strings so we can repeat original indent not just the same number of columns (don't have to worry about tabs vs spaces then). Anchors are char positions (tabs won't work) that indicate where all future wraps should justify to. The wrap position is actually the larger of either the last anchor or the indentation level.

    This is a filter on a Writer.

    \n is the proper way to say newline for options and templates. Templates can mix \r\n and \n them, but use \n in options like wrap="\n". This writer will render newline characters according to newline. The default value is taken from the line.separator system property, and can be overridden by passing in a String to the appropriate constructor.