Class HTMLContent

java.lang.Object
com.amalgamasimulation.desktop.html.HTMLContent
All Implemented Interfaces:
HTMLConvertable

public class HTMLContent extends Object implements HTMLConvertable
The HTMLContent class represents a piece of content that can be converted to HTML. It implements the HTMLConvertable interface, providing a method to convert the content to an HTML string.
Author:
Alexey Glazyrin
  • Constructor Details

    • HTMLContent

      public HTMLContent(String content)
      Constructs a new HTMLContent instance with the specified content.
      Parameters:
      content - the content to be converted to HTML
  • Method Details

    • content

      public HTMLContent content(String content)
      Sets the content of this HTMLContent instance and returns the modified instance to allow method chaining.
      Parameters:
      content - the new content to set
      Returns:
      this instance after modification
    • content

      public String content()
      Retrieves the current content of this HTMLContent instance.
      Returns:
      the current content string
    • toHTML

      public String toHTML(Set<String> outStringsMap)
      Converts the content to an HTML string. If the content is null, an empty string is returned.
      Specified by:
      toHTML in interface HTMLConvertable
      Parameters:
      outStringsMap - set of unique strings of text content
      Returns:
      the HTML representation of the content
    • copy

      public HTMLContent copy(Map<String,String> stringsSubstitutionMap)
      Description copied from interface: HTMLConvertable
      Creates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.
      Specified by:
      copy in interface HTMLConvertable
      Parameters:
      stringsSubstitutionMap - a map where keys are original text strings (as collected by HTMLConvertable.toHTML(Set)) and values are their translations. During copying, any encountered text content present in this map will be replaced with its translated version.
      Returns:
      a new independent copy of this HTMLConvertable instance with translated content