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 onpageStart.lineEnd- 1-indexed last line onpageEnd(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, thenlineEnd >= lineStart. Cross-page spans intentionally allowlineEnd < lineStartbecause line numbers reset per page.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSourceLocation(int pageStart, int pageEnd, int lineStart, int lineEnd, int charOffset) Creates an instance of aSourceLocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecharOffsetrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intlineEnd()Returns the value of thelineEndrecord component.intReturns the value of thelineStartrecord component.intpageEnd()Returns the value of thepageEndrecord component.intReturns the value of thepageStartrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SourceLocation
public SourceLocation(int pageStart, int pageEnd, int lineStart, int lineEnd, int charOffset) Creates an instance of aSourceLocationrecord class.- Parameters:
pageStart- the value for thepageStartrecord componentpageEnd- the value for thepageEndrecord componentlineStart- the value for thelineStartrecord componentlineEnd- the value for thelineEndrecord componentcharOffset- the value for thecharOffsetrecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
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 thecomparemethod from their corresponding wrapper classes. -
pageStart
-
pageEnd
-
lineStart
-
lineEnd
-
charOffset
public int charOffset()Returns the value of thecharOffsetrecord component.- Returns:
- the value of the
charOffsetrecord component
-