public class CharacterStream extends Object
| 构造器和说明 |
|---|
CharacterStream(String source) |
CharacterStream(String source,
int start,
int end) |
| 限定符和类型 | 方法和说明 |
|---|---|
char |
consume()
返回下一个字符
|
Span |
endSpan()
根据当前位置返回Span
|
Span |
endSpan(int offset)
根据当前位置 - offset 返回 Span
|
Span |
endSpan(int start,
int end) |
int |
getPosition()
返回当前位置
|
Span |
getSpan(int start,
int end)
根据开始位置、结束位置返回Span
|
boolean |
hasMore()
是否有下一个字符
|
boolean |
match(String needle,
boolean consume)
返回是否是以给定的字符串开头
|
boolean |
matchAny(boolean consume,
String... strs)
匹配任意字符串
|
boolean |
matchDigit(boolean consume)
返回是否是数字
|
boolean |
matchIdentifierPart(boolean consume)
返回是否是标识符部分
|
boolean |
matchIdentifierStart(boolean consume)
返回是否以标识符开头
|
void |
reset(int position)
重置当前位置
|
void |
skipLine()
跳过一行
|
boolean |
skipUntil(String chars)
直到给定的字符串之前全部跳过
|
void |
skipWhiteSpace()
跳过空白字符
|
void |
startSpan()
记录当前位置为Span的开始位置
|
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)
startIndex - 开始位置endIndex - 结束位置public boolean hasMore()
public Span getSpan(int start, int end)
public char consume()
public boolean match(String needle, boolean consume)
public boolean matchAny(boolean consume,
String... strs)
strs - 任意字符串public boolean matchDigit(boolean consume)
public boolean matchIdentifierStart(boolean consume)
public boolean matchIdentifierPart(boolean consume)
consume - 是否消耗public void skipLine()
public boolean skipUntil(String chars)
public void skipWhiteSpace()
public void startSpan()
public Span endSpan()
public Span endSpan(int offset)
public Span endSpan(int start, int end)
public int getPosition()
public void reset(int position)
Copyright © 2020–2021. All rights reserved.