Record Class TextRun

java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.model.text.TextRun
Record Components:
text - literal text, including any spaces or line feeds
style - optional run-level overrides, or null to inherit from the block or cell
href - external hyperlink target, or null for unlinked text
pageNumber - optional dynamic page field; text must be empty when supplied

public record TextRun(String text, Style style, String href, PageNumber pageNumber) extends Record
Literal inline text with optional style overrides and an external hyperlink. Text is XML-escaped during rendering, and spaces and line feeds are preserved by text blocks; it is never interpreted as HTML markup. Styles apply after the containing block or cell.

Construction performs no validation. Generation permits empty text but requires nonnull XML-compatible text. A supplied link must be a syntactically valid absolute HTTP, HTTPS, or mailto URI with a nonempty scheme-specific part; HTTP(S) links also require a host.

  • Constructor Details

    • TextRun

      public TextRun(String text, Style style, String href)
      Creates a literal text run without a dynamic page field.
      Parameters:
      text - literal text
      style - nullable inline style
      href - nullable link destination
    • TextRun

      public TextRun(String text, Style style, String href, PageNumber pageNumber)
      Creates an instance of a TextRun record class.
      Parameters:
      text - the value for the text record component
      style - the value for the style record component
      href - the value for the href record component
      pageNumber - the value for the pageNumber record component
  • Method Details

    • currentPage

      public static TextRun currentPage()
      Returns:
      a current physical page-number run with inherited appearance
    • pageCount

      public static TextRun pageCount()
      Returns:
      a total physical page-count run with inherited appearance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • style

      public Style style()
      Returns the value of the style record component.
      Returns:
      the value of the style record component
    • href

      public String href()
      Returns the value of the href record component.
      Returns:
      the value of the href record component
    • pageNumber

      public PageNumber pageNumber()
      Returns the value of the pageNumber record component.
      Returns:
      the value of the pageNumber record component