Record Class SourceLocation

java.lang.Object
java.lang.Record
ai.doctruth.SourceLocation
Record Components:
pageStart - 1-indexed first page of the span.
pageEnd - 1-indexed last page of the span (inclusive); >= pageStart.
lineStart - 1-indexed first line on pageStart.
lineEnd - 1-indexed last line on pageEnd (inclusive).
charOffset - 0-indexed character offset into the source page text where the span begins.

public record SourceLocation(int pageStart, int pageEnd, int lineStart, int lineEnd, int charOffset) extends Record
A 1-indexed page + line span into a parsed source document, plus a 0-indexed character offset into the source page text. Used as the verifiable anchor for every Citation.

Invariants (enforced by the compact constructor):

  • pageStart >= 1 — pages are 1-indexed (PDF/PDFBox convention).
  • pageEnd >= pageStart.
  • lineStart >= 1, lineEnd >= 1 — line numbers are per-page, 1-indexed.
  • charOffset >= 0.
  • If pageStart == pageEnd, then lineEnd >= lineStart. Cross-page spans intentionally allow lineEnd < lineStart because line numbers reset per page.
Since:
0.1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    SourceLocation(int pageStart, int pageEnd, int lineStart, int lineEnd, int charOffset)
    Creates an instance of a SourceLocation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the charOffset record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the lineEnd record component.
    int
    Returns the value of the lineStart record component.
    int
    Returns the value of the pageEnd record component.
    int
    Returns the value of the pageStart record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SourceLocation

      public SourceLocation(int pageStart, int pageEnd, int lineStart, int lineEnd, int charOffset)
      Creates an instance of a SourceLocation record class.
      Parameters:
      pageStart - the value for the pageStart record component
      pageEnd - the value for the pageEnd record component
      lineStart - the value for the lineStart record component
      lineEnd - the value for the lineEnd record component
      charOffset - the value for the charOffset record component
  • 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 the compare method from their corresponding wrapper classes.
      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.
    • pageStart

      public int pageStart()
      Returns the value of the pageStart record component.
      Returns:
      the value of the pageStart record component
    • pageEnd

      public int pageEnd()
      Returns the value of the pageEnd record component.
      Returns:
      the value of the pageEnd record component
    • lineStart

      public int lineStart()
      Returns the value of the lineStart record component.
      Returns:
      the value of the lineStart record component
    • lineEnd

      public int lineEnd()
      Returns the value of the lineEnd record component.
      Returns:
      the value of the lineEnd record component
    • charOffset

      public int charOffset()
      Returns the value of the charOffset record component.
      Returns:
      the value of the charOffset record component