public interface ArgumentReader
| Modifier and Type | Method and Description |
|---|---|
boolean |
atEnd()
Gets whether the reader has reached the last character.
|
char |
get()
Gets the current character this reader is looking at
|
int |
index()
Gets the current index of the reader
|
void |
jumpTo(int index)
Sets the index to something else, "jumping" to that location
|
char |
next()
Advances the reader by 1, returning the current character after advancing
|
@NotNull String |
nextWord()
Returns the next word and places the reader on the space after that word, or the last character in the reader
|
int |
size()
Gets the size of the underlying data
|
@NotNull String |
splice(int beginning)
Performs a splice that gets a string starting at index
beginning and ending at index size() |
@NotNull String |
splice(int beginning,
int end)
Performs a splice that gets a string starting at index
beginning and ending at index end |
char get()
char next()
char next = reader.next();
char current = reader.get();
assert next == current;
IllegalStateException - If the reader has already reached the last characterboolean atEnd()
next() will throw an exception.
This is the same as checking if index() == size() - 1true if the reader is at the last character, false otherwiseint index()
int size()
void jumpTo(int index)
index - The index to set toIndexOutOfBoundsException - If index is negative or greater than or equal to size()@NotNull @NotNull String splice(int beginning)
beginning and ending at index size()
// reader has the internal string of "hello there"
String spliced = reader.splice(2);
assert spliced.equals("llo there");
beginning - The index to start at@NotNull @NotNull String splice(int beginning, int end)
beginning and ending at index end
// reader has the internal string of "hello there"
String spliced = reader.splice(2, 8);
assert spliced.equals("llo th");
beginning - The index to start atend - The index to end at@NotNull @NotNull String nextWord()
// reader has the internal string of "hello there"
String word = reader.nextWord();
assert word.equals("hello");
assert reader.get() == ' ';
Copyright © 2024. All rights reserved.