Package org.ossreviewtoolkit.model
Class TextLocation
-
- All Implemented Interfaces:
-
kotlin.Comparable
public final class TextLocation implements Comparable<TextLocation>
A TextLocation references text located in a file.
-
-
Constructor Summary
Constructors Constructor Description TextLocation(String path, Integer line)A convenience constructor that sets startLine and endLine to the same line. TextLocation(String path, Integer startLine, Integer endLine)
-
Method Summary
Modifier and Type Method Description final StringgetPath()The path (with invariant separators) of the file that contains the text. final IntegergetStartLine()The line the text is starting at. final IntegergetEndLine()The line the text is ending at. IntegercompareTo(TextLocation other)final Booleancontains(Integer line)Return whether the given line is contained in the location. final Booleancontains(TextLocation other)Return whether the given other location is contained in this location. final BooleanlinesOverlapWith(TextLocation other)Return whether this and the other locations are overlapping, i.e. final IntegerdistanceTo(TextLocation other)Return the minimum distance between this and the other location. final TextLocationwithRelativePath(File basePath)Return a TextLocation whose path is relative to basePath, or throw an IllegalArgumentException if the paths have different roots. -
-
Method Detail
-
getPath
final String getPath()
The path (with invariant separators) of the file that contains the text.
-
getStartLine
final Integer getStartLine()
The line the text is starting at.
-
getEndLine
final Integer getEndLine()
The line the text is ending at.
-
compareTo
Integer compareTo(TextLocation other)
-
contains
final Boolean contains(Integer line)
Return whether the given line is contained in the location.
-
contains
final Boolean contains(TextLocation other)
Return whether the given other location is contained in this location.
-
linesOverlapWith
final Boolean linesOverlapWith(TextLocation other)
Return whether this and the other locations are overlapping, i.e. they share at least a single line. Note that the path is not compared.
-
distanceTo
final Integer distanceTo(TextLocation other)
Return the minimum distance between this and the other location. A distance of 0 means that the locations are overlapping.
-
withRelativePath
final TextLocation withRelativePath(File basePath)
Return a TextLocation whose path is relative to basePath, or throw an IllegalArgumentException if the paths have different roots.
-
-
-
-