Package com.norconex.commons.lang.xml

# Class XmlFormatter.Builder

java.lang.Object
com.norconex.commons.lang.xml.XmlFormatter.Builder

Enclosing class:
  XmlFormatter

public static class XmlFormatter.Builder extends Object

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `XmlFormatter.Builder.AttributeWrap`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `XmlFormatter.Builder`
  `attributeIndent(String indent)`
  String to use for indenting attributed, when wrapped.
  `XmlFormatter.Builder`
  `attributeWrapping(XmlFormatter.Builder.AttributeWrap attributeWrapping)`
  Attribute wrapping strategy.
  `XmlFormatter.Builder`
  `blankLineAfterComment()`
  Inserts a blank line after a comment.
  `XmlFormatter.Builder`
  `blankLineBeforeComment()`
  Inserts a blank line before a comment.
  `XmlFormatter`
  `build()`
  Creates an immutable, thread-safe XML formatter instance using this builder.
  `XmlFormatter.Builder`
  `closeWrappingTagOnOwnLine()`
  Put the closing angle bracket of tags with wrapping attributes on its own line, aligned with opening angle bracket.
  `XmlFormatter.Builder`
  `elementIndent(String indent)`
  String to use for indenting elements.
  `XmlFormatter.Builder`
  `maxLineLength(int charQty)`
  Maximum length a line can have before wrapping is performed.
  `XmlFormatter.Builder`
  `minTextLength(int charQty)`
  Minimum length for text on any line before text can be wrapped.
  `XmlFormatter.Builder`
  `preserveTextIndent()`
  Preserves indentation found in element or comment text.
  `XmlFormatter.Builder`
  `selfCloseEmptyElements()`
  Self-close elements with no or blank values.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### 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

  - ### attributeWrapping

    public XmlFormatter.Builder attributeWrapping(XmlFormatter.Builder.AttributeWrap attributeWrapping)
    Attribute wrapping strategy. Defaults to `XmlFormatter.Builder.AttributeWrap.ALL`.
    Parameters:
      `attributeWrapping` - attribute wrapping strategy
    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(int)`.
    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