Package org.commonmark.parser.beta
Class Scanner
- java.lang.Object
-
- org.commonmark.parser.beta.Scanner
-
public class Scanner extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static char
END
Character representing the end of input source (or outside of the text in case of the "previous" methods).private int
index
private SourceLine
line
private int
lineIndex
private int
lineLength
private java.util.List<SourceLine>
lines
-
Constructor Summary
Constructors Constructor Description Scanner(java.util.List<SourceLine> lines, int lineIndex, int index)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkPosition(int lineIndex, int index)
int
find(char c)
int
find(CharMatcher matcher)
SourceLines
getSource(Position begin, Position end)
boolean
hasNext()
int
match(CharMatcher matcher)
int
matchMultiple(char c)
void
next()
boolean
next(char c)
Check if the specified char is next and advance the position.boolean
next(java.lang.String content)
Check if we have the specified content on the line and advanced the position.static Scanner
of(SourceLines lines)
char
peek()
int
peekCodePoint()
int
peekPreviousCodePoint()
Position
position()
private void
setLine(SourceLine line)
void
setPosition(Position position)
int
whitespace()
-
-
-
Field Detail
-
END
public static final char END
Character representing the end of input source (or outside of the text in case of the "previous" methods).Note that we can use NULL to represent this because CommonMark does not allow those in the input (we replace them in the beginning of parsing).
- See Also:
- Constant Field Values
-
lines
private final java.util.List<SourceLine> lines
-
lineIndex
private int lineIndex
-
index
private int index
-
line
private SourceLine line
-
lineLength
private int lineLength
-
-
Constructor Detail
-
Scanner
Scanner(java.util.List<SourceLine> lines, int lineIndex, int index)
-
-
Method Detail
-
of
public static Scanner of(SourceLines lines)
-
peek
public char peek()
-
peekCodePoint
public int peekCodePoint()
-
peekPreviousCodePoint
public int peekPreviousCodePoint()
-
hasNext
public boolean hasNext()
-
next
public void next()
-
next
public boolean next(char c)
Check if the specified char is next and advance the position.- Parameters:
c
- the char to check (including newline characters)- Returns:
- true if matched and position was advanced, false otherwise
-
next
public boolean next(java.lang.String content)
Check if we have the specified content on the line and advanced the position. Note that if you want to match newline characters, usenext(char)
.- Parameters:
content
- the text content to match on a single line (excluding newline characters)- Returns:
- true if matched and position was advanced, false otherwise
-
matchMultiple
public int matchMultiple(char c)
-
match
public int match(CharMatcher matcher)
-
whitespace
public int whitespace()
-
find
public int find(char c)
-
find
public int find(CharMatcher matcher)
-
position
public Position position()
-
setPosition
public void setPosition(Position position)
-
getSource
public SourceLines getSource(Position begin, Position end)
-
setLine
private void setLine(SourceLine line)
-
checkPosition
private void checkPosition(int lineIndex, int index)
-
-