Package com.norconex.commons.lang.xml
Class XmlFormatter.Builder
java.lang.Object
com.norconex.commons.lang.xml.XmlFormatter.Builder
- Enclosing class:
XmlFormatter
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionattributeIndent(String indent) String to use for indenting attributed, when wrapped.attributeWrapping(XmlFormatter.Builder.AttributeWrap attributeWrapping) Attribute wrapping strategy.Inserts a blank line after a comment.Inserts a blank line before a comment.build()Creates an immutable, thread-safe XML formatter instance using this builder.Put the closing angle bracket of tags with wrapping attributes on its own line, aligned with opening angle bracket.elementIndent(String indent) String to use for indenting elements.maxLineLength(int charQty) Maximum length a line can have before wrapping is performed.minTextLength(int charQty) Minimum length for text on any line before text can be wrapped.Preserves indentation found in element or comment text.Self-close elements with no or blank values.
-
Method Details
-
elementIndent
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
String to use for indenting attributed, when wrapped. Defaults to four spaces.- Parameters:
indent- string to use as indent- Returns:
- this builder
-
attributeWrapping
Attribute wrapping strategy. Defaults toXmlFormatter.Builder.AttributeWrap.ALL.- Parameters:
attributeWrapping- attribute wrapping strategy- Returns:
- this 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
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)andXmlFormatter.Builder.AttributeWrap.NONEboth take precedence over this value.- Parameters:
charQty- maximum number of characters.- Returns:
- this builder
-
minTextLength
Minimum length for text on any line before text can be wrapped. This takes precedence overmaxLineLength(int).- Parameters:
charQty- minimum number of characters.- Returns:
- this builder
-
blankLineBeforeComment
Inserts a blank line before a comment.- Returns:
- this builder
-
blankLineAfterComment
Inserts a blank line after a comment.- Returns:
- this builder
-
selfCloseEmptyElements
Self-close elements with no or blank values.- Returns:
- this 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
Creates an immutable, thread-safe XML formatter instance using this builder.- Returns:
- XML formatter
-