Class TextElement<T extends TextElement<T>>

Direct Known Subclasses:
PhrasingContentElement

public abstract class TextElement<T extends TextElement<T>> extends StyledElement<T>
Abstract base class for HTML elements that primarily contain text content.

TextElement provides common functionality for elements like paragraphs, headings, spans, and other text-containing elements. It simplifies setting and manipulating text content with optional styling.

Subclasses include elements such as:

  • invalid reference
    Paragraph
    - <p> element
  • invalid reference
    Span
    - <span> element
  • invalid reference
    H1
    ,
    invalid reference
    H2
    , etc. - Heading elements
  • invalid reference
    Label
    - <label> element
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • TextElement

      public TextElement(String tagName)
      Creates a new TextElement with the specified HTML tag name.
      Parameters:
      tagName - The HTML tag name for this element.
    • TextElement

      public TextElement(String tagName, String text)
      Creates a new TextElement with the specified tag name and text content.
      Parameters:
      tagName - The HTML tag name for this element.
      text - The text content to display.
    • TextElement

      public TextElement(String tagName, String text, String style)
      Creates a new TextElement with the specified tag name, text content, and inline CSS style.
      Parameters:
      tagName - The HTML tag name for this element.
      text - The text content to display.
      style - The inline CSS style string.
    • TextElement

      public TextElement(String tagName, String text, CssStyle style)
      Creates a new TextElement with the specified tag name, text content, and CSS style object.
      Parameters:
      tagName - The HTML tag name for this element.
      text - The text content to display.
      style - The CssStyle object containing style properties.
  • Method Details

    • setText

      public final void setText(String text)
      Sets the text content of this element, replacing any existing content.
      Overrides:
      setText in class Element<T extends TextElement<T>>
      Parameters:
      text - The text content to display.
    • setText

      public final void setText(String text, CssStyle style)
      Sets the text content and style of this element, replacing any existing content.
      Overrides:
      setText in class Element<T extends TextElement<T>>
      Parameters:
      text - The text content to display.
      style - The CssStyle object containing style properties.
    • setText

      public final void setText(String text, String style)
      Sets the text content and inline CSS style of this element, replacing any existing content.
      Overrides:
      setText in class Element<T extends TextElement<T>>
      Parameters:
      text - The text content to display.
      style - The inline CSS style string.
    • addText

      public final void addText(String text)
      Appends additional text content to this element without removing existing content.
      Overrides:
      addText in class Element<T extends TextElement<T>>
      Parameters:
      text - The text to append.
    • addText

      public final void addText(Text text)
      Appends a Text element to this element without removing existing content.
      Overrides:
      addText in class Element<T extends TextElement<T>>
      Parameters:
      text - The Text element to append.