public final class MutableStringStreamImpl extends java.lang.Object implements MutableStringStream
| Modifier and Type | Field and Description |
|---|---|
protected static char |
DOUBLE_QUOTE
The character for quoting
|
protected static char |
ESCAPE
The escape character
|
protected int |
pos
The current reading position
|
protected java.lang.String |
source
The source string being read
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead(int characters)
Tests whether the stream can read the given
characters count |
@NotNull java.lang.String |
consumeRemaining()
Consumes the rest of the stream
|
void |
extend(@NotNull java.lang.String str) |
boolean |
hasFinished()
Tests whether this stream has finished parsing or not
|
boolean |
hasRemaining()
Tests whether there are any characters left in the string
stream
|
boolean |
isEmpty()
Tests whether is this stream empty or not.
|
boolean |
isMutable()
Tests whether is this stream mutable or not
|
void |
moveBackward()
Moves the cursor 1 step backward
|
void |
moveBackward(int by)
Moves the cursor by the given steps backward
|
void |
moveForward()
Moves the cursor 1 step forward
|
void |
moveForward(int by)
Moves the cursor by the given steps forward
|
char |
peek()
Peeks the next character, without moving the cursor forward.
|
java.lang.String |
peek(int characters)
Peeks the next number of character, without moving the cursor forward.
|
char |
peekOffset(int offset)
Peeks the character after
offset chars, without moving the cursor forward. |
@NotNull java.lang.String |
peekRemaining()
Peeks the remainder of the string stream
|
@NotNull java.lang.String |
peekString()
Peeks the next string.
|
@NotNull java.lang.String |
peekUnquotedString()
Peeks a single, unquoted string.
|
int |
position()
Returns the cursor position
|
char |
read() |
java.lang.String |
read(int characters)
Reads the given number of characters, and moves the cursor forward.
|
boolean |
readBoolean()
Parses the next token as a
boolean. |
byte |
readByte()
Parses the next token as a
byte. |
double |
readDouble()
Parses the next token as a
double. |
float |
readFloat()
Parses the next token as a
float. |
int |
readInt()
Parses the next token as an
int. |
long |
readLong()
Parses the next token as a
long. |
short |
readShort()
Parses the next token as a
short. |
@NotNull java.lang.String |
readString() |
@NotNull java.lang.String |
readUnquotedString() |
@NotNull java.lang.String |
readUntil(char delimiter)
Reads a string until it encounters the given delimiter character.
|
@NotNull java.lang.String |
readWhile(CharPredicate predicate)
Reads from the text stream until the given predicate returns
false. |
int |
remaining()
Returns the characters remaining
|
void |
setPosition(int pos)
Sets the current position of the cursor
|
void |
skipToEnd()
Skips to the end of the stream
|
void |
skipWhitespace()
Skips all the upcoming whitespace
|
@NotNull java.lang.String |
source()
Returns the original entire string source.
|
@NotNull @Unmodifiable StringStream |
toImmutableCopy()
Returns an
StringStream copy of this string stream |
@NotNull MutableStringStream |
toMutableCopy()
Returns a new, mutable
MutableStringStream copy of this stream. |
int |
totalSize()
Returns the size of the source
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitread, readString, readUnquotedString, toImmutableCopy, toMutableCopycanRead, create, create, createMutable, createMutable, hasFinished, hasRemaining, isEmpty, peek, peek, peekOffset, peekRemaining, peekString, peekUnquotedString, position, remaining, source, totalSizeprotected static final char ESCAPE
protected static final char DOUBLE_QUOTE
protected java.lang.String source
protected int pos
public java.lang.String read(int characters)
MutableStringStreamread in interface MutableStringStreampublic void moveForward()
MutableStringStreammoveForward in interface MutableStringStreampublic void skipWhitespace()
MutableStringStreamskipWhitespace in interface MutableStringStreampublic void moveBackward()
MutableStringStreammoveBackward in interface MutableStringStreampublic void moveForward(int by)
MutableStringStreammoveForward in interface MutableStringStreamby - Steps to movepublic void moveBackward(int by)
MutableStringStreammoveBackward in interface MutableStringStreamby - Steps to move@NotNull public @NotNull java.lang.String consumeRemaining()
MutableStringStreamconsumeRemaining in interface MutableStringStreampublic void skipToEnd()
MutableStringStreamskipToEnd in interface MutableStringStream@ApiStatus.Internal
public void extend(@NotNull
@NotNull java.lang.String str)
@NotNull public @NotNull java.lang.String readUntil(char delimiter)
MutableStringStreamdelimiter
or before another backslash.readUntil in interface MutableStringStreamdelimiter - Delimiter character@NotNull public @NotNull java.lang.String readWhile(CharPredicate predicate)
MutableStringStreamfalse.readWhile in interface MutableStringStreampredicate - Predicate to test withpublic float readFloat()
MutableStringStreamfloat.readFloat in interface MutableStringStreamfloat.public double readDouble()
MutableStringStreamdouble.readDouble in interface MutableStringStreamdouble.public int readInt()
MutableStringStreamint.readInt in interface MutableStringStreamint.public long readLong()
MutableStringStreamlong.readLong in interface MutableStringStreamlong.public short readShort()
MutableStringStreamshort.readShort in interface MutableStringStreamshort.public byte readByte()
MutableStringStreambyte.readByte in interface MutableStringStreambyte.public boolean readBoolean()
MutableStringStreamboolean.readBoolean in interface MutableStringStreamboolean.public void setPosition(int pos)
MutableStringStreamsetPosition in interface MutableStringStreampos - The cursor positionpublic boolean isMutable()
isMutable in interface StringStream@NotNull public @NotNull java.lang.String source()
StringStreamsource in interface StringStreampublic int totalSize()
StringStreamtotalSize in interface StringStreampublic int remaining()
StringStreamremaining in interface StringStream@Contract(pure=true) public char peek()
StringStreampeek in interface StringStreampublic java.lang.String peek(int characters)
StringStreampeek in interface StringStream@Contract(pure=true) public char peekOffset(int offset)
StringStreamoffset chars, without moving the cursor forward.peekOffset in interface StringStreamoffset - Characters to peekpublic boolean hasRemaining()
StringStreamhasRemaining in interface StringStreampublic boolean hasFinished()
StringStreamhasFinished in interface StringStreampublic boolean canRead(int characters)
StringStreamcharacters countcanRead in interface StringStreamcharacters - Number of characterspublic int position()
StringStreamposition in interface StringStream@NotNull public @NotNull java.lang.String readUnquotedString()
@NotNull public @NotNull java.lang.String readString()
public char read()
@NotNull public @NotNull java.lang.String peekString()
StringStreamThis will not move the cursor forward.
peekString in interface StringStream@NotNull public @NotNull java.lang.String peekUnquotedString()
StringStreamThis will not move the cursor forward.
peekUnquotedString in interface StringStream@NotNull public @NotNull java.lang.String peekRemaining()
StringStreampeekRemaining in interface StringStream@NotNull public @NotNull @Unmodifiable StringStream toImmutableCopy()
StringStreamStringStream copy of this string streamtoImmutableCopy in interface StringStream@NotNull
@Contract(value="-> new",
pure=true)
public @NotNull MutableStringStream toMutableCopy()
StringStreamMutableStringStream copy of this stream.toMutableCopy in interface StringStreampublic boolean isEmpty()
StringStream
This is equivalent to String.isEmpty()
isEmpty in interface StringStream