public class SourceSpan extends Object
It has a starting position (line and column index) and a length of how many characters it spans.
For example, this CommonMark source text:
> foo
The BlockQuote node would have this source span: line 0, column 0, length 5.
The Paragraph node inside it would have: line 0, column 2, length 3.
If a block has multiple lines, it will have a source span for each line.
Note that the column index and length are measured in Java characters (UTF-16 code units). If you're outputting them to be consumed by another programming language, e.g. one that uses UTF-8 strings, you will need to translate them, otherwise characters such as emojis will result in incorrect positions.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
getColumnIndex() |
int |
getLength() |
int |
getLineIndex() |
int |
hashCode() |
static SourceSpan |
of(int lineIndex,
int columnIndex,
int length) |
String |
toString() |
public static SourceSpan of(int lineIndex, int columnIndex, int length)
public int getLineIndex()
public int getColumnIndex()
public int getLength()
Copyright © 2021. All rights reserved.