public class CharacterStream extends Object
Source and handles traversing the contained characters. Manages a current Span via
the startSpan() and endSpan() methods.| 构造器和说明 |
|---|
CharacterStream(String source) |
CharacterStream(String source,
int start,
int end) |
| 限定符和类型 | 方法和说明 |
|---|---|
char |
consume()
Returns the next character and advance the stream
|
Span |
endSpan()
Completes the span started with
startSpan() at the current stream position. |
int |
getPosition()
Returns the current character position in the stream.
|
Span |
getSpan(int start,
int end) |
boolean |
hasMore()
Returns whether there are more characters in the stream
|
boolean |
match(String needle,
boolean consume)
Matches the given needle with the next characters.
|
boolean |
matchDigit(boolean consume)
Returns whether the next character is a digit and optionally consumes it.
|
boolean |
matchIdentifierPart(boolean consume)
Returns whether the next character is the start of an identifier and optionally consumes it.
|
boolean |
matchIdentifierStart(boolean consume)
Returns whether the next character is the start of an identifier and optionally consumes it.
|
char |
peek()
Returns the next character without advancing the stream
|
void |
reset(int position) |
void |
skipLine() |
void |
skipUntil(String chars) |
void |
skipWhiteSpace()
Skips any number of successive whitespace characters.
|
void |
startSpan()
Start a new Span at the current stream position.
|
String |
substring(int startIndex,
int endIndex) |
public CharacterStream(String source)
public CharacterStream(String source, int start, int end)
public String substring(int startIndex, int endIndex)
public boolean hasMore()
public char peek()
public Span getSpan(int start, int end)
public char consume()
public boolean match(String needle, boolean consume)
public boolean matchDigit(boolean consume)
public boolean matchIdentifierStart(boolean consume)
Character.isJavaIdentifierStart(char).public boolean matchIdentifierPart(boolean consume)
Character.isJavaIdentifierPart(char).public void skipLine()
public void skipUntil(String chars)
public void skipWhiteSpace()
public void startSpan()
endSpan() to complete the span.public Span endSpan()
startSpan() at the current stream position.public int getPosition()
public void reset(int position)
Copyright © 2020–2021. All rights reserved.