public class JSONParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ARRAY_END
Event indicating the end of a JSON array
|
static int |
ARRAY_START
Event indicating the start of a JSON array
|
static int |
BIGNUMBER
Event indicating a JSON number value that was not produced by toString of any
Java primitive numerics such as Double or Long.
|
private boolean |
bool |
static int |
BOOLEAN
Event indicating a JSON boolean
|
(package private) char[] |
buf |
private static CharArr |
devNull |
private static byte |
DID_ARRELEM |
private static byte |
DID_ARRSTART |
private static byte |
DID_MEMNAME |
private static byte |
DID_MEMVAL |
private static byte |
DID_OBJSTART |
(package private) int |
end |
(package private) boolean |
eof |
static int |
EOF
Event indicating the end of input has been reached
|
(package private) int |
event |
(package private) long |
gpos |
private static int |
HAS_EXPONENT |
private static int |
HAS_FRACTION |
(package private) java.io.Reader |
in |
static int |
LONG
Event indicating a JSON number value which fits into a signed 64 bit integer
|
private long |
lval |
private int |
nstate |
static int |
NULL
Event indicating a JSON null
|
static int |
NUMBER
Event indicating a JSON number value which has a fractional part or an exponent
and with string length <= 23 chars not including sign.
|
static int |
OBJECT_END
Event indicating the end of a JSON object
|
static int |
OBJECT_START
Event indicating the start of a JSON object
|
private CharArr |
out |
private int |
ptr |
private byte[] |
stack |
(package private) int |
start |
private byte |
state |
static int |
STRING
Event indicating a JSON string value, including member names of objects
|
private CharArr |
tmp |
private int |
valstate |
Constructor and Description |
---|
JSONParser(char[] data,
int start,
int end) |
JSONParser(java.io.Reader in) |
JSONParser(java.io.Reader in,
char[] buffer) |
JSONParser(java.lang.String data) |
JSONParser(java.lang.String data,
int start,
int end) |
Modifier and Type | Method and Description |
---|---|
private void |
continueNumber(CharArr arr) |
private java.lang.RuntimeException |
err(java.lang.String msg) |
private java.lang.String |
errEscape(int a,
int b) |
private void |
expect(char[] arr) |
protected void |
fill() |
boolean |
getBoolean()
Reads a boolean value
|
protected int |
getChar() |
private int |
getCharNWS() |
private java.lang.String |
getContext() |
double |
getDouble()
Reads a number from the input stream and parses it as a double
|
static java.lang.String |
getEventString(int e) |
int |
getLevel() |
long |
getLong()
Reads a number from the input stream and parses it as a long, only if
the value will in fact fit into a signed 64 bit integer.
|
private void |
getMore() |
void |
getNull()
Reads a null value
|
CharArr |
getNumberChars()
Returns the characters of a JSON numeric value.
|
void |
getNumberChars(CharArr output)
Reads a JSON numeric value into the output.
|
long |
getPosition() |
java.lang.String |
getString()
Returns the JSON string value, decoding any escaped characters.
|
void |
getString(CharArr output)
Reads a JSON string into the output, decoding any escaped characters.
|
CharArr |
getStringChars()
Returns the characters of a JSON string value, decoding any escaped characters.
|
private void |
goTo(int what) |
private int |
hexval(int hexdig) |
int |
lastEvent() |
private int |
next(int ch)
alternate implelentation
// middle is the pointer to the middle of a buffer to start scanning for a non-string
// character ('"' or "/").
|
int |
nextEvent()
Returns the next event encountered in the JSON stream, one of
STRING
LONG
NUMBER
BIGNUMBER
BOOLEAN
NULL
OBJECT_START
OBJECT_END
OBJECT_END
ARRAY_START
ARRAY_END
EOF
|
private void |
pop() |
private void |
push() |
private char |
readEscapedChar() |
private int |
readExp(CharArr arr,
int lim) |
private int |
readExpDigits(CharArr arr,
int lim) |
private int |
readFrac(CharArr arr,
int lim) |
private long |
readNumber(int firstChar,
boolean isNeg)
Returns the long read...
|
private CharArr |
readStringChars() |
private void |
readStringChars2(CharArr arr,
int middle) |
java.lang.String |
toString() |
boolean |
wasKey() |
public static final int STRING
public static final int LONG
public static final int NUMBER
public static final int BIGNUMBER
public static final int BOOLEAN
public static final int NULL
public static final int OBJECT_START
public static final int OBJECT_END
public static final int ARRAY_START
public static final int ARRAY_END
public static final int EOF
private static final CharArr devNull
final char[] buf
int start
int end
final java.io.Reader in
boolean eof
long gpos
int event
private final CharArr out
private byte[] stack
private int ptr
private byte state
private static final byte DID_OBJSTART
private static final byte DID_ARRSTART
private static final byte DID_ARRELEM
private static final byte DID_MEMNAME
private static final byte DID_MEMVAL
private int valstate
private boolean bool
private long lval
private int nstate
private static final int HAS_FRACTION
private static final int HAS_EXPONENT
private final CharArr tmp
public JSONParser(java.io.Reader in)
public JSONParser(java.io.Reader in, char[] buffer)
public JSONParser(char[] data, int start, int end)
public JSONParser(java.lang.String data)
public JSONParser(java.lang.String data, int start, int end)
public static java.lang.String getEventString(int e)
private final void push()
private final void pop()
protected void fill() throws java.io.IOException
java.io.IOException
private void getMore() throws java.io.IOException
java.io.IOException
protected int getChar() throws java.io.IOException
java.io.IOException
private int getCharNWS() throws java.io.IOException
java.io.IOException
private void expect(char[] arr) throws java.io.IOException
java.io.IOException
private java.lang.RuntimeException err(java.lang.String msg)
private java.lang.String getContext()
private java.lang.String errEscape(int a, int b)
private long readNumber(int firstChar, boolean isNeg) throws java.io.IOException
java.io.IOException
private int readFrac(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private int readExp(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private int readExpDigits(CharArr arr, int lim) throws java.io.IOException
java.io.IOException
private void continueNumber(CharArr arr) throws java.io.IOException
java.io.IOException
private int hexval(int hexdig)
private char readEscapedChar() throws java.io.IOException
java.io.IOException
private CharArr readStringChars() throws java.io.IOException
java.io.IOException
private void readStringChars2(CharArr arr, int middle) throws java.io.IOException
java.io.IOException
private int next(int ch) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public int nextEvent() throws java.io.IOException
java.io.IOException
public int lastEvent()
public boolean wasKey()
private void goTo(int what) throws java.io.IOException
java.io.IOException
public java.lang.String getString() throws java.io.IOException
java.io.IOException
public CharArr getStringChars() throws java.io.IOException
CharArr
should *not* be
modified as it may be shared with the input buffer.
The returned CharArr
will only be valid up until
the next JSONParser method is called. Any required data should be
read before that point.java.io.IOException
public void getString(CharArr output) throws java.io.IOException
java.io.IOException
public long getLong() throws java.io.IOException
java.io.IOException
public double getDouble() throws java.io.IOException
java.io.IOException
public CharArr getNumberChars() throws java.io.IOException
CharArr
should *not* be
modified as it may be shared with the input buffer.
The returned CharArr
will only be valid up until
the next JSONParser method is called. Any required data should be
read before that point.java.io.IOException
public void getNumberChars(CharArr output) throws java.io.IOException
java.io.IOException
public boolean getBoolean() throws java.io.IOException
java.io.IOException
public void getNull() throws java.io.IOException
java.io.IOException
public int getLevel()
public long getPosition()