public class StringReader
extends java.lang.Object
| Constructor and Description |
|---|
StringReader(java.lang.String string) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead() |
boolean |
canRead(int length)
Get if the reader can read the given amount of characters.
|
StringReader |
ensureLength(int length)
Ensure that the reader can read the given amount of characters.
|
int |
getCursor() |
java.lang.String |
getString() |
int |
length() |
char |
peek() |
char |
peek(int offset)
Get the character with the given offset without moving the cursor.
|
java.lang.String |
peekRemaining() |
char |
read() |
java.lang.String |
read(int length)
Read the given amount of characters and move the cursor by the given amount of characters.
|
java.lang.String |
readDecimalNumber()
Read a word and ensure that it is a valid decimal number.
|
java.lang.String |
readIntegerNumber()
Read a word and ensure that it is a valid integer number.
|
java.lang.String |
readRemaining() |
java.lang.String |
readString()
Read a string starting with a single or double quote.
|
java.lang.String |
readUntil(char c)
Read until the given character is found or the end of the string is reached.
|
java.lang.String |
readUntil(char c,
boolean allowEscape)
Read until the given character is found or the end of the string is reached.
|
java.lang.String |
readWord()
Read a word until the next whitespace character is found.
|
java.lang.String |
readWordOrString()
Read a word or a string if the next character is a single or double quote.
|
int |
remaining() |
StringReader |
require(char... cs)
Require the next character to be in the given array.
|
StringReader |
setCursor(int cursor)
Set the cursor position.
|
StringReader |
skip()
Move the cursor by one character.
|
StringReader |
skip(int length)
Move the cursor by the given amount of characters.
|
StringReader |
skipRequiredWhitespace()
Skip all whitespace characters and ensure that at least one character was skipped.
|
StringReader |
skipRequiredWhitespaceOrEOL()
Skip all whitespace characters and ensure that at least one character was skipped.
|
StringReader |
skipWhitespace()
Skip all whitespace characters.
|
public java.lang.String getString()
public int getCursor()
public StringReader setCursor(int cursor)
cursor - The new cursor positionpublic int length()
public int remaining()
public boolean canRead()
public boolean canRead(int length)
length - The amount of characterspublic StringReader ensureLength(int length)
length - The amount of charactersjava.lang.StringIndexOutOfBoundsException - If the reader cannot read the given amount of characterspublic StringReader require(char... cs)
cs - The array of charactersjava.lang.IllegalStateException - If the nothing can be read or the next character is not in the given arraypublic char peek()
public char peek(int offset)
offset - The offsetpublic java.lang.String peekRemaining()
public StringReader skipWhitespace()
public StringReader skipRequiredWhitespace()
java.lang.IllegalStateException - If nothing can be read or the next character is not a whitespace characterpublic StringReader skipRequiredWhitespaceOrEOL()
java.lang.IllegalStateException - If the next character is not a whitespace characterpublic StringReader skip()
public StringReader skip(int length)
length - The amount of charactersjava.lang.StringIndexOutOfBoundsException - If the given amount of characters is not availablepublic char read()
public java.lang.String read(int length)
length - The amount of charactersjava.lang.StringIndexOutOfBoundsException - If the given amount of characters is not availablepublic java.lang.String readUntil(char c)
c - The characterpublic java.lang.String readUntil(char c,
boolean allowEscape)
c - The characterallowEscape - Whether to allow escapingpublic java.lang.String readRemaining()
public java.lang.String readWord()
public java.lang.String readString()
java.lang.IllegalStateException - If the end of the string is reached without finding a closing quotepublic java.lang.String readWordOrString()
java.lang.IllegalStateException - If the end of the string is reached without finding a closing quote (if a string is read)public java.lang.String readIntegerNumber()
public java.lang.String readDecimalNumber()