java.lang.Object
net.luis.utils.io.token.TokenReader.PositionTracker
- Enclosing class:
TokenReader
A class that tracks the position of the current character in the input string.
It keeps track of the line number, character position, and character index in the line.
It keeps track of the line number, character position, and character index in the line.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The index of the current character in the line.private int
The line number of the current character in the input string.private int
The index of the current character in the input string. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
copyFrom
(@NotNull TokenReader.PositionTracker other) Copies the position from another position tracker.
It sets the line number, character position, and character index to the values of the other position tracker.private void
Counts a new character in the input string.
It increments the position and character index.private void
newLine()
Counts a new line in the input string.
It increments the position and character index, and resets the character in line index to 0.private @NotNull TokenPosition
Creates a new token position based on the current position tracker.
-
Field Details
-
line
private int lineThe line number of the current character in the input string. -
position
private int positionThe index of the current character in the input string. -
charInLine
private int charInLineThe index of the current character in the line.
-
-
Constructor Details
-
PositionTracker
private PositionTracker()
-
-
Method Details
-
increment
private void increment()Counts a new character in the input string.
It increments the position and character index. -
newLine
private void newLine()Counts a new line in the input string.
It increments the position and character index, and resets the character in line index to 0. -
copyFrom
Copies the position from another position tracker.
It sets the line number, character position, and character index to the values of the other position tracker.- Parameters:
other
- The other position tracker to copy from- Throws:
NullPointerException
- If the other position tracker is null
-
toTokenPosition
Creates a new token position based on the current position tracker.- Returns:
- A new token position
-