public class JsonParser extends Object
| Modifier and Type | Field and Description |
|---|---|
private char[] |
buffer |
private int |
bufferOffset |
private StringBuilder |
captureBuffer |
private int |
captureStart |
private int |
current |
private static int |
DEFAULT_BUFFER_SIZE |
private int |
fill |
private JsonHandler<Object,Object> |
handler |
private int |
index |
private int |
line |
private int |
lineOffset |
private static int |
MAX_NESTING_LEVEL |
private static int |
MIN_BUFFER_SIZE |
private int |
nestingLevel |
private Reader |
reader |
| Constructor and Description |
|---|
JsonParser(JsonHandler<?,?> handler)
Creates a new JsonParser with the given handler.
|
| Modifier and Type | Method and Description |
|---|---|
private String |
endCapture() |
private ParseException |
error(String message) |
private ParseException |
expected(String expected) |
(package private) Location |
getLocation() |
private boolean |
isDigit() |
private boolean |
isEndOfText() |
private boolean |
isHexDigit() |
private boolean |
isWhiteSpace() |
void |
parse(Reader reader)
Reads the entire input from the given reader and parses it as JSON.
|
void |
parse(Reader reader,
int buffersize)
Reads the entire input from the given reader and parses it as JSON.
|
void |
parse(String string)
Parses the given input string.
|
private void |
pauseCapture() |
private void |
read() |
private void |
readArray() |
private boolean |
readChar(char ch) |
private boolean |
readDigit() |
private void |
readEscape() |
private boolean |
readExponent() |
private void |
readFalse() |
private boolean |
readFraction() |
private String |
readName() |
private void |
readNull() |
private void |
readNumber() |
private void |
readObject() |
private void |
readRequiredChar(char ch) |
private void |
readString() |
private String |
readStringInternal() |
private void |
readTrue() |
private void |
readValue() |
private void |
skipWhiteSpace() |
private void |
startCapture() |
private static final int MAX_NESTING_LEVEL
private static final int MIN_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
private final JsonHandler<Object,Object> handler
private Reader reader
private char[] buffer
private int bufferOffset
private int index
private int fill
private int line
private int lineOffset
private int current
private StringBuilder captureBuffer
private int captureStart
private int nestingLevel
public JsonParser(JsonHandler<?,?> handler)
handler - the handler to process parser eventspublic void parse(String string)
string - the input string, must be valid JSONParseException - if the input is not valid JSONpublic void parse(Reader reader) throws IOException
Characters are read in chunks into a default-sized input buffer. Hence, wrapping a reader in an
additional BufferedReader likely won't improve reading performance.
reader - the reader to read the input fromIOException - if an I/O error occurs in the readerParseException - if the input is not valid JSONpublic void parse(Reader reader, int buffersize) throws IOException
Characters are read in chunks into an input buffer of the given size. Hence, wrapping a reader
in an additional BufferedReader likely won't improve reading performance.
reader - the reader to read the input frombuffersize - the size of the input buffer in charsIOException - if an I/O error occurs in the readerParseException - if the input is not valid JSONprivate void readValue()
throws IOException
IOExceptionprivate void readArray()
throws IOException
IOExceptionprivate void readObject()
throws IOException
IOExceptionprivate String readName() throws IOException
IOExceptionprivate void readNull()
throws IOException
IOExceptionprivate void readTrue()
throws IOException
IOExceptionprivate void readFalse()
throws IOException
IOExceptionprivate void readRequiredChar(char ch)
throws IOException
IOExceptionprivate void readString()
throws IOException
IOExceptionprivate String readStringInternal() throws IOException
IOExceptionprivate void readEscape()
throws IOException
IOExceptionprivate void readNumber()
throws IOException
IOExceptionprivate boolean readFraction()
throws IOException
IOExceptionprivate boolean readExponent()
throws IOException
IOExceptionprivate boolean readChar(char ch)
throws IOException
IOExceptionprivate boolean readDigit()
throws IOException
IOExceptionprivate void skipWhiteSpace()
throws IOException
IOExceptionprivate void read()
throws IOException
IOExceptionprivate void startCapture()
private void pauseCapture()
private String endCapture()
Location getLocation()
private ParseException expected(String expected)
private ParseException error(String message)
private boolean isWhiteSpace()
private boolean isDigit()
private boolean isHexDigit()
private boolean isEndOfText()
Copyright © 2011–2016 David R. Smith. All rights reserved.