Class Editor.EditorElementBuilder

java.lang.Object
eu.maveniverse.domtrip.Editor.EditorElementBuilder
Enclosing class:
Editor

public static class Editor.EditorElementBuilder extends Object
Builder for creating and configuring elements within the Editor context.

This builder integrates with the Editor's whitespace management and automatically adds the created element to the specified parent.

  • Method Details

    • to

      Sets the parent node for this element.
      Parameters:
      parent - the parent node
      Returns:
      this builder for method chaining
    • withText

      public Editor.EditorElementBuilder withText(String content)
      Sets text content for this element.
      Parameters:
      content - the text content
      Returns:
      this builder for method chaining
    • withAttribute

      public Editor.EditorElementBuilder withAttribute(String name, String value)
      Adds an attribute to this element.
      Parameters:
      name - the attribute name
      value - the attribute value
      Returns:
      this builder for method chaining
    • withAttribute

      public Editor.EditorElementBuilder withAttribute(QName qname, String value)
      Adds an attribute to this element using a QName.
      Parameters:
      qname - the attribute QName
      value - the attribute value
      Returns:
      this builder for method chaining
    • withAttributes

      public Editor.EditorElementBuilder withAttributes(Map<String,String> attributes)
      Adds multiple attributes to this element.
      Parameters:
      attributes - a map of attribute names to values
      Returns:
      this builder for method chaining
    • withQNameAttributes

      public Editor.EditorElementBuilder withQNameAttributes(Map<QName,String> qnameAttributes)
      Adds multiple attributes to this element using QNames.
      Parameters:
      qnameAttributes - a map of attribute QNames to values
      Returns:
      this builder for method chaining
    • selfClosing

      public Editor.EditorElementBuilder selfClosing()
      Makes this element self-closing.
      Returns:
      this builder for method chaining
    • build

      public Element build() throws DomTripException
      Builds and adds the element to the document.
      Returns:
      the created and added element
      Throws:
      DomTripException - if the element cannot be added