Class CmsAiTranslator.HtmlParseResult

java.lang.Object
org.opencms.ai.CmsAiTranslator.HtmlParseResult
Enclosing class:
CmsAiTranslator

public static class CmsAiTranslator.HtmlParseResult extends Object
Holder for parsed HTML text nodes and helper operations.

  • Constructor Details

    • HtmlParseResult

      public HtmlParseResult(org.jsoup.nodes.Document doc, List<org.jsoup.nodes.TextNode> textNodes, boolean isFullDocument)
      Creates a new parse result.

      Parameters:
      doc - the parsed document
      textNodes - the collected text nodes
      isFullDocument - true if input is a full HTML document
  • Method Details

    • splitTranslateString

      public static List<String> splitTranslateString(String input)
      Splits a translation string into segments by marker tokens.

      Parameters:
      input - the translation string
      Returns:
      the list of segments
    • getDocument

      public org.jsoup.nodes.Document getDocument()
      Returns the parsed document.

      Returns:
      the parsed document
    • getTextNodes

      public List<org.jsoup.nodes.TextNode> getTextNodes()
      Returns the collected text nodes.

      Returns:
      the collected text nodes
    • isFullDocument

      public boolean isFullDocument()
      Returns true if the input represented a full document.

      Returns:
      true if the input is a full document
    • setTranslatedString

      public String setTranslatedString(String translation) throws CmsAiException
      Applies a translated string to the text nodes and returns the HTML output.

      Parameters:
      translation - the translated string
      Returns:
      the resulting HTML
      Throws:
      CmsAiException - if the translation does not match the text node count
    • toString

      public String toString()
      Returns a string representation of the HTML of the parsed document.

      Overrides:
      toString in class Object
      See Also:
    • toTranslateString

      Returns a concatenated string with markers between text nodes.

      Returns:
      the translation input string