Interface Element

All Known Subinterfaces:
ProcessingInstruction, XMLElement
All Known Implementing Classes:
Comment, DocType, ProcessingInstructionImpl, Text, XMLElementAdapter, XMLElementImpl

@ClassVersion(sourceVersion="$Id: Element.java 1158 2026-03-14 16:23:29Z tquadrat $") @API(status=MAINTAINED, since="0.0.5") public interface Element
The definition for an SGML element.
Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: Element.java 1158 2026-03-14 16:23:29Z tquadrat $
Since:
0.0.5
UML Diagram
UML Diagram for "org.tquadrat.foundation.xml.builder.spi.Element"

UML Diagram for "org.tquadrat.foundation.xml.builder.spi.Element"

UML Diagram for "org.tquadrat.foundation.xml.builder.spi.Element"
  • Method Details

    • getAttribute

      Returns the value for the attribute with the given name.
      Parameters:
      name - The attribute name.
      Returns:
      An instance of Optional that holds the value for that attribute.
    • getAttributes

      Provides read access to the attributes.
      Returns:
      A reference to the attributes.
    • getChildren

      default Collection<? extends Element> getChildren()
      Provides access to the children for this element; the returned collection is not modifiable.
      Returns:
      A reference to the children of this element; if the element does not have children, an empty collection will be returned.
    • getElementName

      Returns the name of the element.
      Returns:
      The name of the element.
    • getNamespaces

      Provides access to the namespaces for this element; the returned collection is not modifiable.
      Returns:
      A reference to the namespaces of this element; if the element does not have namespaces assigned, an empty collection will be returned.
    • getParent

      Returns the parent of this element.
      Returns:
      An instance of Optional that holds the parent.
    • hasChildren

      default boolean hasChildren()
      Returns true if the element has children, false otherwise.
      Returns:
      true if the element has children.
    • isBlock

      default boolean isBlock()

      Returns the block flag.

      This flag is used in the conversion of the element into a String; it indicates whether the element is 'inline' (like an HTML <span>) or 'block' (as an HTML <div>). This is important only for elements where whitespace is relevant, like for HTML elements, as pretty printing will add additional whitespace around inline elements that can become visible on parsing (for HTML: on the rendered page).

      XML elements for example will be always block as there whitespace is not that important.

      Obviously, true indicates a block element, while false stands for an inline element.

      The default is true.

      Returns:
      The flag.
    • setParent

      <E extends Element> void setParent(E parent)
      Sets the parent for this element.
      Type Parameters:
      E - The implementation of Element.
      Parameters:
      parent - The parent.
    • toString

      default String toString(int indentationLevel, boolean prettyPrint)
      Returns a String representation for this element instance.
      Parameters:
      indentationLevel - The indentation level.
      prettyPrint - The pretty print flag.
      Returns:
      The String representation.