Enum Class FormatElementCategory
- All Implemented Interfaces:
Serializable,Comparable<FormatElementCategory>,Constable
Classification of an XML element that determines how the formatter handles
its whitespace. The category is computed from the element's content model
(children, text, or both) and from
xml:space attributes.
The category drives every formatting decision in
DOMElementFormatter: indentation of children, wrapping at
maxLineWidth, whitespace collapsing, and preservation.
- Author:
- Angelo ZERR
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionElement contains only child elements (no text content).Element contains both text and child elements.Element contains only text (no child elements).Element hasxml:space="preserve"— all whitespace is significant. -
Method Summary
Modifier and TypeMethodDescriptionstatic FormatElementCategoryReturns the enum constant of this class with the specified name.static FormatElementCategory[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
IgnoreSpace
Element contains only child elements (no text content). All whitespace between children is insignificant and is replaced with newlines and proper indentation.Use case:
<root><a><b/></a></root> → <root> <a> <b /> </a> </root> -
NormalizeSpace
Element contains only text (no child elements). Consecutive whitespace characters are collapsed to a single space. Line breaks are preserved unlessjoinContentLinesis enabled.Use case:
<p> hello world </p> → <p>hello world</p>
-
MixedContent
Element contains both text and child elements. Inline flow is preserved: a single whitespace between text and elements is significant. Child elements only wrap to new lines whenmaxLineWidthis exceeded or indentation needs normalizing.Use case (no overflow — stays inline):
<p>text <b>bold</b> more</p> → unchanged
Use case (overflow — element wraps):
<p>text <a>aaa</a><b>bbb</b></p> → <p>text <a>aaa</a> <b>bbb</b></p>
-
PreserveSpace
Element hasxml:space="preserve"— all whitespace is significant. No changes are made to spacing within this element. Child elements may belong to a different category and may be reformatted independently.Attribute values are always treated as preserve-space regardless of the element's category.
Use case:
<pre xml:space="preserve"> keep spaces </pre> → unchanged
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-