java.lang.Object
de.linusdev.data.parser.JsonReader
A
Reader like class, that makes reading a json-object much easier.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidpushBack(int i) Pushes given character back, so the nextread(ParseTracker)call will read it.
The push back buffer supports only a single character, if the buffer is not empty, it will be overwritten, and the old character will be lost.intread(@NotNull ParseTracker tracker) reads to the next character, which integer value is not below 33.readString(boolean allowNewLine, @NotNull ParseTracker tracker) reads until a '"' is read.@Nullable ObjectreadValue(@NotNull ParseTracker tracker) reads until ',' is read.
-
Constructor Details
-
JsonReader
-
-
Method Details
-
pushBack
public void pushBack(int i) Pushes given character back, so the nextread(ParseTracker)call will read it.
The push back buffer supports only a single character, if the buffer is not empty, it will be overwritten, and the old character will be lost.- Parameters:
i- character to push back
-
read
reads to the next character, which integer value is not below 33.- Returns:
- next character or -1 if end of the stream is reached.
- Throws:
IOException
-
readValue
@Nullable public @Nullable Object readValue(@NotNull @NotNull ParseTracker tracker) throws IOException, ParseException reads until ',' is read. the ',' will be pushed back.- Parameters:
tracker-ParseTracker- Returns:
- read value, may be
Boolean,nullorNumber - Throws:
IOException- while reading or parsingParseException- while reading or parsing
-
readString
public String readString(boolean allowNewLine, @NotNull @NotNull ParseTracker tracker) throws IOException, UnexpectedEndException, UnexpectedCharacterException reads until a '"' is read.- Parameters:
allowNewLine- whether to allow a line break while readingtracker-ParseTracker- Returns:
- read
String - Throws:
IOException- while reading or parsingUnexpectedEndException- while reading or parsingUnexpectedCharacterException- while reading or parsing
-
close
public void close()
-