Record Class TextSection

java.lang.Object
java.lang.Record
ai.doctruth.TextSection
Record Components:
text - the recovered text run.
location - the source-document span this text was recovered from.
kind - the geometric / typographic classification of the block.
All Implemented Interfaces:
ParsedSection

public record TextSection(String text, SourceLocation location, BlockKind kind) extends Record implements ParsedSection
A run of plain text recovered from the source document, anchored to a SourceLocation and tagged with a BlockKind that classifies the geometric / typographic shape of the block (HEADING / BODY / LIST / OTHER).

Invariants: text, location, and kind are non-null. Empty text is allowed (an empty paragraph or whitespace-only run is still a parsed section).

The two-arg convenience constructor exists for backward compatibility with v0.1.0 callers that pre-date BlockKind; it defaults kind to BlockKind.OTHER. New code that classifies layout SHOULD prefer the three-arg form.

Since:
0.1.0
  • Constructor Details

    • TextSection

      public TextSection(String text, SourceLocation location, BlockKind kind)
      Creates an instance of a TextSection record class.
      Parameters:
      text - the value for the text record component
      location - the value for the location record component
      kind - the value for the kind record component
    • TextSection

      public TextSection(String text, SourceLocation location)
      Backward-compat 2-arg constructor — defaults kind to BlockKind.OTHER. Preserved for callers that pre-date the BlockKind upgrade; new code that classifies layout should prefer the 3-arg form.
  • Method Details

    • 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
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component
    • kind

      public BlockKind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component