Class JsonParser
java.lang.Object
com.formdev.flatlaf.json.JsonParser
A streaming parser for JSON text. The parser reports all events to a given handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate char[]private intprivate StringBuilderprivate intprivate intprivate static final intprivate intprivate final JsonHandler<Object, Object> private intprivate intprivate intprivate static final intprivate static final intprivate intprivate Reader -
Constructor Summary
ConstructorsConstructorDescriptionJsonParser(JsonHandler<?, ?> handler) Creates a new JsonParser with the given handler. -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringprivate ParseExceptionprivate ParseException(package private) Locationprivate booleanisDigit()private booleanprivate booleanprivate booleanvoidReads the entire input from the given reader and parses it as JSON.voidReads the entire input from the given reader and parses it as JSON.voidParses the given input string.private voidprivate voidread()private voidprivate booleanreadChar(char ch) private booleanprivate voidprivate booleanprivate voidprivate booleanprivate StringreadName()private voidreadNull()private voidprivate voidprivate voidreadRequiredChar(char ch) private voidprivate Stringprivate voidreadTrue()private voidprivate voidprivate void
-
Field Details
-
MAX_NESTING_LEVEL
private static final int MAX_NESTING_LEVEL- See Also:
-
MIN_BUFFER_SIZE
private static final int MIN_BUFFER_SIZE- See Also:
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE- See Also:
-
handler
-
reader
-
buffer
private char[] buffer -
bufferOffset
private int bufferOffset -
index
private int index -
fill
private int fill -
line
private int line -
lineOffset
private int lineOffset -
current
private int current -
captureBuffer
-
captureStart
private int captureStart -
nestingLevel
private int nestingLevel
-
-
Constructor Details
-
JsonParser
Creates a new JsonParser with the given handler. The parser will report all parser events to this handler.- Parameters:
handler- the handler to process parser events
-
-
Method Details
-
parse
Parses the given input string. The input must contain a valid JSON value, optionally padded with whitespace.- Parameters:
string- the input string, must be valid JSON- Throws:
ParseException- if the input is not valid JSON
-
parse
Reads the entire input from the given reader and parses it as JSON. The input must contain a valid JSON value, optionally padded with whitespace.Characters are read in chunks into a default-sized input buffer. Hence, wrapping a reader in an additional
BufferedReaderlikely won't improve reading performance.- Parameters:
reader- the reader to read the input from- Throws:
IOException- if an I/O error occurs in the readerParseException- if the input is not valid JSON
-
parse
Reads the entire input from the given reader and parses it as JSON. The input must contain a valid JSON value, optionally padded with whitespace.Characters are read in chunks into an input buffer of the given size. Hence, wrapping a reader in an additional
BufferedReaderlikely won't improve reading performance.- Parameters:
reader- the reader to read the input frombuffersize- the size of the input buffer in chars- Throws:
IOException- if an I/O error occurs in the readerParseException- if the input is not valid JSON
-
readValue
- Throws:
IOException
-
readArray
- Throws:
IOException
-
readObject
- Throws:
IOException
-
readName
- Throws:
IOException
-
readNull
- Throws:
IOException
-
readTrue
- Throws:
IOException
-
readFalse
- Throws:
IOException
-
readRequiredChar
- Throws:
IOException
-
readString
- Throws:
IOException
-
readStringInternal
- Throws:
IOException
-
readEscape
- Throws:
IOException
-
readNumber
- Throws:
IOException
-
readFraction
- Throws:
IOException
-
readExponent
- Throws:
IOException
-
readChar
- Throws:
IOException
-
readDigit
- Throws:
IOException
-
skipWhiteSpace
- Throws:
IOException
-
read
- Throws:
IOException
-
startCapture
private void startCapture() -
pauseCapture
private void pauseCapture() -
endCapture
-
getLocation
Location getLocation() -
expected
-
error
-
isWhiteSpace
private boolean isWhiteSpace() -
isDigit
private boolean isDigit() -
isHexDigit
private boolean isHexDigit() -
isEndOfText
private boolean isEndOfText()
-