Class XMLFormatter.Builder

    • Method Detail

      • elementIndent

        public XMLFormatter.Builder elementIndent​(String indent)
        String to use for indenting elements. Repeated as needed to match the current hierarchical depth of the element. Defaults to two spaces.
        Parameters:
        indent - string to use as indent
        Returns:
        this builder
      • attributeIndent

        public XMLFormatter.Builder attributeIndent​(String indent)
        String to use for indenting attributed, when wrapped. Defaults to four spaces.
        Parameters:
        indent - string to use as indent
        Returns:
        this builder
      • closeWrappingTagOnOwnLine

        public XMLFormatter.Builder closeWrappingTagOnOwnLine()
        Put the closing angle bracket of tags with wrapping attributes on its own line, aligned with opening angle bracket. Defaults to adding it the closing angle bracket at the end of the last attribute.
        Returns:
        this builder
      • maxLineLength

        public XMLFormatter.Builder maxLineLength​(int charQty)
        Maximum length a line can have before wrapping is performed. Tries to do smart break when possible. When not possible, (e.g., a very long word) it will not wrap. minTextLength(int) and XMLFormatter.Builder.AttributeWrap.NONE both take precedence over this value.
        Parameters:
        charQty - maximum number of characters.
        Returns:
        this builder
      • minTextLength

        public XMLFormatter.Builder minTextLength​(int charQty)
        Minimum length for text on any line before text can be wrapped. This takes precedence over maxLineLength.
        Parameters:
        charQty - minimum number of characters.
        Returns:
        this builder
      • blankLineBeforeComment

        public XMLFormatter.Builder blankLineBeforeComment()
        Inserts a blank line before a comment.
        Returns:
        this builder
      • blankLineAfterComment

        public XMLFormatter.Builder blankLineAfterComment()
        Inserts a blank line after a comment.
        Returns:
        this builder
      • selfCloseEmptyElements

        public XMLFormatter.Builder selfCloseEmptyElements()
        Self-close elements with no or blank values.
        Returns:
        this builder
      • preserveTextIndent

        public XMLFormatter.Builder preserveTextIndent()
        Preserves indentation found in element or comment text. By default all lines are trimmed. When this option is set, indentations (relative to the shorted indent) are kept.
        Returns:
        this builder
      • build

        public XMLFormatter build()
        Creates an immutable, thread-safe XML formatter instance using this builder.
        Returns:
        XML formatter