Class LineAndColumn
java.lang.Object
org.dellroad.javabox.LineAndColumn
Represents a character offset into a
String, along with associated line and column offsets.
This class does not store the string itself, just the offset information within it.
The character, line, and column offsets are zero-based. Columns are measured in codepoints rather than characters.
Instances are immutable.
-
Method Summary
Modifier and TypeMethodDescriptionUpdate the offsets by advancing through the given string.intGet the column offset.booleaninthashCode()static LineAndColumninitial()Obtain an initial instance with all offsets set to zero.intGet the line offset.intoffset()Get the overall character offset.toString()
-
Method Details
-
initial
Obtain an initial instance with all offsets set to zero. -
offset
public int offset()Get the overall character offset.- Returns:
- character offset (zero based)
-
lineOffset
public int lineOffset()Get the line offset.- Returns:
- line offset (zero based)
-
columnOffset
public int columnOffset()Get the column offset.- Returns:
- column offset (zero based)
-
advance
Update the offsets by advancing through the given string.- Parameters:
text- string content- Returns:
- updated instance
- Throws:
IllegalArgumentException- iftextis nullIllegalArgumentException- if the offsets would overflow
-
hashCode
-
equals
-
toString
-