public class StringReader
extends java.lang.Object
| Constructor and Description |
|---|
StringReader(java.lang.String s) |
| Modifier and Type | Method and Description |
|---|---|
int |
getIndex() |
boolean |
hasNext() |
char |
next()
Read the next character and increase the index by 1.
|
char |
peek()
Peek the next character without increasing the index.
|
java.lang.String |
peek(int amount)
Peek the next characters without increasing the index.
|
java.lang.String |
peekRemaining()
Peek the remaining characters without increasing the index.
|
java.lang.String |
readQuoted()
Read the next quoted string and skip all upcoming whitespace characters.
|
java.lang.String |
readUntil(char c)
Read all characters until the given character is found.
|
java.lang.String |
readWord()
Read the next word (characters until the next whitespace character) and skip all upcoming whitespace characters.
|
void |
setIndex(int index)
Set the index of the reader.
|
StringReader |
skip()
Skip the next character and increase the index by 1.
|
StringReader |
skip(int amount)
Skip the next characters and increase the index by the given amount.
|
StringReader |
skipUntil(char c)
Skip all characters until the given character is found.
|
StringReader |
skipWhitespace()
Skip all upcoming whitespace characters.
|
public int getIndex()
public void setIndex(int index)
index - The new indexjava.lang.IndexOutOfBoundsException - If the index is out of boundspublic boolean hasNext()
public char next()
java.lang.IndexOutOfBoundsException - If there are no more characters to readpublic char peek()
java.lang.IndexOutOfBoundsException - If there are no more characters to peekpublic java.lang.String peek(int amount)
amount - The amount of characters to peekjava.lang.IndexOutOfBoundsException - If there are not enough characters to peekpublic java.lang.String peekRemaining()
public StringReader skip()
java.lang.IndexOutOfBoundsException - If there are no more characters to skippublic StringReader skip(int amount)
amount - The amount of characters to skipjava.lang.IndexOutOfBoundsException - If there are not enough characters to skippublic StringReader skipWhitespace()
public StringReader skipUntil(char c)
c - The character to skip untilpublic java.lang.String readUntil(char c)
c - The character to read untilpublic java.lang.String readWord()
java.lang.IllegalStateException - If there are no more characters to readpublic java.lang.String readQuoted()
" and '.java.lang.IllegalStateException - If the next character is not a quote character