Class Editor.EditorElementBuilder

  • Enclosing class:
    Editor

    public static class Editor.EditorElementBuilder
    extends java.lang.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 Detail

      • withText

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

        public Editor.EditorElementBuilder withAttribute​(java.lang.String name,
                                                         java.lang.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,
                                                         java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<QName,​java.lang.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